javafx.scene.SubScene Java Examples
The following examples show how to use
javafx.scene.SubScene.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpinningGlobe.java From mars-sim with GNU General Public License v3.0 | 7 votes |
public Parent createDraggingGlobe() { boolean support = Platform.isSupported(ConditionalFeature.SCENE3D); if (support) logger.config("JavaFX 3D features supported"); else logger.config("JavaFX 3D features NOT supported"); globe = new Globe(); rotateGlobe(); // Use a SubScene subScene = new SubScene(globe.getRoot(), WIDTH, HEIGHT);//, true, SceneAntialiasing.BALANCED); subScene.setId("sub"); subScene.setCamera(globe.getCamera());//subScene)); //return new Group(subScene); return new HBox(subScene); }
Example #2
Source File: ChildrenGetter.java From scenic-view with GNU General Public License v3.0 | 5 votes |
public static ObservableList<Node> getChildren(Node node) { if (node == null) return FXCollections.emptyObservableList(); if (node instanceof Parent) { return ((Parent)node).getChildrenUnmodifiable(); } else if (node instanceof SubScene) { return ((SubScene)node).getRoot().getChildrenUnmodifiable(); } return FXCollections.emptyObservableList(); }
Example #3
Source File: ContentModel.java From RubikFX with GNU General Public License v3.0 | 5 votes |
private void buildSubScene() { root3D.getChildren().add(autoScalingGroup); subScene = new SubScene(root3D,paneW,paneH,true,javafx.scene.SceneAntialiasing.BALANCED); subScene.setCamera(camera); subScene.setFill(Color.CADETBLUE); setListeners(true); }
Example #4
Source File: Viewer3d.java From phoebus with Eclipse Public License 1.0 | 5 votes |
/** @param disabled Disable mouse interaction? * @throws Exception on error */ public Viewer3d (final boolean disabled) throws Exception { axes = buildAxes(); view.getChildren().add(axes); root = new Group(view); root.setDepthTest(DepthTest.ENABLE); scene = new SubScene(root, 1024, 768, true, SceneAntialiasing.BALANCED); scene.setManaged(false); scene.setFill(Color.GRAY); scene.heightProperty().bind(heightProperty()); scene.widthProperty().bind(widthProperty()); buildCamera(); scene.setCamera(camera); // Legend, placed on top of 3D scene final HBox legend = new HBox(10, createAxisLabel("X Axis", Color.RED), createAxisLabel("Y Axis", Color.GREEN), createAxisLabel("Z Axis", Color.BLUE)); legend.setPadding(new Insets(10)); getChildren().setAll(scene, legend); if (! disabled) handleMouse(this); }
Example #5
Source File: CameraView.java From FXyzLib with GNU General Public License v3.0 | 5 votes |
public CameraView(SubScene scene) { // Make sure "world" is a group assert scene.getRoot().getClass().equals(Group.class); worldToView = (Group)scene.getRoot(); camera = new PerspectiveCamera(true); // cameraTransform.setTranslate(0, 0, -500); cameraTransform.getChildren().add(camera); camera.setNearClip(0.1); camera.setFarClip(15000.0); camera.setTranslateZ(-1500); // cameraTransform.ry.setAngle(-45.0); // cameraTransform.rx.setAngle(-10.0); params.setCamera(camera); params.setDepthBuffer(true); params.setFill(Color.rgb(0, 0, 0, 0.5)); viewTimer = new AnimationTimer() { @Override public void handle(long now) { redraw(); } }; }
Example #6
Source File: ContentModel.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void buildSubScene() { root3D.getChildren().add(autoScalingGroup); subScene = new SubScene(root3D, paneW, paneH, true, SceneAntialiasing.BALANCED); subScene.setCamera(camera); subScene.setFill(Color.CADETBLUE); setListeners(true); }
Example #7
Source File: Viewer3DFX.java From paintera with GNU General Public License v2.0 | 4 votes |
public Viewer3DFX(final double width, final double height) { super(); this.root = new Group(); this.sceneGroup = new Group(); this.meshesGroup = new Group(); sceneGroup.getChildren().add(meshesGroup); this.setWidth(width); this.setHeight(height); this.scene = new SubScene(root, width, height, true, SceneAntialiasing.BALANCED); this.scene.fillProperty().bind(backgroundFill); this.camera = new PerspectiveCamera(true); this.camera.setNearClip(0.01); this.camera.setFarClip(10.0); this.camera.setTranslateY(0); this.camera.setTranslateX(0); this.camera.setTranslateZ(0); this.camera.setFieldOfView(90); this.scene.setCamera(this.camera); this.cameraGroup = new Group(); this.getChildren().add(this.scene); this.root.getChildren().addAll(cameraGroup, sceneGroup); this.scene.widthProperty().bind(widthProperty()); this.scene.heightProperty().bind(heightProperty()); lightSpot.setTranslateX(-10); lightSpot.setTranslateY(-10); lightSpot.setTranslateZ(-10); lightFill.setTranslateX(10); this.cameraGroup.getChildren().addAll(camera, lightAmbient, lightSpot, lightFill); this.cameraGroup.getTransforms().add(cameraTransform); this.handler = new Scene3DHandler(this); this.root.visibleProperty().bind(this.meshesEnabled); final AffineTransform3D cameraAffineTransform = Transforms.fromTransformFX(cameraTransform); this.handler.addAffineListener(sceneTransform -> { final AffineTransform3D sceneToWorldTransform = Transforms.fromTransformFX(sceneTransform).inverse(); eyeToWorldTransformProperty.set(sceneToWorldTransform.concatenate(cameraAffineTransform)); }); final InvalidationListener sizeChangedListener = obs -> viewFrustumProperty.set( new ViewFrustum(camera, new double[] {getWidth(), getHeight()}) ); widthProperty().addListener(sizeChangedListener); heightProperty().addListener(sizeChangedListener); // set initial value sizeChangedListener.invalidated(null); }
Example #8
Source File: Cutaway.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
public Cutaway(SubScene scene, double width, double height) { // Make sure "world" is a group assert scene.getRoot().getClass().equals(Group.class); setFillWidth(true); setPrefSize(width, height+controlSize); setMaxSize(width, height+controlSize); this.setBorder(new Border( new BorderStroke(Color.DARKKHAKI, BorderStrokeStyle.SOLID, new CornerRadii(25), new BorderWidths(5) ))); Rectangle closeSquare = new Rectangle(controlSize, controlSize, Color.LIGHTCORAL); closeSquare.setOnMouseClicked((MouseEvent me) -> { this.fireEvent(new CloseCutawayEvent(this)); }); Circle dragCircle = new Circle(controlSize/2, Color.STEELBLUE); HBox top = new HBox(20,closeSquare,dragCircle); dragCircle.setVisible(false); StackPane.setAlignment(closeSquare, Pos.TOP_RIGHT); StackPane.setMargin(closeSquare, new Insets(50)); top.setBackground(new Background( new BackgroundFill(Color.KHAKI, new CornerRadii(20,20,0,0,false), Insets.EMPTY))); top.setAlignment(Pos.TOP_RIGHT); top.setOnMousePressed((MouseEvent me) -> { cutawayPosX = me.getSceneX(); cutawayPosY = me.getSceneY(); cutawayOldX = me.getSceneX(); cutawayOldY = me.getSceneY(); }); top.setOnMouseDragged((MouseEvent me) -> { cutawayOldX = cutawayPosX; cutawayOldY = cutawayPosY; cutawayPosX = me.getSceneX(); cutawayPosY = me.getSceneY(); cutawayDeltaX = (cutawayPosX - cutawayOldX); cutawayDeltaY = (cutawayPosY - cutawayOldY); setTranslateX(getTranslateX() + cutawayDeltaX); setTranslateY(getTranslateY() + cutawayDeltaY); }); getChildren().addAll(top,imageView); worldToView = (Group)scene.getRoot(); camera = new PerspectiveCamera(true); cameraTransform.getChildren().add(camera); camera.setNearClip(0.1); camera.setFarClip(15000.0); camera.setTranslateZ(-1500); params.setCamera(camera); params.setDepthBuffer(true); params.setFill(Color.rgb(0, 0, 0, 0.5)); viewTimer = new AnimationTimer() { @Override public void handle(long now) { redraw(); } }; setOnMouseEntered(e->{ requestFocus(); }); }
Example #9
Source File: BillBoardBehaviorTest.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
private void createSubscene(){ subScene = new SubScene(root, 800, 600, true, SceneAntialiasing.BALANCED); camera = new PerspectiveCamera(true); cameraTransform.setTranslate(0, 0, 0); cameraTransform.getChildren().addAll(camera); camera.setNearClip(0.1); camera.setFarClip(100000.0); camera.setFieldOfView(35); camera.setTranslateZ(-cameraDistance); cameraTransform.ry.setAngle(-45.0); cameraTransform.rx.setAngle(-10.0); //add a Point Light for better viewing of the grid coordinate system PointLight light = new PointLight(Color.WHITE); cameraTransform.getChildren().add(light); light.setTranslateX(camera.getTranslateX()); light.setTranslateY(camera.getTranslateY()); light.setTranslateZ(camera.getTranslateZ()); root.getChildren().add(cameraTransform); subScene.setCamera(camera); initFirstPersonControls(subScene); skyBox = new Skybox(new Image("http://www.zfight.com/misc/images/textures/envmaps/violentdays_large.jpg"), 100000, camera); //Make a bunch of semi random Torusesessses(toroids?) and stuff : from torustest Group torusGroup = new Group(); for (int i = 0; i < 10; 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()); boolean ambientRandom = r.nextBoolean(); boolean fillRandom = r.nextBoolean(); if(i == 0){ torusGroup.getChildren().add(bill); } TorusMesh torus = new TorusMesh(randomTubeDivisions, randomRadiusDivisions, randomRadius, randomTubeRadius); 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().addAll(skyBox, torusGroup); rootPane.getChildren().add(subScene); //Enable subScene resizing subScene.widthProperty().bind(rootPane.widthProperty()); subScene.heightProperty().bind(rootPane.heightProperty()); subScene.setFocusTraversable(true); }
Example #10
Source File: CameraController.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
protected SubScene getSubScene() { return subScene; }
Example #11
Source File: CameraController.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
public void setSubScene(SubScene subScene) { this.subScene = subScene; setEventHandlers(subScene); }
Example #12
Source File: CameraController.java From FXyzLib with GNU General Public License v3.0 | 4 votes |
private void setEventHandlers(SubScene scene) { scene.addEventHandler(KeyEvent.ANY, k -> handleKeyEvent(k)); scene.addEventHandler(MouseEvent.ANY, m -> handleMouseEvent(m)); scene.addEventHandler(ScrollEvent.ANY, s -> handleScrollEvent(s)); }
Example #13
Source File: Tutorial.java From FXTutorials with MIT License | 4 votes |
private Parent createContent() { Cube c = new Cube(1, Color.GREEN); c.setTranslateX(-1); c.setRotationAxis(Rotate.Y_AXIS); c.setRotate(45); Cube c2 = new Cube(1, Color.BLUE); c2.setTranslateX(1); c2.setRotationAxis(Rotate.Y_AXIS); c2.setRotate(45); Cube c3 = new Cube(1, Color.RED); c3.setRotationAxis(Rotate.Y_AXIS); c3.setRotate(45); camera = new PerspectiveCamera(true); translate = new Translate(0, 0, -10); rotate = new Rotate(0, new Point3D(0, 1, 0)); camera.getTransforms().addAll(translate, rotate); PointLight light = new PointLight(Color.WHITE); light.setTranslateX(3); light.setTranslateZ(-5); TranslateTransition tt = new TranslateTransition(Duration.seconds(2), light); tt.setFromX(-3); tt.setToX(3); tt.setAutoReverse(true); tt.setCycleCount(Animation.INDEFINITE); AmbientLight globalLight = new AmbientLight(Color.WHITE.deriveColor(0, 1, 0.2, 1)); worldRoot.getChildren().addAll(c, c2, c3, globalLight, light); SubScene subScene = new SubScene(worldRoot, 800, 600, true, SceneAntialiasing.BALANCED); subScene.setCamera(camera); tt.play(); return new Group(new Rectangle(800, 600), subScene); }
Example #14
Source File: Simple3DSphereApp.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public Parent createContent() throws Exception { Image dImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-d.jpg").toExternalForm()); Image nImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-n.jpg").toExternalForm()); Image sImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-s.jpg").toExternalForm()); Image siImage = new Image(Simple3DSphereApp.class.getResource("/maps/earth-l.jpg").toExternalForm()); material = new PhongMaterial(); material.setDiffuseColor(Color.WHITE); material.diffuseMapProperty().bind( Bindings.when(diffuseMap).then(dImage).otherwise((Image) null)); material.setSpecularColor(Color.TRANSPARENT); material.specularMapProperty().bind( Bindings.when(specularMap).then(sImage).otherwise((Image) null)); material.bumpMapProperty().bind( Bindings.when(bumpMap).then(nImage).otherwise((Image) null)); material.selfIlluminationMapProperty().bind( Bindings.when(selfIlluminationMap).then(siImage).otherwise((Image) null)); earth = new Sphere(5); earth.setMaterial(material); earth.setRotationAxis(Rotate.Y_AXIS); // Create and position camera PerspectiveCamera camera = new PerspectiveCamera(true); camera.getTransforms().addAll( new Rotate(-20, Rotate.Y_AXIS), new Rotate(-20, Rotate.X_AXIS), new Translate(0, 0, -20)); sun = new PointLight(Color.rgb(255, 243, 234)); sun.translateXProperty().bind(sunDistance.multiply(-0.82)); sun.translateYProperty().bind(sunDistance.multiply(-0.41)); sun.translateZProperty().bind(sunDistance.multiply(-0.41)); sun.lightOnProperty().bind(sunLight); AmbientLight ambient = new AmbientLight(Color.rgb(1, 1, 1)); // Build the Scene Graph Group root = new Group(); root.getChildren().add(camera); root.getChildren().add(earth); root.getChildren().add(sun); root.getChildren().add(ambient); RotateTransition rt = new RotateTransition(Duration.seconds(24), earth); rt.setByAngle(360); rt.setInterpolator(Interpolator.LINEAR); rt.setCycleCount(Animation.INDEFINITE); rt.play(); // Use a SubScene SubScene subScene = new SubScene(root, 400, 300, true, SceneAntialiasing.BALANCED); subScene.setFill(Color.TRANSPARENT); subScene.setCamera(camera); return new Group(subScene); }
Example #15
Source File: Qubit3D.java From strangefx with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void createQubit() { PerspectiveCamera camera = new PerspectiveCamera(true); camera.setNearClip(0.1); camera.setFarClip(10000.0); camera.getTransforms().addAll(rotateX, rotateY, new Translate(0, 0, -200)); FrustumMesh plane = new FrustumMesh(50, 50, 1, 1, new Point3D(0, -0.5f, 0), new Point3D(0, 0.5f, 0)); plane.setMaterial(new PhongMaterial(Color.web("#ccdd3320"))); SegmentedSphereMesh innerSphere = new SegmentedSphereMesh(40, 0, 0, 50, new Point3D(0, 0, 0)); innerSphere.setMaterial(new PhongMaterial(Color.web("#ff800080"))); SegmentedSphereMesh frameSphere = new SegmentedSphereMesh(20, 0, 0, 50, new Point3D(0, 0, 0)); frameSphere.setMaterial(new PhongMaterial(Color.BLACK)); frameSphere.setDrawMode(DrawMode.LINE); FrustumMesh rod = new FrustumMesh(2, 2, 1, 1, new Point3D(0, 0, 0), new Point3D(50, 0, 0)); rod.setMaterial(new PhongMaterial(Color.web("#0080ff"))); SegmentedSphereMesh smallSphere = new SegmentedSphereMesh(20, 0, 0, 4, new Point3D(50, 0, 0)); smallSphere.setMaterial(new PhongMaterial(Color.web("#0080ff"))); rodSphere = new Group(smallSphere, rod); Group group = new Group(plane, rodSphere, innerSphere, frameSphere, new AmbientLight(Color.BISQUE)); SubScene subScene = new SubScene(group, 100, 100, true, SceneAntialiasing.BALANCED); subScene.setCamera(camera); subScene.setOnMousePressed(event -> { mouseOldX = event.getSceneX(); mouseOldY = event.getSceneY(); }); subScene.setOnMouseDragged(event -> { rotateX.setAngle(rotateX.getAngle() - (event.getSceneY() - mouseOldY)); rotateY.setAngle(rotateY.getAngle() + (event.getSceneX() - mouseOldX)); mouseOldX = event.getSceneX(); mouseOldY = event.getSceneY(); }); getChildren().add(subScene); rodSphere.getTransforms().setAll(myRotate); }
Example #16
Source File: Viewer3DFX.java From paintera with GNU General Public License v2.0 | 4 votes |
public SubScene scene() { return scene; }
Example #17
Source File: ContentModel.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | votes |
public SubScene getSubScene() { return subScene; }
Example #18
Source File: Rubik.java From gluon-samples with BSD 3-Clause "New" or "Revised" License | votes |
public SubScene getSubScene(){ return content.getSubScene(); }
Example #19
Source File: Rubik.java From RubikFX with GNU General Public License v3.0 | votes |
public SubScene getSubScene(){ return content.getSubScene(); }
Example #20
Source File: ContentModel.java From RubikFX with GNU General Public License v3.0 | votes |
public SubScene getSubScene() { return subScene; }