Java Code Examples for com.jme3.scene.Node#updateGeometricState()
The following examples show how to use
com.jme3.scene.Node#updateGeometricState() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CollideIgnoreTransformTest.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testPhantomTriangles() { JmeSystem.setSystemDelegate(new MockJmeSystemDelegate()); assetManager = new DesktopAssetManager(); assetManager.registerLocator(null, ClasspathLocator.class); assetManager.registerLoader(J3MLoader.class, "j3m", "j3md"); rootNode = new Node(); createRedSquare(); rootNode.updateLogicalState(0.01f); rootNode.updateGeometricState(); /** * ray in the -Z direction, starting from (0.5, 0.6, 10) */ Ray ray1 = new Ray(/* origin */new Vector3f(0.5f, 0.6f, 10f), /* direction */ new Vector3f(0f, 0f, -1f)); castRay(ray1, 1); /** * ray in the -Z direction, starting from (0.5, 3, 10) */ Ray ray0 = new Ray(/* origin */new Vector3f(0.5f, 3f, 10f), /* direction */ new Vector3f(0f, 0f, -1f)); castRay(ray0, 0); }
Example 2
Source File: HudState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected void initialize( Application app ) { InputMapper inputMapper = GuiGlobals.getInstance().getInputMapper(); inputMapper.addDelegate( MainFunctions.F_HUD, this, "toggleHud" ); Camera cam = app.getCamera().clone(); cam.setParallelProjection(true); size = new Vector3f( cam.getWidth(), cam.getHeight(), 0 ); main = new Node( "HUD" ); main.setQueueBucket(Bucket.Gui); view = app.getRenderManager().createPostView( "Hud ViewPort", cam); view.setEnabled(isEnabled()); view.setClearFlags(false, true, true); view.attachScene( main ); // Make sure our viewport is setup properly GuiGlobals.getInstance().setupGuiComparators(view); // Make sure this viewport gets mouse events getState(MouseAppState.class).addCollisionRoot( main, view ); // Setup a basic container for standard layout... for anything // that cares to use it. container = new Container( new BorderLayout() ); container.setPreferredSize( new Vector3f(cam.getWidth(), cam.getHeight(), 0) ); container.setLocalTranslation( 0, cam.getHeight(), 0 ); main.attachChild(container); if( lit ) { // Add some lighting DirectionalLight light = new DirectionalLight(); light.setDirection( new Vector3f( 1, -0.5f, -1.5f ).normalizeLocal() ); main.addLight(light); AmbientLight ambient = new AmbientLight(); ambient.setColor( ColorRGBA.Gray ); main.addLight(ambient); } // Have to add an empty geometry to the HUD because JME has // a bug in the online versions and I'd rather not go directly to // source. Label temp = new Label(""); getNorth().addChild(temp); /* Just a test container... putting the real stuff somewhere else in a sec. Container test = new Container(new ElementId("window.container"), "glass"); System.out.println( "Container layout:" + test.getLayout() ); test.addChild(new Label("Test Title", new ElementId("window.title.label"), "glass")); test.addChild(new Button("Test Button 1", new ElementId("window.button"), "glass")); test.addChild(new Button("Test Button 2", new ElementId("window.button"), "glass")); test.addChild(new Button("Test Button 3", new ElementId("window.button"), "glass")); test.addChild(new Button("Test Button 4", new ElementId("window.button"), "glass")); getWest().addChild(test); */ main.updateLogicalState(1); main.updateGeometricState(); }
Example 3
Source File: OpenVRViewManager.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Replaces rootNode as the main cameras scene with the distortion mesh */ private void setupVRScene(){ if (environment != null){ if (environment.getApplication() != null){ // no special scene to setup if we are doing instancing if( environment.isInstanceRendering() ) { // distortion has to be done with compositor here... we want only one pass on our end! if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { setupMirrorBuffers(environment.getCamera(), dualEyeTex, true); } return; } leftEyeTexture = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); rightEyeTexture = (Texture2D)getRightViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); leftEyeDepth = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); rightEyeDepth = (Texture2D)getRightViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); // main viewport is either going to be a distortion scene or nothing // mirroring is handled by copying framebuffers Iterator<Spatial> spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); while(spatialIter.hasNext()){ environment.getApplication().getViewPort().detachScene(spatialIter.next()); } spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); while(spatialIter.hasNext()){ environment.getApplication().getGuiViewPort().detachScene(spatialIter.next()); } // only setup distortion scene if compositor isn't running (or using custom mesh distortion option) if( environment.getVRHardware().getCompositor() == null ) { Node distortionScene = new Node(); Material leftMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); leftMat.setTexture("Texture", leftEyeTexture); Geometry leftEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Left, environment.getVRHardware())); leftEye.setMaterial(leftMat); distortionScene.attachChild(leftEye); Material rightMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); rightMat.setTexture("Texture", rightEyeTexture); Geometry rightEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Right, environment.getVRHardware())); rightEye.setMaterial(rightMat); distortionScene.attachChild(rightEye); distortionScene.updateGeometricState(); environment.getApplication().getViewPort().attachScene(distortionScene); //if( useCustomDistortion ) setupFinalFullTexture(app.getViewPort().getCamera()); } if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { setupMirrorBuffers(environment.getCamera(), leftEyeTexture, false); } } else { throw new IllegalStateException("This VR environment is not attached to any application."); } } else { throw new IllegalStateException("This VR view manager is not attached to any VR environment."); } }
Example 4
Source File: OSVRViewManager.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Replaces rootNode as the main cameras scene with the distortion mesh */ private void setupVRScene(){ if (environment != null){ if (environment.getApplication() != null){ // no special scene to setup if we are doing instancing if( environment.isInstanceRendering() ) { // distortion has to be done with compositor here... we want only one pass on our end! if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { setupMirrorBuffers(environment.getCamera(), dualEyeTex, true); } return; } leftEyeTexture = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); rightEyeTexture = (Texture2D)getRightViewPort().getOutputFrameBuffer().getColorBuffer().getTexture(); leftEyeDepth = (Texture2D) getLeftViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); rightEyeDepth = (Texture2D)getRightViewPort().getOutputFrameBuffer().getDepthBuffer().getTexture(); // main viewport is either going to be a distortion scene or nothing // mirroring is handled by copying framebuffers Iterator<Spatial> spatialIter = environment.getApplication().getViewPort().getScenes().iterator(); while(spatialIter.hasNext()){ environment.getApplication().getViewPort().detachScene(spatialIter.next()); } spatialIter = environment.getApplication().getGuiViewPort().getScenes().iterator(); while(spatialIter.hasNext()){ environment.getApplication().getGuiViewPort().detachScene(spatialIter.next()); } // only setup distortion scene if compositor isn't running (or using custom mesh distortion option) if( environment.getVRHardware().getCompositor() == null ) { Node distortionScene = new Node(); Material leftMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); leftMat.setTexture("Texture", leftEyeTexture); Geometry leftEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Left, environment.getVRHardware())); leftEye.setMaterial(leftMat); distortionScene.attachChild(leftEye); Material rightMat = new Material(environment.getApplication().getAssetManager(), "Common/MatDefs/VR/OpenVR.j3md"); rightMat.setTexture("Texture", rightEyeTexture); Geometry rightEye = new Geometry("box", setupDistortionMesh(JOpenVRLibrary.EVREye.EVREye_Eye_Right, environment.getVRHardware())); rightEye.setMaterial(rightMat); distortionScene.attachChild(rightEye); distortionScene.updateGeometricState(); environment.getApplication().getViewPort().attachScene(distortionScene); //if( useCustomDistortion ) setupFinalFullTexture(app.getViewPort().getCamera()); } if( environment.getApplication().getContext().getSettings().isSwapBuffers() ) { setupMirrorBuffers(environment.getCamera(), leftEyeTexture, false); } } else { throw new IllegalStateException("This VR environment is not attached to any application."); } } else { throw new IllegalStateException("This VR view manager is not attached to any VR environment."); } }