是否可以在JavaFX中創建類似於Google地圖中的photoshpere的光球?如果是,如何?創建類似於Google地圖Photo-Sphere(JavaFX 3D)的Photo-Sphere
2
A
回答
5
答案是肯定的,你可以在JavaFX中創建一個光球。至於如何,基於3D API的球體有一個簡單的解決方案,但是我們可以通過自定義網格實現改進的解決方案。
讓我們從使用常規球體開始。我們只需要一個360º的圖像,像這樣one。
正如我們希望從球體內部看到的,我們必須水平翻轉圖像,並將其添加到球體材質的擴散圖中。
然後我們只需要在球體的中心設置一個攝像頭,添加一些燈光並開始旋轉。
@Override
public void start(Stage primaryStage) {
PerspectiveCamera camera = new PerspectiveCamera(true);
camera.setNearClip(0.1);
camera.setFarClip(10000.0);
camera.setFieldOfView(90);
Sphere sphere = new Sphere(1000);
sphere.setCullFace(CullFace.NONE);
PhongMaterial material = new PhongMaterial();
/*
"SonyCenter 360panorama" by François Reincke - Own work. Made using autostitch (www.autostitch.net)..
Licensed under CC BY-SA 3.0 via Wikimedia Commons - http://commons.wikimedia.org/wiki/File:SonyCenter_360panorama.jpg#mediaviewer/File:SonyCenter_360panorama.jpg
*/
material.setDiffuseMap(new Image(getClass().getResource("SonyCenter_360panorama_reversed.jpg").toExternalForm()));
sphere.setMaterial(material);
Group root3D = new Group(camera,sphere,new AmbientLight(Color.WHITE));
Scene scene = new Scene(root3D, 800, 600, true, SceneAntialiasing.BALANCED);
scene.setCamera(camera);
primaryStage.setTitle("PhotoSphere in JavaFX3D");
primaryStage.setScene(scene);
primaryStage.show();
final Timeline rotateTimeline = new Timeline();
rotateTimeline.setCycleCount(Timeline.INDEFINITE);
camera.setRotationAxis(Rotate.Y_AXIS);
final KeyValue kv1 = new KeyValue(camera.rotateProperty(), 360);
final KeyFrame kf1 = new KeyFrame(Duration.millis(30000), kv1);
rotateTimeline.getKeyFrames().addAll(kf1);
rotateTimeline.play();
}
現在你會想一些控件添加到相機(這樣你就可以瀏覽)。你會發現,這種解決方案在球體的頂部和底部的一個弱點,由於該圖像的全部頂部或底部側在一個點上:
你可以在F(X)yz庫here找到解決這個問題的辦法。一個名爲SegmentedSphereMesh
的自定義網格允許您裁剪球體的極值,因此圖像可以保持其縱橫比而不會被拉伸。
如果克隆和構建回購,在以前的片段添加FXyz.jar到您的項目,並只需更換Sphere
本:
SegmentedSphereMesh sphere = new SegmentedSphereMesh(100,0,26,1000);
sphere.setCullFace(CullFace.NONE);
sphere.setTextureModeImage(getClass().getResource("SonyCenter_360panorama_reversed.jpg").toExternalForm());
在相同的庫,您可以找到SkyBox
,基於其每個面上的立方體和一個方形圖像。另請檢查高級相機選項。
最後,請注意,現在在F(X)yz-Sampler application中演示了此更多3D高級形狀。
相關問題
- 1. 用於android photosphere的XML視圖?
- 2. 4.2版設備上的Photosphere
- 3. Android Photosphere代碼示例
- 4. 如何打開photosphere相機?
- 5. 使用不在Google服務器上託管的圖片嵌入Google PhotoSphere(gapi.panoembed)
- 6. 如何複製Google Cardboard Photosphere應用程序
- 7. 如何在打開全景圖時設置photosphere模式Android
- 8. 如何在我的應用中加載Photosphere?
- 9. 我如何在Unity3D的運行時更新/更改photosphere/skybox?
- 10. 谷歌紙板的Unity- Photosphere照片查看器
- 11. 在JavaScript中動態創建類似的Google地圖地圖控件
- 12. 在Windows 8中創建類似於3D效果的效果8
- 13. 創建的類似於AS3
- 14. 適用於Google地圖的Java API(或類似的地址)
- 15. 創建類似於谷歌分析的分析地圖
- 16. C++ Collections:如何創建類似於結構的地圖
- 17. 創建類似於android
- 18. Google地圖 - 使用不是ID的類創建地圖?
- 19. 在Google搜索結果中顯示的創建類似Facebook的站點地圖
- 20. 一種類似於Google地圖中的繪製編碼算法
- 21. 如何創建Google Latitude類似標記?
- 22. 從Google地圖等PNG創建地圖
- 23. 創建Google地圖容器
- 24. 創建類似於天氣風暴廣播的地塊
- 25. 如何在JavaFX 3D中創建霧?
- 26. Google和Yandex地圖是否類似?
- 27. 如何爲iphone/ipad創建3D地圖
- 28. 用於創建Google地圖或地球的Java API
- 29. Silverlight工具包 - 創建一個類似Google的圖表
- 30. 創建類似OpenGL的圖形庫