[solved] render to texture

hello,



I would have wanted to render an animation(3d) to an image

so i could use it in the nifty gui

to select caracter, or to view objects in 3d

i can’t find any info on that :frowning:



thx

You want to render it to the screen at the same time? Or you want to set up a separate viewport (not view the stuff you render, just get a texture)?

If you want to render a 3D object to a texture, take a look at TestRenderToTexture in the jme3 tests.

With the method used in that test you’ll get a Texture2D which you can then use to create a NiftyImage (new NiftyImage(nifty.getRenderEngine(), new RenderImageJme(tex2d));).

@Tumaini said:
If you want to render a 3D object to a texture, take a look at TestRenderToTexture in the jme3 tests.
With the method used in that test you'll get a Texture2D which you can then use to create a NiftyImage (new NiftyImage(nifty.getRenderEngine(), new RenderImageJme(tex2d));).

awesome thx a lot :)
@Tumaini said:
If you want to render a 3D object to a texture, take a look at TestRenderToTexture in the jme3 tests.
With the method used in that test you'll get a Texture2D which you can then use to create a NiftyImage (new NiftyImage(nifty.getRenderEngine(), new RenderImageJme(tex2d));).

problem is that i got this error

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: box2
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)

i dont get it...

Search the forums, there’s about 10 billion posts on that subject.

1 Like

Yes, I got that error as well, it’s seems like a strange error to get here until you realise that your object is not attached to the application root node, so updateGeometricState() isn’t called on it automatically.

Just call updateGeometricState() on your spatial (continuously if you change anything about it later).

@Tumaini said:
Yes, I got that error as well, it's seems like a strange error to get here until you realise that your object is not attached to the application root node, so updateGeometricState() isn't called on it automatically.
Just call updateGeometricState() on your spatial (continuously if you change anything about it later).

thx man, that was the trick
awesome :)