问题
I've Stage which is divided by Split Panel, and I wants on the right pane create a 3D torus. First: I don't know what can I create torus. Second: I don't know on what kind of obiect can I create this Torus. Pane enough?
Please for help.
回答1:
You won't be able to create an embedded 3D scene with a Torus using JavaFX 2.x without a lot of custom coding on your part. However this becomes easy if you use JavaFX 8 and the third party 3D library F(X)yz: http://birdasaur.github.io/FXyz/
F(X)yz has a Torus object:
/src/org/fxyz/shapes/Torus.java
You can see how to use it with the provided test code:
/src/org/fxyz/tests/TorusTest.java
Part of your question was how to place the 3D object into your existing JavaFX scene using the Split Pane. The Split Pane doesn't care if its content is 3D but you should use a SubScene to embed the 3D content into the 3D scene.
Example:
SubScene subScene = subScene = new SubScene(sceneRoot, sceneWidth, sceneHeight, true, SceneAntialiasing.BALANCED);
subScene.setFill(Color.STEELBLUE);
Camera 3DCamera = new PerspectiveCamera(true);
3Dcamera.setNearClip(0.1);
3Dcamera.setFarClip(100000.0);
3Dcamera.setFieldOfView(35);
3Dcamera.setTranslateZ(cameraDistance);
subScene.setCamera(3Dcamera);
//Add the subscene to the SplitPane
mySplitPane.getChildren().add(subScene);
Good luck.
回答2:
Here you can read how to create torus http://blogoben.wordpress.com/2011/10/26/webgl-basics-7-colored-torus/
来源:https://stackoverflow.com/questions/13540509/torus-3d-in-javafx-2-x