legacyOpenVr.adoc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. = Virtual Reality Legacy support
  2. :revnumber: 2.0
  3. :revdate: 2020/07/27
  4. == Introduction
  5. The jMonkeyEngine module jme3-vr is deprecated and will be removed in a future version. This documents that deprecated functionality.
  6. jMonkeyEngine 3 supports several VR specifications. The most modern of those is OpenVR, which is currently a widely supported standard. However, vendors are beginning to move towards OpenXR as a fully open cross-platform standard. OpenXR is available with jMonkeyEngine via xref:contributions:vr/topic_contributions_vr.adoc[user contributed virtual reality libraries].
  7. The known supported systems are:
  8. HTC Vive and systems supporting SteamVR/OpenVR
  9. Native Oculus Rift support (and through SteamVR)
  10. Oculus Quest 2 (through SteamVR with Virtual Desktop)
  11. Razer HDK and systems supporting OSVR
  12. Google Cardboard / GoogleVR
  13. Two implementations exist for OpenVR. A community maintained JNA based binding and LWJGL's JNI based.
  14. To use the JNA based bindings, put:
  15. settings.put(VRConstants.SETTING_VRAPI, VRConstants.SETTING_VRAPI_OPENVR_VALUE);
  16. in your settings. To use LWJGL, instead put:
  17. settings.put(VRConstants.SETTING_VRAPI, VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE);
  18. Note that the LWJGL bindings require LWJGL3 (jme3-lwjgl3) to be used.
  19. == Required dependencies
  20. - org.jmonkeyengine:jme3-core
  21. - org.jmonkeyengine:jme3-lwjgl3
  22. - org.jmonkeyengine:jme3-vr
  23. == Sample Application
  24. [source,java]
  25. ----
  26. public class Main extends SimpleApplication {
  27. public static void main(String[] args) {
  28. AppSettings settings = new AppSettings(true);
  29. settings.put(VRConstants.SETTING_VRAPI, VRConstants.SETTING_VRAPI_OPENVR_LWJGL_VALUE);
  30. settings.put(VRConstants.SETTING_ENABLE_MIRROR_WINDOW, true);
  31. VREnvironment env = new VREnvironment(settings);
  32. env.initialize();
  33. // Checking if the VR environment is well initialized
  34. // (access to the underlying VR system is effective, VR devices are detected).
  35. if (env.isInitialized()){
  36. VRAppState vrAppState = new VRAppState(settings, env);
  37. vrAppState.setMirrorWindowSize(1024, 800);
  38. Main app = new Main(vrAppState);
  39. app.setLostFocusBehavior(LostFocusBehavior.Disabled);
  40. app.setSettings(settings);
  41. app.setShowSettings(false);
  42. app.start();
  43. }
  44. }
  45. public Main(AppState... appStates) {
  46. super(appStates);
  47. }
  48. @Override
  49. public void simpleInitApp() {
  50. Box b = new Box(1, 1, 1);
  51. Geometry geom = new Geometry("Box", b);
  52. Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
  53. mat.setColor("Color", ColorRGBA.Blue);
  54. geom.setMaterial(mat);
  55. rootNode.attachChild(geom);
  56. }
  57. @Override
  58. public void simpleUpdate(float tpf) {
  59. //TODO: add update code
  60. }
  61. @Override
  62. public void simpleRender(RenderManager rm) {
  63. //TODO: add render code
  64. }
  65. }
  66. ----
  67. Project source: https://github.com/neph1/VRSampleApplication
  68. == Google Cardboard VR SDK 1.0 integration
  69. gvr-android-jme (https://github.com/nordfalk/gvr-android-jme)
  70. == Legacy
  71. The following projects are not up to date, but may provide functionality not found in the other packages.
  72. Google Cardboard up to version 0.6: https://github.com/neph1/jme-cardboard