Deep copy of a Texture

Texture.createSimpleClone() copies everything concerning the Texture except the image itself, but I need that too.



What I am doing is I have a TextureRenderer that renders an animated model to a Texture, kind of like ImposterNode is doing it. This is already working. I need a Texture that shows the animation of the model at time 0.0f.



After the TextureRenderer is set up I want to somehow retrieve a copy of the Texture:



Texture2D textureClone = (Texture2D) str.getTexture().createSimpleClone();
((LWJGLTextureRenderer)str.getTextureRenderer()).copyToTexture(textureClone, texWidth, texWidth);



does not work because the texturerenderer will keep rendering to the cloned Texture. I want it to write the texture once and then somehow detach it from the renderer.

anyone? thx,
Andy

damn it.



right now i can come up with this:



str.updateScene(0.0f);
str.renderTexture();

Texture2D textureClone = new Texture2D();
copyProperties(str.getTexture(), textureClone);
((LWJGLTextureRenderer) str.getTextureRenderer()).copyToTexture(textureClone, texWidth, texWidth);



I call this after setting up the scene in the texturerenderer. however the Texture 'textureClone' is blanc.

PLZ help

Not sure if this would work, but seeing as it’s just a normal Java object like everything else I imagine it would.  I created a cloning utility in jCommon that provides several methods of deep cloning:



http://commonj.googlecode.com/svn/trunk/src/org/jcommon/clone/CloneUtilities.java



It defaults to use the reflection method (which is by far the fastest), but you can always configure it to use a more typical deep cloning style if you prefer.

Deep cloning wont do the job, since the textureId is what identifies the texture to OGL, and using the same textureId will result in overwriting the texture.



Set up two textures for RTT, after you render to the first texture, use that as your original clone, after that use the second to render to afterwards.

thanks darkfrog for the answer but i got it to work just now like this:



tRenderer.setMultipleTargets(true);
animatedTexture = new Texture2D();
stillTexture = new Texture2D();
tRenderer.setupTexture(animatedTexture);
tRenderer.setupTexture(stillTexture);

tRenderer.render(symbolSceneParent, stillTexture);



and in the draw() method, i render the animatedTexture.

this is somehow worse than copying the initial texture since it is being drawn twice, but it is only done once in the constructor which is called at the startup of the game.  :)
vear said:

Set up two textures for RTT, after you render to the first texture, use that as your original clone, after that use the second to render to afterwards.


right you are.

Hi

Did you manage to clone textures so that they have separate images?



Any success, please?