use of org.fxyz.shapes.Octahedron in project FXyzLib by Birdasaur.
the class OctahedronTest method generateShapes.
private void generateShapes() {
for (int i = 0; i < 100; i++) {
Random r = new Random();
// A lot of magic numbers in here that just artificially constrain the math
float randomHypotenuse = (float) ((r.nextFloat() * 300) + 25);
float randomHeight = (float) ((r.nextFloat() * 200) + 25);
Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
Octahedron octahedron = new Octahedron(randomHypotenuse, randomHeight, randomColor);
octahedron.setEmissiveLightingColor(randomColor);
octahedron.setEmissiveLightingOn(r.nextBoolean());
octahedron.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
double translationX = Math.random() * 1024;
if (Math.random() >= 0.5) {
translationX *= -1;
}
double translationY = Math.random() * 1024;
if (Math.random() >= 0.5) {
translationY *= -1;
}
double translationZ = Math.random() * 1024;
if (Math.random() >= 0.5) {
translationZ *= -1;
}
Translate translate = new Translate(translationX, translationY, translationZ);
Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);
octahedron.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
shapeGroup.getChildren().add(octahedron);
}
}
Aggregations