How to use Pass and change the spatial while drawing

I'm extending Pass to make some special drawing.



In doRender, how can I take a Spatial, draw it, make a change to it and draw it again?



I tried doing this f.ex.


public void doRender(Renderer r) {
  
       
        Node node;
        for (int j = 0; j < spatials.size(); j++) {

            if (spatials.get(j) instanceof Node) {

                node = (Node) spatials.get(j);

                for (int i = 0; i < node.getQuantity(); i++) {

                    TriMesh mesh = null;

                    if(node.getChild(i) instanceof TriMesh){

                        mesh = (TriMesh)node.getChild(i);
                       
                        scaleVertexBuffer(mesh.getVertexBuffer(), 2f);
                                           
                        mesh.draw(r);

                        scaleVertexBuffer(mesh.getVertexBuffer(), 0.5f);
                   
                        mesh.draw(r);
                    }
               

                   }
            }
        }

       }



From this I expect to see a small version of the meshes drawn on top of itself, but all I see is the small version.

The jME Renderer queues up all models that you order it to draw, the call mesh.draw® simply says "draw the mesh object when the frame ends". Thus you can't see the changes of your first scaling since you modify it right away with the second scaling.



In order to make sure your mesh gets drawn before being scaled, you have to call Renderer.renderQueue() like so:


scaleVertexBuffer(mesh.getVertexBuffer(), 2f);
mesh.draw(r);
r.renderQueue();

scaleVertexBuffer(mesh.getVertexBuffer(), 0.5f);
mesh.draw(r);

Thank you!