[SOLVED] Render to texture dont support Animations?

My model is buged when I render it on render to texture :
It render perfect when not in this mode.
Bug, not supported or something else ???

j3o : http://wikisend.com/download/266888/evechar.j3o

test case code :

  package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.input.KeyInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.renderer.Camera;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture2D;

public class TestRenderToTexture extends SimpleApplication {

    private Spatial offBox;
    private ViewPort offView;

    public static void main(String[] args){
        TestRenderToTexture app = new TestRenderToTexture();

    public Texture setupOffscreenView(){
        Camera offCamera = new Camera(512, 512);

        offView = renderManager.createPreView("Offscreen View", offCamera);
        offView.setClearFlags(true, true, true);

        // create offscreen framebuffer
        FrameBuffer offBuffer = new FrameBuffer(512, 512, 1);

        //setup framebuffer's cam
        offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f);
        offCamera.setLocation(new Vector3f(0f, 0f, -5f));
        offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);

        //setup framebuffer's texture
        Texture2D offTex = new Texture2D(512, 512, Format.RGBA8);

        //setup framebuffer to use texture

        //set viewport to render to offscreen framebuffer

        // setup framebuffer's scene
        offBox = assetManager.loadModel("Models/evechar.j3o");

        //Box boxMesh = new Box(Vector3f.ZERO, 1,1,1);
        //Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        //offBox = new Geometry("box", boxMesh);

        // attach the scene to the viewport to be rendered

        return offTex;

    @Override public void simpleInitApp() {
        cam.setLocation(new Vector3f(3, 3, 3));
        cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);

        //setup main scene
        Geometry quad = new Geometry("box", new Box(Vector3f.ZERO, 1,1,1));

        Texture offTex = setupOffscreenView();

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setTexture("ColorMap", offTex);

    @Override public void simpleUpdate(float tpf){
        if (offView.isEnabled()) {


Obs: I tried other models with the same buged result.

Just to add, that I test it with the Sinbad.mesh and got the same results…

Just found out the problem, and also what the offBox.updateLogicalState(tpf); do :smile:

For info, add the code


before the offBox.updateGeometricState();

Sorry for the trouble :chimpanzee_nogood:

1 Like

you should place it before updateGeometricState

Thats right, thanks for the correction !

if(offView.isEnabled()) { renderNode.updateLogicalState(tpf); renderNode.updateGeometricState(); }