Render Node always on Top

Hello I just wanted to know if I can render a Node always on top (but behind the GUINode).

How can I do that ? Or how is it made that in games the items of the player are always on top ?

Greetings,

J4ever

Multiple viewports, the player’s weapon viewport rendering on top of the scene viewport. TestMultiViews.java shows how to use them and there are some examples peppered throughout the forums.

1 Like

Ok thank you. I will look at the example :smiley:

Ok it works nearly fine but the viewport of the weapon is not transparent. How can i fix that ? I tried to set the Background Color to null but that doesn’t work.

Try myViewPort.setClearFlags(false, false, false);

1 Like

He probably wants to clear the depth buffer?

Ok thank you for the usefull tips so far. Now I thought when I have another viewport i don’t need to attach the weapon to the RootNode but when I don’t do it I get this exception: java.lang.IllegalStateException: Scene graph is not properly updated for rendering.

State was changed after rootNode.updateGeometricState() call.

Make sure you do not modify the scene from another thread!

Problem spatial name: ViewingPlatform

at com.jme3.scene.Spatial.checkCulling(Spatial.java:242)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:775)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1116)

at com.jme3.renderer.RenderManager.render(RenderManager.java:1167)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:263)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:149)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:223)

at java.lang.Thread.run(Thread.java:722)



This exception is because I change the Position of the viewingplatform to the position of the cam.

when I write spieler.viewingPlatform.updateGeometricState(); in the simpleUpdate() I don’t get the error but the model seems not to be rendered correctly. Is this the right solution or is there something else I have to look at ?

Thanks for your help so far.

Ok I don’t need to change the position of the weapon when I don’t change the Position of the camera from the second ViewPort.

But am I modifying the Weapons Node when I play animations from the models ?

@zarch Hmm I don’t know if i want to do that because I don’t know what it does when I clear it and how that works :smiley: maybe you are right but the idea with the viewport works too. And I think when the error above is fixed it works fine

Search for ViewportState in the upper right “custom google search” for the methods you need to call on your extra viewport’s root node to keep everything happy.

1 Like

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:multithreading

@zarch said:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:multithreading


While interesting reading, this is unrelated to the OP's problem.

Ahh, that looked like the threading scene graph exceptions? Unless its due to the viewport setup instead?

@zarch said:
Ahh, that looked like the threading scene graph exceptions? Unless its due to the viewport setup instead?


A root node needs to have updateLogicalState() and updateGeometricState() or whatever methods called on it every frame (if something about it changes) or you will get this error. The error can also indicate changes from another thread but really it's that changes were made after updateGeometricState() was called but before the renderer got it.

Simpleapplication calls these on the normal root node by default. If you have your own viewport then you need to call them yourself. My example ViewPortState (which I've posted before) shows when these should ideally be called.
2 Likes

Ahh, thanks. Good to know :slight_smile:

Hey pspeed, i tried your class and it is AWESOME. Thanks for sharing it. :smiley:

And also thanks to the others.

@j4ever said:
Hey pspeed, i tried your class and it is AWESOME. Thanks for sharing it. :D
And also thanks to the others.


Cool. Glad it worked for you. Someday I should add a more official version or something. :)
2 Likes