Can't find the data in a texture created by a SceneProcessor

Hi,



I am currently working on a kind of level design app, and because I have to handle many cameras, I would like to display each render separately (each camera has it’s own SceneProcessor, which are set into a SimpleApplication started in OffscreenSurface context).



The rendering is made on a texture, but I can’t figure out where is the raw data into it. I am not sure I am doing this the right way, and don’t understand where is the image in the texture object (obviously, I found the Image object in the texture, but it’s “data” array is empty…)



I know my implementation of the SceneProcessor is functional, I tested it by applying the texture it writes into on a cube (using a second SimpleApplication launched in default mode, quite tricky but working).



I hope I explained my problem well,

Thank you in advance for your help !

Maybe you should try to use several viewPorts and just add a processor to each viewport, so you wouldn’t have to deal with the texture itself.



See TestMultiViews

http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/renderer/TestMultiViews.java



Some explanations about the processor : you should be able to get the texture in the postFrame method of the processor. If your data is empty here , then you’re probably doing something wrong.



see TestRenderToTexture to see how to correctly initialize a FrameBuffer and its associated texture.

http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/post/TestRenderToTexture.java

@nehon said:
Maybe you should try to use several viewPorts and just add a processor to each viewport, so you wouldn't have to deal with the texture itself.


I don't understand, what do you mean by "don't have to deal with the texture itself" ? My final goal is to get the raster contained (somewhere) in the texture (I realize I didn't explicit this need in my first post, sorry about that...), because I might have to do some treatment on it before the displaying with an API that needs a raster.


By the way, I took the TestRenderToTexture example and set the offscreen texture as a private field, here is where I thought there would be the raster into the texture (I add the breakpoint into the 'simpleUpdate()' method after the cube has been displayed, so I am sure the scene has been loaded) :



I hope I just misunderstood something...
Thanks for helping !
@orabeyrolles said:
I don't understand, what do you mean by "don't have to deal with the texture itself" ? My final goal is to get the raster contained (somewhere) in the texture (I realize I didn't explicit this need in my first post, sorry about that...), because I might have to do some treatment on it before the displaying with an API that needs a raster.

Well yeah it could have help to explain what you were trying to do :p
I thought you wanted to render several views on screen.

Anyway it's normal that the texture is empty in the simpleUpdate because the render has not occur yet. You need to go at least to the update of the second frame to see what was rendered in previous frame in this particular case.

Well, I waited to see the cube on my screen before adding the breakpoint in Netbeans, so I am pretty sure the render has occurred at least once…

Hi again,



So is this normal if I still see an empty image in my texture after waiting for the first render (I always let the game begin before adding the breakpoint, so I am sure the render is occurred) ?



I saw other examples with a SceneProcessor (like the one posted by 3H in this topic), and it is always the same : even after a few render, the ‘data’ ArrayList in the Image object of the texture is always empty…



I really don’t understand where is hidden this raster !



Thanks a lot for helping !

Mhh ok, i guess the data is not in the image but in the framebuffer

look at how it’s done in the ScreenShotAppState (http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/desktop/com/jme3/app/state/ScreenshotAppState.java)

the frameBuffer is copied in a ByteBuffer.

1 Like

Great !



I try to use this ‘readFrameBuffer()’ method and let you know how it goes immediately !



Thank you very much ! :smiley: