Add VR functionality

From JReality Wiki
Jump to: navigation, search

Source file: JRViewerVR

Run as Java webstart


To obtain virtual reality environment in JRViewer, you should first create an instance of JRViewer through the standard constructor.


JRViewer v = new JRViewer();


Then activate the basicUI plugin set. This set includes

  • a scene graph navigator,
  • a bean shell,
  • tool bar,
  • export capabilities, and
  • a few other nice features.


v.addBasicUI();


Then activate the VR plugin set. This set includes

  • an avatar for navigating the
  • terrain, and
  • a skybox.


Note: To get the skybox (sky box) of the screenshot above you need to put vrData.jar into your classpath (see downloads).


v.addVRSupport();


The next two lines describe the content type. In this case, we use the type TERRAIN_ALIGNED to indicate that content should be scaled and positioned to fit into the terrain. The scaling factor is consistent with an avatar with a height of 1.7 units. We also add the plugin name ContentAppearance which provides a convenient inspector for the appearance attached to the content.


v.addContentSupport(ContentType.TerrainAligned);
v.registerPlugin(new ContentAppearance());


Finally set the content itself:


	v.setContent(Primitives.icosahedron());


All that's left is to call startup() on the JRViewer instance. We turn off display of the menu bar to simulate the function of the simple JRViewer as much as possible.


v.startup();
v.getController().setShowMenuBar(false);


Finally, encompass the scene by typing the 'e' key once you have the focus in the graphics window.


Screenshot

IcosahedronVR-01.png


Previous: Create a standalone viewer Developer Tutorial: Contents Next: Use selection capabilities