Torus 3d in javaFX 2.x

一世执手 提交于 2019-12-25 02:16:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!