Rending as a texture causes wierdness

I've written a little snippet of code to load in a jme model and animate it on the screen:


       
try
        {
            Spatial r = (Spatial)BinaryImporter.getInstance().load( getClass().getResourceAsStream( "mum.jme" ) );
           r.setModelBound(new BoundingBox());
            r.updateModelBound();
            Quaternion temp = new Quaternion();
            temp.fromAngleAxis(FastMath.PI / 2, new Vector3f(-1, 0, 0));
            rootNode.setLocalRotation(temp);
            r.getController( 0 ).setSpeed( 20 );
            r.getController( 0 ).setRepeatType( Controller.RT_WRAP );
            rootNode.attachChild( r );
            cam.lookAt( rootNode.getWorldTranslation( ), new Vector3f( 0, 1, 0) );
            cam.update( );
        } catch (IOException e) {
            e.printStackTrace();
        }



Now, using the render as texture example, I've munged this code together:



  protected void simpleInitGame() {
    display.setTitle("Render to Texture");
    cam.setLocation(new Vector3f(0, 0, 25));
    cam.update();

    // Setup dimensions for a box
    Vector3f max = new Vector3f(5, 5, 5);
    Vector3f min = new Vector3f( -5, -5, -5);

    // Make the real world box -- you'll see this spinning around..  woo...
    realBox = new Box("Box", min, max);
    realBox.setModelBound(new BoundingSphere());
    realBox.updateModelBound();
    realBox.setLocalTranslation(new Vector3f(0, 0, 0));

    rootNode.attachChild(realBox);

    Spatial r = null;
   
    try
    {
        r = (Spatial)BinaryImporter.getInstance().load( getClass().getResourceAsStream( "mum.jme" ) );
       r.setModelBound(new BoundingBox());
        r.updateModelBound();

        Quaternion temp = new Quaternion();
        temp.fromAngleAxis(FastMath.PI / 2, new Vector3f(-1, 0, 0));
        r.setLocalRotation(temp);
       
        r.getController( 0 ).setSpeed( 20 );
        r.getController( 0 ).setRepeatType( Controller.RT_WRAP );
    } catch (IOException e) {
        e.printStackTrace();
    }

    // add the monkey box to a node.  This node is a root node, not part of the "real world" tree.
    fakeScene = new Node("Fake node");
    fakeScene.setRenderQueueMode(Renderer.QUEUE_SKIP);
    fakeScene.attachChild( r );
   
    // Lets add a monkey texture to the geometry we are going to rendertotexture...
    TextureState ts = display.getRenderer().createTextureState();

    // Ok, now lets create the Texture object that our monkey cube will be rendered to.
    tRenderer = display.createTextureRenderer(512, 512, TextureRenderer.RENDER_TEXTURE_2D);
    tRenderer.setBackgroundColor(new ColorRGBA(.667f, .667f, .851f, 1f));
    fakeTex = new Texture();
    fakeTex.setWrap(Texture.WM_CLAMP_S_CLAMP_T);
    if ( tRenderer.isSupported() ) {
        tRenderer.setupTexture(fakeTex);
        tRenderer.getCamera().setLocation(new Vector3f(0, 0, 15));
    } else {
        LoggingSystem.getLogger().severe( "Render to texture not supported!");
    }

    // Now add that texture to the "real" cube.
    ts = display.getRenderer().createTextureState();
    ts.setEnabled(true);
    ts.setTexture(fakeTex, 0);
    rootNode.setRenderState(ts);

    //fakeScene.updateGeometricState(0.0f, true);
    fakeScene.updateRenderState();
  }
}



Something strange happens to the model. It's a mummy, arms outstretched, walking towards the camera. The right side of his head, legs and arms aren't rendered at all, yet the same model renders fine in the first example.

Have I missed something obvious?

Many thanks for your help :)

Nope, still can't seem to fix it…



Setting cull mode to never didn't change anything - tried all sorts of different ideas with no effect.



Stumped!

Is the model made out of sections?  If a piece disappears altogether, it's often a bounding cull.  You might try setting cullmode on your model root to cull_never and see what happens.

Yes I'll look into that, thanks.



Just been thinking about how it appears on the screen, and I think what it's doing is performing backface removal based upon a view from the right hand side of the model, rather than the camera.



Perhaps I should uncomment-out that updateGeometricState call at the end…



I'll have a tinker.