Search in sources :

Example 1 with AdvancedCamera

use of org.fxyz.cameras.AdvancedCamera in project FXyzLib by Birdasaur.

the class ConeTest method start.

@Override
public void start(Stage stage) {
    Group coneGroup = new Group();
    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 randomRadius = (float) ((r.nextFloat() * 100) + 25);
        float randomHeight = (float) ((r.nextFloat() * 300) + 75);
        int randomDivisions = (int) ((r.nextFloat() * 50) + 5);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        Cone cone = new Cone(randomDivisions, randomRadius, randomHeight, randomColor);
        cone.setEmissiveLightingColor(randomColor);
        cone.setEmissiveLightingOn(r.nextBoolean());
        cone.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);
        cone.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        coneGroup.getChildren().add(cone);
    }
    root.getChildren().add(coneGroup);
    camera = new AdvancedCamera();
    controller = new FPSController();
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setController(controller);
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    controller.setScene(scene);
    stage.setTitle("Random Cones!");
    stage.setScene(scene);
    stage.show();
    stage.setFullScreen(false);
    stage.setFullScreenExitHint("");
}
Also used : Group(javafx.scene.Group) Cone(org.fxyz.shapes.Cone) Rotate(javafx.scene.transform.Rotate) Color(javafx.scene.paint.Color) FPSController(org.fxyz.cameras.controllers.FPSController) Scene(javafx.scene.Scene) Random(java.util.Random) AdvancedCamera(org.fxyz.cameras.AdvancedCamera) Translate(javafx.scene.transform.Translate) StackPane(javafx.scene.layout.StackPane)

Example 2 with AdvancedCamera

use of org.fxyz.cameras.AdvancedCamera in project FXyzLib by Birdasaur.

the class FPSControllerTest method start.

@Override
public void start(Stage stage) {
    Group root = new Group();
    // Make a bunch of semi random Torusesessses(toroids?) and stuff : from torustest
    Group torusGroup = new Group();
    for (int i = 0; i < 30; i++) {
        Random r = new Random();
        // A lot of magic numbers in here that just artificially constrain the math
        float randomRadius = (float) ((r.nextFloat() * 300) + 50);
        float randomTubeRadius = (float) ((r.nextFloat() * 100) + 1);
        int randomTubeDivisions = (int) ((r.nextFloat() * 64) + 1);
        int randomRadiusDivisions = (int) ((r.nextFloat() * 64) + 1);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        Torus torus = new Torus(randomTubeDivisions, randomRadiusDivisions, randomRadius, randomTubeRadius, randomColor);
        torus.setEmissiveLightingColor(randomColor);
        torus.setEmissiveLightingOn(r.nextBoolean());
        double translationX = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024 * 1.95;
        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);
        torus.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        // torus.getTransforms().add(translate);
        torusGroup.getChildren().add(torus);
    }
    root.getChildren().add(torusGroup);
    Scene scene = new Scene(root, 1400, 1000, true, SceneAntialiasing.BALANCED);
    scene.setFill(Color.BLACK);
    stage.setTitle("SimpleFPSControllerTest");
    stage.setScene(scene);
    stage.show();
    // stage.setMaximized(true);
    FPSController controller = new FPSController();
    controller.setScene(scene);
    controller.setMouseLookEnabled(true);
    AdvancedCamera camera = new AdvancedCamera();
    camera.setController(controller);
    root.getChildren().add(camera);
    scene.setCamera(camera);
}
Also used : Group(javafx.scene.Group) Random(java.util.Random) Rotate(javafx.scene.transform.Rotate) AdvancedCamera(org.fxyz.cameras.AdvancedCamera) Torus(org.fxyz.shapes.Torus) Color(javafx.scene.paint.Color) FPSController(org.fxyz.cameras.controllers.FPSController) Scene(javafx.scene.Scene) Translate(javafx.scene.transform.Translate)

Example 3 with AdvancedCamera

use of org.fxyz.cameras.AdvancedCamera in project FXyzLib by Birdasaur.

the class OctahedronTest method start.

@Override
public void start(Stage stage) {
    shapeGroup.getChildren().clear();
    generateShapes();
    root.getChildren().add(shapeGroup);
    camera = new AdvancedCamera();
    controller = new FPSController();
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setController(controller);
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    controller.setScene(scene);
    scene.setOnKeyPressed(event -> {
        // What key did the user press?
        KeyCode keycode = event.getCode();
        if (keycode == KeyCode.SPACE) {
            shapeGroup.getChildren().clear();
            generateShapes();
        }
    });
    stage.setTitle("Random Octahedrons!");
    stage.setScene(scene);
    stage.show();
    stage.setFullScreen(false);
    stage.setFullScreenExitHint("");
}
Also used : AdvancedCamera(org.fxyz.cameras.AdvancedCamera) FPSController(org.fxyz.cameras.controllers.FPSController) KeyCode(javafx.scene.input.KeyCode) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Example 4 with AdvancedCamera

use of org.fxyz.cameras.AdvancedCamera in project FXyzLib by Birdasaur.

the class TrapezoidTest method start.

@Override
public void start(Stage stage) {
    shapeGroup.getChildren().clear();
    generateShapes();
    root.getChildren().add(shapeGroup);
    camera = new AdvancedCamera();
    controller = new FPSController();
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setController(controller);
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    controller.setScene(scene);
    scene.setOnKeyPressed(event -> {
        // What key did the user press?
        KeyCode keycode = event.getCode();
        if (keycode == KeyCode.SPACE) {
            shapeGroup.getChildren().clear();
            generateShapes();
        }
    });
    stage.setTitle("Random Trapezoids!");
    stage.setScene(scene);
    stage.show();
    stage.setFullScreen(false);
    stage.setFullScreenExitHint("");
}
Also used : AdvancedCamera(org.fxyz.cameras.AdvancedCamera) FPSController(org.fxyz.cameras.controllers.FPSController) KeyCode(javafx.scene.input.KeyCode) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Example 5 with AdvancedCamera

use of org.fxyz.cameras.AdvancedCamera in project FXyzLib by Birdasaur.

the class CapsuleTest method start.

@Override
public void start(Stage stage) {
    Group capsuleGroup = new Group();
    for (int i = 0; i < 50; i++) {
        Random r = new Random();
        // A lot of magic numbers in here that just artificially constrain the math
        float randomRadius = (float) ((r.nextFloat() * 100) + 25);
        float randomHeight = (float) ((r.nextFloat() * 300) + 75);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
        Capsule cap = new Capsule(randomRadius, randomHeight, randomColor);
        cap.setEmissiveLightingColor(randomColor);
        cap.setEmissiveLightingOn(r.nextBoolean());
        cap.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
        double translationX = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024 * 1.95;
        if (Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024 * 1.95;
        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);
        cap.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
        capsuleGroup.getChildren().add(cap);
    }
    root.getChildren().add(capsuleGroup);
    camera = new AdvancedCamera();
    controller = new FPSController();
    camera.setNearClip(0.1);
    camera.setFarClip(10000.0);
    camera.setFieldOfView(42);
    camera.setController(controller);
    Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
    scene.setCamera(camera);
    scene.setFill(Color.BLACK);
    controller.setScene(scene);
    stage.setTitle("Hello World!");
    stage.setScene(scene);
    stage.show();
    stage.setFullScreen(true);
    stage.setFullScreenExitHint("");
}
Also used : Group(javafx.scene.Group) Rotate(javafx.scene.transform.Rotate) Color(javafx.scene.paint.Color) FPSController(org.fxyz.cameras.controllers.FPSController) Capsule(org.fxyz.shapes.Capsule) Scene(javafx.scene.Scene) Random(java.util.Random) AdvancedCamera(org.fxyz.cameras.AdvancedCamera) Translate(javafx.scene.transform.Translate) StackPane(javafx.scene.layout.StackPane)

Aggregations

Scene (javafx.scene.Scene)6 AdvancedCamera (org.fxyz.cameras.AdvancedCamera)6 FPSController (org.fxyz.cameras.controllers.FPSController)5 StackPane (javafx.scene.layout.StackPane)4 Random (java.util.Random)3 Group (javafx.scene.Group)3 Color (javafx.scene.paint.Color)3 Rotate (javafx.scene.transform.Rotate)3 Translate (javafx.scene.transform.Translate)3 KeyCode (javafx.scene.input.KeyCode)2 Animation (javafx.animation.Animation)1 AnimationTimer (javafx.animation.AnimationTimer)1 KeyFrame (javafx.animation.KeyFrame)1 Timeline (javafx.animation.Timeline)1 Transition (javafx.animation.Transition)1 Point2D (javafx.geometry.Point2D)1 SubScene (javafx.scene.SubScene)1 KeyEvent (javafx.scene.input.KeyEvent)1 MIDDLE (javafx.scene.input.MouseButton.MIDDLE)1 PRIMARY (javafx.scene.input.MouseButton.PRIMARY)1