private void showMasterDetailInWindow(final Stage stage, final Database database, final MasterDetailViewFeatures features) throws JAXBException, IOException { final Parent viewRoot = ViewFactory.createMasterDetailView(database, features); final Rectangle clip = new Rectangle(); clip.setArcHeight(18); clip.setArcWidth(18); clip.widthProperty().bind(stage.widthProperty()); clip.heightProperty().bind(stage.heightProperty()); //TODO: Only clipping or PerspectiveCamera is working... :( features.customWindowClipProperty().addListener((obs, oldVal, newVal) -> { if (newVal) { viewRoot.setClip(clip); } else { viewRoot.setClip(null); } }); final Scene scene = new Scene(viewRoot); features.useCssProperty().addListener((obs, oldVal, newVal) -> { updateStylesheets(scene, newVal); }); updateStylesheets(scene, features.isUseCss()); scene.setFill(Color.TRANSPARENT); scene.setCamera(new PerspectiveCamera()); if (features.isCustomWindowUI()) { stage.initStyle(StageStyle.TRANSPARENT); } stage.setTitle("Movie Database"); stage.setScene(scene); stage.setWidth(1100); stage.setHeight(720); stage.centerOnScreen(); stage.show(); final FeaturesDialog featuresDialog = new FeaturesDialog(stage); featuresDialog.addFeature(new Feature("Layout & Style", "demo2-css", features.useCssProperty())); featuresDialog.addFeature(new Feature("Image Background", "demo2-image-background",features.movieBackgroundProperty())); featuresDialog.addFeature(new Feature("List Animation", "demo2-list-animation",features.listAnimationProperty())); featuresDialog.addFeature(new Feature("List Shadow", "demo2-list-shadow",features.listShadowProperty())); // featuresDialog.addFeature(new Feature("List Cache", "demo2-list-cache",features.listCacheProperty())); featuresDialog.addFeature(new Feature("Poster Transform", "demo2-poster-transform",features.posterTransformProperty())); featuresDialog.addFeature(new Feature("Custom Window UI", "demo2-custom-window-ui",features.customWindowUIProperty())); featuresDialog.addFeature(new Feature("Custom Window Clip", "demo2-custom-window-clip", features.customWindowClipProperty())); featuresDialog.show(); }
@Override protected void interpolate(double d) { if (first) { // setup flipNode.setRotationAxis(Rotate.Y_AXIS); oldCamera = flipNode.getScene().getCamera(); flipNode.getScene().setCamera(new PerspectiveCamera()); first = false; } super.interpolate(d); if (d == 1) { // restore first = true; flipNode.setRotate(0); flipNode.setRotationAxis(Rotate.Z_AXIS); flipNode.getScene().setCamera(oldCamera); } }
@Override public void start(Stage stage) { BorderPane pane = new BorderPane(flipPanel); pane.setPrefSize(400, 250); pane.setPadding(new Insets(50, 50, 50, 50)); pane.setBackground(new Background(new BackgroundFill(Color.rgb(68, 68, 68), CornerRadii.EMPTY, Insets.EMPTY))); PerspectiveCamera camera = new PerspectiveCamera(false); camera.setFieldOfView(20); Scene scene = new Scene(pane); scene.setCamera(camera); scene.getStylesheets().add(Demo.class.getResource("styles.css").toExternalForm()); stage.setTitle("FlipPanel Demo"); stage.setScene(scene); stage.show(); }
private void loadCamera(Scene scene) { //initialize camera camera = new PerspectiveCamera(true); camera.setVerticalFieldOfView(RUN_JASON); //setup camera transform for rotational support cameraTransform.setTranslate(0, 0, 0); cameraTransform.getChildren().add(camera); camera.setNearClip(0.1); camera.setFarClip(100000.0); camera.setTranslateZ(-5000); cameraTransform.ry.setAngle(0.0); cameraTransform.rx.setAngle(-45.0); //add a Point Light for better viewing of the grid coordinate system PointLight light = new PointLight(Color.GAINSBORO); cameraTransform.getChildren().add(light); cameraTransform.getChildren().add(new AmbientLight(Color.WHITE)); light.setTranslateX(camera.getTranslateX()); light.setTranslateY(camera.getTranslateY()); light.setTranslateZ(camera.getTranslateZ()); //attach camera to scene scene.setCamera(camera); }
@Override protected void initScene() { DefaultMeshBuilder dmb = new DefaultMeshBuilder() { @Override protected double function(double fx, double fy) { return 1; } }; MeshView meshView = new MeshView(dmb.getTriangleMesh()); meshView.setScaleX(100); meshView.setScaleY(100); meshView.setScaleZ(100); Sphere s = new Sphere(50); s.setTranslateX(WIDTH / 2); s.setTranslateY(HEIGHT / 2); Group root = new Group(s, meshView); scene = createScene(root, WIDTH, HEIGHT); scene.setCamera(new PerspectiveCamera()); }
public LocalTo_TransformsScene() { super(hBox, 150, 150, true); setCamera(new PerspectiveCamera()); StackPane firstPane = new StackPane(); StackPane secondPane = new StackPane(); StackPane thirdPane = new StackPane(); StackPane nestedPane = new StackPane(); StackPane doubleNestedPane = new StackPane(); StackPane forthPane = new StackPane(); Circle circle1 = CircleBuilder.create().radius(20).id("circle_one").build(); Circle circle2 = CircleBuilder.create().radius(20).id("circle_two").build(); Circle circle3 = CircleBuilder.create().radius(20).id("circle_three").build(); Circle circle4 = CircleBuilder.create().radius(20).id("circle_four").translateZ(-50).build(); forthPane.getChildren().add(circle4); doubleNestedPane.getChildren().add(circle3); nestedPane.getChildren().add(doubleNestedPane); thirdPane.getChildren().add(nestedPane); secondPane.getChildren().add(circle2); firstPane.getChildren().add(circle1); hBox.getChildren().addAll(firstPane, secondPane, thirdPane, forthPane); }
public Scene3D(Parent parent, double width, double height) { // super(new Group(parent), width, height, true); // see http://javafx-jira.kenai.com/browse/RT-22696 super(new Group(parent), width, height); if (true == Platform.isSupported(ConditionalFeature.SCENE3D)) { setCamera(new PerspectiveCamera()); Translate centerTranslate = new Translate(); centerTranslate.xProperty().bind(widthProperty().divide(2)); centerTranslate.yProperty().bind(heightProperty().divide(2)); getRoot().getTransforms().addAll(centerTranslate, translateZ, rotateX, rotateY, translateY); // getRoot().setDepthTest(DepthTest.ENABLE);// see http://javafx-jira.kenai.com/browse/RT-22696 } }
@Override public void start(Stage stage) { Group group = buildScene(); Scene scene = new Scene( new StackPane(group), VIEWPORT_SIZE, VIEWPORT_SIZE, true, SceneAntialiasing.BALANCED ); scene.setFill(Color.rgb(10, 10, 40)); scene.setCamera(new PerspectiveCamera()); stage.setScene(scene); stage.show(); stage.setFullScreen(true); rotateAroundYAxis(group).play(); }
/** * Check that the camera is added to the parent INode's JavaFX node * correctly. */ @Test public void checkCamera() { // Create a camera, an attachment containing that camera, and the node Camera camera = new PerspectiveCamera(); FXCameraAttachment attachment = new FXCameraAttachment(camera); GNode node = new GNode(); Group fxNode = new Group(); node.setProperty(INode.RENDERER_NODE_PROP, fxNode); // Check that the attachment has the camera assertTrue(attachment.getFxCamera() == camera); // Attach to the node and check that the camera has been added to the // JavaFX node attachment.attach(node); assertTrue(Util.getFxGroup(node).getChildren().contains(camera)); // Detach from the node and check that the camera has been removed from // the JavaFX node. attachment.detach(node); assertFalse(Util.getFxGroup(node).getChildren().contains(camera)); }
/** * <p> * Creates the current geometry editor camera. * </p> * * @param parent * the parent to create the camera on * */ protected void createDefaultCamera(Group parent) { PerspectiveCamera perspCamera = new PerspectiveCamera(true); perspCamera.setNearClip(0.1); perspCamera.setFarClip(4000.0); perspCamera.setFieldOfView(35); perspCamera.setTranslateX(0); perspCamera.setTranslateY(0); parent.getChildren().add(perspCamera); // Hacked in camera (for now) FXCameraAttachment cameraAttachment = new FXCameraAttachment( perspCamera); setCamera(cameraAttachment); }
public Skybox(Image topImg, Image bottomImg, Image leftImg, Image rightImg, Image frontImg, Image backImg, double size, PerspectiveCamera camera) { super(); this.imageType = SkyboxImageType.MULTIPLE; this.topImg = topImg; this.bottomImg = bottomImg; this.leftImg = leftImg; this.rightImg = rightImg; this.frontImg = frontImg; this.backImg = backImg; this.size.set(size); this.camera = camera; loadImageViews(); getTransforms().add(affine); getChildren().addAll(views); startTimer(); }
/** * Calculates the angle needed for the given {@link Node} to be edge-on with * the user. * * @param pNode the {@link Node}. * @param pOrientation the {@link Orientation}. * @return the angle needed for the {@link Node} the be viewed edge-on. */ public static double calculateEdgeAngle(Node pNode, Orientation pOrientation) { Scene scene = pNode.getScene(); Camera camera = scene.getCamera(); if (camera instanceof PerspectiveCamera) { PerspectiveCamera perspectiveCamera = (PerspectiveCamera)camera; double distanceFromCenter = getDistanceFromCenter(scene, pNode, pOrientation); double rotationFromCenter = getAngleFromCenter(scene, perspectiveCamera, distanceFromCenter); return 90 - rotationFromCenter; } return 90; }
public Scene initScene(City city, PerspectiveCamera camera, String cityName) { Group root = new Group(); buildCamera(root, camera); root.getTransforms().addAll(rxBox, ryBox, rzBox); subScene = new SubScene(root, SCENE_WIDTH, SCENE_HEIGHT, true, SceneAntialiasing.BALANCED); subScene.setCamera(camera); root.getChildren().add(city); // 2D BorderPane pane = new BorderPane(); Pane toolBar = null; try { toolBar = new CityToolBarService().load(cityName); } catch (IOException e) { e.printStackTrace(); } pane.setBottom(subScene); pane.setTop(toolBar); Scene scene = new Scene(pane, SCENE_WIDTH, SCENE_HEIGHT); subScene.heightProperty().bind(scene.heightProperty()); subScene.widthProperty().bind(scene.widthProperty()); return scene; }
public SimpleGraphView3D(boolean perspective) { super(new Group(), 800, 800, true, SceneAntialiasing.BALANCED); // root is dummy node3D = new Node3D(); node3D.setTranslateX(400); node3D.setTranslateY(400); setRoot(node3D); setFill(Color.gray(0.95)); if (perspective) { setCamera(new PerspectiveCamera()); } MouseHandler3D handler = new MouseHandler3D(node3D); setOnMousePressed(handler); setOnMouseDragged(handler); setOnMouseReleased(handler); setOnScroll(new ZoomHandler3D(node3D)); }
@Override public void start(Stage primaryStage) throws Exception { Parent main = loadFromFXML(); Scene scene = new Scene(main, 1024, 768,true); scene.getStylesheets().add(JFXScad.class.getResource("java-keywords.css"). toExternalForm()); PerspectiveCamera camera = new PerspectiveCamera(); scene.setCamera(camera); primaryStage.setTitle("JavaFXScad"); primaryStage.setScene(scene); primaryStage.setMinWidth(1024); primaryStage.setMinHeight(768); primaryStage.show(); }
@Override public void start(Stage stage) { notifier = NotifierBuilder.create().build(); Pane pane = new Pane(); pane.getChildren().addAll(contentPane, prefPane, shadowOverlay); Scene scene = new Scene(pane, SIZE.getWidth(), SIZE.getHeight()); scene.setCamera(new PerspectiveCamera()); scene.getStylesheets().add(Main.class.getResource("styles.css").toExternalForm()); registerListeners(scene); stage.setScene(scene); stage.setResizable(false); stage.show(); timer.start(); }
private void init(Stage primaryStage) { Group root = new Group(); root.setDepthTest(DepthTest.ENABLE); primaryStage.setResizable(false); primaryStage.setScene(new Scene(root, 400, 150, true)); primaryStage.getScene().setCamera(new PerspectiveCamera()); root.getTransforms().addAll( new Translate(400 / 2, 150 / 2), new Rotate(180, Rotate.X_AXIS) ); root.getChildren().add(create3dContent()); }
private void init(Stage primaryStage) { Group root = new Group(); root.setDepthTest(DepthTest.ENABLE); primaryStage.setResizable(false); primaryStage.setScene(new Scene(root, 500, 500, true)); primaryStage.getScene().setCamera(new PerspectiveCamera()); root.getTransforms().addAll( new Translate(500 / 2, 500 / 2), new Rotate(180, Rotate.X_AXIS) ); root.getChildren().add(create3dContent()); }
private void init(Stage primaryStage) { Group root = new Group(); root.setDepthTest(DepthTest.ENABLE); primaryStage.setResizable(false); primaryStage.setScene(new Scene(root, 400, 500, true)); primaryStage.getScene().setCamera(new PerspectiveCamera()); root.getTransforms().addAll( new Translate(400 / 2, 500 / 2 + 100), new Rotate(180, Rotate.X_AXIS) ); root.getChildren().add(create3dContent()); }
@Override protected void starting() { super.starting(); node.setRotationAxis(Rotate.Y_AXIS); oldCamera = node.getScene().getCamera(); node.getScene().setCamera(new PerspectiveCamera()); }
@Override public void start(final Stage s) throws Exception { s.setTitle("Curbstone 3D"); final Curbstone c = new Curbstone(50, Color.web("#DC143C"), 1); c.setTranslateX(0); c.rx.setAngle(25); c.ry.setAngle(45); final Timeline animation = new Timeline(); animation.getKeyFrames().addAll(new KeyFrame(Duration.ZERO, new KeyValue(c.ry.angleProperty(), 0d)), new KeyFrame(Duration.valueOf("20000ms"), new KeyValue(c.ry.angleProperty(), 360d))); animation.setCycleCount(Animation.INDEFINITE); // create root group final Parent root = c; // translate and rotate group so that origin is center and +Y is up root.setTranslateX(200); root.setTranslateY(75); final Line line = new Line(200, 200, 200, 200); final Rotate rotation = new Rotate(1, Rotate.Y_AXIS); rotation.pivotXProperty().bind(line.startXProperty()); rotation.pivotYProperty().bind(line.startYProperty()); root.getTransforms().add(rotation); // create scene final Scene scene = new Scene(root, 400, 150); scene.setCamera(new PerspectiveCamera()); s.setScene(scene); s.show(); // start spining animation animation.play(); }
@Override protected Camera addCamera(Scene scene) { camera = cam = new PerspectiveCamera(true); scene.setCamera(camera); camera.setFarClip(10000); return camera; }
@Override public void cameraConstruct() { Group parent = (Group) camera.getParent(); parent.getChildren().remove(camera); camera = cam = new PerspectiveCamera(); scene.setCamera(camera); parent.getChildren().add(camera); }
@Override protected SubScene getTopLeftScene() { rootTLMV = buildGroupMover(); SubScene ss = new SubScene(rootTLMV.getGroup(), SS_WIDTH, SS_HEIGHT, true, SceneAntialiasing.DISABLED); ss.setCamera(new PerspectiveCamera()); return ss; }
@Override protected SubScene getTopRightScene() { rootTRMV = buildGroupMover(); rootTRMV.setRotateY(60); SubScene ss = new SubScene(rootTRMV.getGroup(), SS_WIDTH, SS_HEIGHT, true, SceneAntialiasing.DISABLED); ss.setCamera(new PerspectiveCamera()); return ss; }
@Override protected SubScene getDownLeftScene() { rootDLMV = buildGroupMover(); rootDLMV.setRotateY(-60); SubScene ss = new SubScene(rootDLMV.getGroup(), SS_WIDTH, SS_HEIGHT, true, SceneAntialiasing.DISABLED); ss.setCamera(new PerspectiveCamera()); return ss; }
@Override protected Camera addCamera(SubScene scene) { PerspectiveCamera pc = new PerspectiveCamera(true); scene.setCamera(pc); pc.setFarClip(10000); return pc; }
@Override public void setFieldOfView(double d) { for (int i = 0; i < scenesCount; i++) { ((PerspectiveCamera) cameras[i]).setFieldOfView(d); } checkFieldOfView(); }
@Override public void setVerticalFieldOfView(boolean bln) { for (int i = 0; i < scenesCount; i++) { ((PerspectiveCamera) cameras[i]).setVerticalFieldOfView(bln); } checkVerticalFieldOfView(); }
private void checkFieldOfView() { Assert.assertEquals(FIELD_OF_VIEW_DIFFERS, ((PerspectiveCamera) cameras[0]).getFieldOfView(), ((PerspectiveCamera) cameras[1]).getFieldOfView(), delta); Assert.assertEquals(FIELD_OF_VIEW_DIFFERS, ((PerspectiveCamera) cameras[2]).getFieldOfView(), ((PerspectiveCamera) cameras[1]).getFieldOfView(), delta); Assert.assertEquals(FIELD_OF_VIEW_DIFFERS, ((PerspectiveCamera) cameras[0]).getFieldOfView(), ((PerspectiveCamera) cameras[2]).getFieldOfView(), delta); }
private void checkVerticalFieldOfView() { Assert.assertEquals(VERTICAL_FIELD_OF_VIEW_DIFFERS, ((PerspectiveCamera) cameras[0]).isVerticalFieldOfView(), ((PerspectiveCamera) cameras[1]).isVerticalFieldOfView()); Assert.assertEquals(VERTICAL_FIELD_OF_VIEW_DIFFERS, ((PerspectiveCamera) cameras[2]).isVerticalFieldOfView(), ((PerspectiveCamera) cameras[1]).isVerticalFieldOfView()); Assert.assertEquals(VERTICAL_FIELD_OF_VIEW_DIFFERS, ((PerspectiveCamera) cameras[0]).isVerticalFieldOfView(), ((PerspectiveCamera) cameras[2]).isVerticalFieldOfView()); }
@Override public void cameraConstruct() { for (int i = 0; i < scenesCount; i++) { Group parent = (Group) cameras[i].getParent(); parent.getChildren().remove(cameras[i]); cameras[i] = new PerspectiveCamera(); subScenes[i].setCamera(cameras[i]); parent.getChildren().add(cameras[i]); } }