/** * This method fills the point with coordinates of randomly selected mesh vertex. * @param store * the variable to store with coordinates of randomly selected mesh vertex */ @Override public void getRandomPoint(Vector3f store) { int meshIndex = FastMath.nextRandomInt(0, vertices.size() - 1); int vertIndex = FastMath.nextRandomInt(0, vertices.get(meshIndex).size() - 1); store.set(vertices.get(meshIndex).get(vertIndex)); }
/** * This method fills the point with coordinates of randomly selected mesh vertex. * The normal param is filled with selected vertex's normal. * @param store * the variable to store with coordinates of randomly selected mesh vertex * @param normal * filled with selected vertex's normal */ @Override public void getRandomPointAndNormal(Vector3f store, Vector3f normal) { int meshIndex = FastMath.nextRandomInt(0, vertices.size() - 1); int vertIndex = FastMath.nextRandomInt(0, vertices.get(meshIndex).size() - 1); store.set(vertices.get(meshIndex).get(vertIndex)); normal.set(normals.get(meshIndex).get(vertIndex)); }
private Geometry createInstance(float x, float z) { Mesh mesh; if (FastMath.nextRandomInt(0, 1) == 1) mesh = mesh2; else mesh = mesh1; Geometry geometry = new Geometry("randomGeom", mesh); geometry.setMaterial(materials[FastMath.nextRandomInt(0, materials.length - 1)]); geometry.setLocalTranslation(x, 0, z); return geometry; }
/** * This method fills the point with coordinates of randomly selected point on a random face. * @param store * the variable to store with coordinates of randomly selected selected point on a random face */ @Override public void getRandomPoint(Vector3f store) { int meshIndex = FastMath.nextRandomInt(0, vertices.size() - 1); // the index of the first vertex of a face (must be dividable by 3) int vertIndex = FastMath.nextRandomInt(0, vertices.get(meshIndex).size() / 3 - 1) * 3; // put the point somewhere between the first and the second vertex of a face float moveFactor = FastMath.nextRandomFloat(); store.set(Vector3f.ZERO); store.addLocal(vertices.get(meshIndex).get(vertIndex)); store.addLocal((vertices.get(meshIndex).get(vertIndex + 1).x - vertices.get(meshIndex).get(vertIndex).x) * moveFactor, (vertices.get(meshIndex).get(vertIndex + 1).y - vertices.get(meshIndex).get(vertIndex).y) * moveFactor, (vertices.get(meshIndex).get(vertIndex + 1).z - vertices.get(meshIndex).get(vertIndex).z) * moveFactor); // move the result towards the last face vertex moveFactor = FastMath.nextRandomFloat(); store.addLocal((vertices.get(meshIndex).get(vertIndex + 2).x - store.x) * moveFactor, (vertices.get(meshIndex).get(vertIndex + 2).y - store.y) * moveFactor, (vertices.get(meshIndex).get(vertIndex + 2).z - store.z) * moveFactor); }
/** * This method fills the point with coordinates of randomly selected point on a random face. * The normal param is filled with selected face's normal. * @param store * the variable to store with coordinates of randomly selected selected point on a random face * @param normal * filled with selected face's normal */ @Override public void getRandomPointAndNormal(Vector3f store, Vector3f normal) { int meshIndex = FastMath.nextRandomInt(0, vertices.size() - 1); // the index of the first vertex of a face (must be dividable by 3) int faceIndex = FastMath.nextRandomInt(0, vertices.get(meshIndex).size() / 3 - 1); int vertIndex = faceIndex * 3; // put the point somewhere between the first and the second vertex of a face float moveFactor = FastMath.nextRandomFloat(); store.set(Vector3f.ZERO); store.addLocal(vertices.get(meshIndex).get(vertIndex)); store.addLocal((vertices.get(meshIndex).get(vertIndex + 1).x - vertices.get(meshIndex).get(vertIndex).x) * moveFactor, (vertices.get(meshIndex).get(vertIndex + 1).y - vertices.get(meshIndex).get(vertIndex).y) * moveFactor, (vertices.get(meshIndex).get(vertIndex + 1).z - vertices.get(meshIndex).get(vertIndex).z) * moveFactor); // move the result towards the last face vertex moveFactor = FastMath.nextRandomFloat(); store.addLocal((vertices.get(meshIndex).get(vertIndex + 2).x - store.x) * moveFactor, (vertices.get(meshIndex).get(vertIndex + 2).y - store.y) * moveFactor, (vertices.get(meshIndex).get(vertIndex + 2).z - store.z) * moveFactor); normal.set(normals.get(meshIndex).get(faceIndex)); } }
/** * Randomly Places a cube on the map between 30 and 90 paces away from player */ private void randomizeCube() { Geometry cube = fcube.clone(); int playerX = (int) player.getLocalTranslation().getX(); int playerZ = (int) player.getLocalTranslation().getZ(); // float x = FastMath.nextRandomInt(playerX + difficulty + 10, playerX + difficulty + 150); float x = FastMath.nextRandomInt(playerX + difficulty + 30, playerX + difficulty + 90); float z = FastMath.nextRandomInt(playerZ - difficulty - 50, playerZ + difficulty + 50); cube.getLocalTranslation().set(x, 0, z); // playerX+difficulty+30,playerX+difficulty+90 Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); if (!solidBox){ mat.getAdditionalRenderState().setWireframe(true); } mat.setColor("Color", obstacleColors.get(FastMath.nextRandomInt(0, obstacleColors.size() - 1))); cube.setMaterial(mat); rootNode.attachChild(cube); cubeField.add(cube); }
if (!(instance instanceof InstancedGeometry)) { Geometry geom = (Geometry) instance; geom.setMaterial(materials[FastMath.nextRandomInt(0, materials.length - 1)]); if (FastMath.nextRandomInt(0, 1) == 1) mesh = mesh2; else mesh = mesh1; geom.setMesh(mesh);
p.imageIndex = FastMath.nextRandomInt(0, imagesY - 1) * imagesX + FastMath.nextRandomInt(0, imagesX - 1);
t = obj[FastMath.nextRandomInt(0, obj.length - 1)].clone(false); t.setLocalScale(FastMath.nextRandomFloat() * 10f); t.setMaterial(mat[FastMath.nextRandomInt(0, mat.length - 1)]); rootNode.attachChild(t); t.setLocalTranslation(FastMath.nextRandomFloat() * 200f, FastMath.nextRandomFloat() * 30f + 20, 30f * (i + 2f));
public void setSelectRandomImage(boolean value) { if (value) { frameIndex = FastMath.nextRandomInt(0, frames); } }
n.attachChild(ln); ln.setLocalTranslation(p.getPosition()); int rand = FastMath.nextRandomInt(0, 3); switch (rand) { case 0:
/** * This method fills the point with coordinates of randomly selected mesh vertex. * @param store * the variable to store with coordinates of randomly selected mesh vertex */ @Override public void getRandomPoint(Vector3f store) { int meshIndex = FastMath.nextRandomInt(0, vertices.size() - 1); int vertIndex = FastMath.nextRandomInt(0, vertices.get(meshIndex).size() - 1); store.set(vertices.get(meshIndex).get(vertIndex)); }
/** * This method fills the point with coordinates of randomly selected mesh vertex. * @param store * the variable to store with coordinates of randomly selected mesh vertex */ @Override public void getRandomPoint(Vector3f store) { int meshIndex = FastMath.nextRandomInt(0, vertices.size() - 1); int vertIndex = FastMath.nextRandomInt(0, vertices.get(meshIndex).size() - 1); store.set(vertices.get(meshIndex).get(vertIndex)); }
public void random() { GameMapContainer current; List<GameMapContainer> maps = getMaps(); if (maps.isEmpty()) { current = null; } else if (maps.size() == 1) { current = maps.get(0); } else { do { current = maps.get(FastMath.nextRandomInt(0, maps.size() - 1)); } while (current.equals(map)); } map = current; }
/** * This method fills the point with coordinates of randomly selected mesh vertex. * The normal param is filled with selected vertex's normal. * @param store * the variable to store with coordinates of randomly selected mesh vertex * @param normal * filled with selected vertex's normal */ @Override public void getRandomPointAndNormal(Vector3f store, Vector3f normal) { int meshIndex = FastMath.nextRandomInt(0, vertices.size() - 1); int vertIndex = FastMath.nextRandomInt(0, vertices.get(meshIndex).size() - 1); store.set(vertices.get(meshIndex).get(vertIndex)); normal.set(normals.get(meshIndex).get(vertIndex)); }
/** * This method fills the point with coordinates of randomly selected mesh vertex. * The normal param is filled with selected vertex's normal. * @param store * the variable to store with coordinates of randomly selected mesh vertex * @param normal * filled with selected vertex's normal */ @Override public void getRandomPointAndNormal(Vector3f store, Vector3f normal) { int meshIndex = FastMath.nextRandomInt(0, vertices.size() - 1); int vertIndex = FastMath.nextRandomInt(0, vertices.get(meshIndex).size() - 1); store.set(vertices.get(meshIndex).get(vertIndex)); normal.set(normals.get(meshIndex).get(vertIndex)); }
public int getOrientation() { if (object.getMaxAngle() == 0) { return 0; } // Take a random angle return FastMath.nextRandomInt(0, object.getMaxAngle()); }
protected ArtResource getResource() { if (isAdditionalResources()) { int resourceIndex = FastMath.nextRandomInt(0, getResourceCount() - 1); if (resourceIndex == object.getAdditionalResources().size()) { return object.getMeshResource(); } return object.getAdditionalResources().get(resourceIndex); } return object.getMeshResource(); }
@Override public void visit(Spatial spatial) { AnimControl animControl = spatial.getControl(AnimControl.class); if (animControl != null) { AnimChannel channel = animControl.createChannel(); channel.setAnim("anim"); channel.setLoopMode(LoopMode.Loop); if (randomizeAnimation) { channel.setSpeed(FastMath.nextRandomInt(6, 10) / 10f); channel.setTime(FastMath.nextRandomFloat() * channel.getAnimMaxTime()); } // Don't batch animated objects, seems not to work object.setBatchHint(Spatial.BatchHint.Never); } } });
private void initiazize() { hp = hpCurrent = FastMath.nextRandomInt(effect.getMaxHp(), effect.getMaxHp()); velocity = calculateVelocity(effect); //height = FastMath.nextRandomInt(effect.getLowerHeightLimit(), effect.getUpperHeightLimit()); if (effect.getFlags().contains(EffectElement.EffectElementFlag.SHRINK)) { scale = new FloatLimit(effect.getMaxScale()); scaleRatio = (effect.getMaxScale() - effect.getMinScale()) / hp; } else if (effect.getFlags().contains(EffectElement.EffectElementFlag.EXPAND)) { scale = new FloatLimit(effect.getMinScale()); scaleRatio = (effect.getMaxScale() - effect.getMinScale()) / hp; } else { scale = new FloatLimit(effect.getMinScale() + FastMath.nextRandomFloat() * (effect.getMaxScale() - effect.getMinScale())); scaleRatio = 0; } }