/** Get the type name of a random occludee entity. * * @param dynamic If true, the name of a dynamic entity will be returned (mass > 0) * @return Name of a random entity type */ private String getRandomOccludeeType (boolean dynamic) { int i = rng.nextInt(OCCLUDEE_PATHS_STATIC.length); return (dynamic) ? OCCLUDEE_PATHS_DYNAMIC[i] : OCCLUDEE_PATHS_STATIC[i]; }
/** Adds an occludee entity of random type at a random place on the ground. * * @param dynamic If true, entity body will be dynamic (mass > 0) * @return The added entity */ private BulletEntity addRandomOccludee (boolean dynamic) { // Add occludee to world BulletEntity entity = world.add(getRandomOccludeeType(dynamic), 0, 0, 0); entity.setColor(Color.WHITE); // Random rotation float rotationY = rng.nextFloat() * 360f; // Random ground position Vector3 position = tmpV1; int maxDstX = (int)(GROUND_DIM.x * 0.49f); position.x = rng.nextInt(maxDstX) * ((rng.nextBoolean()) ? 1 : -1); position.z = rng.nextInt(maxDstX) * ((rng.nextBoolean()) ? 1 : -1); position.y = entity.boundingBox.getDimensions(tmpV2).y * 0.5f; entity.modelInstance.transform.setToRotation(Vector3.Y, rotationY).setTranslation(position); entity.body.setWorldTransform(entity.modelInstance.transform); return entity; }