SharedNode Problem

Hi people,



I'm having problems with SharedNodes.



I'm trying to draw a texture quad on differents locations, but I't seems it only draws at the last node.



First of all, I create a texture Node and then I call this function two or more times, with the same "surface" an different locations (x,y)



   public void blit(JMESurface surface, int x, int y) {
      //I create a textureNode, it's a copy of the textureNode already created
      SharedNode textureNode = new SharedNode(surface.getTextureNode().getTextureNode());
      
      //Create a node for the translation
      Node nodoSurface = new Node("nodoSurface"+surface.getIdSurface());
      nodoSurface.setLocalTranslation(x,y, zActual);
      
                     
      zActual+=0.1;
      
      
      //Attach the Geometry Node to the node
      nodoSurface.attachChild(surface.getGeomSurface());
      
      //Attach the node to the textureNode
      textureNode.attachChild(nodoSurface);
      
      
      //Attach the textureNode to the rootnode(current)
      current.attachChild(textureNode);
      
   }



I'm missing something, and I don't known why.

Maybe I need to copy the Geometry node? How to do it?

surface.getGeomSurface() returns the quad saved on the surface. It's a trimesh


JMESurface
....
//Geometry
private TriMesh geomSurface;

...

init(){
   ...
   geomSurface=create3DSurface(width, height);
   ...
}

...
private TriMesh create3DSurface(int width, int height) {
      
      Quad q = new Quad("2DSurface"+idSurface,width,height);
      // Texture Coordinates for each position (ya se han calculado las u y v)
        Vector2f[] texCoords={
         new Vector2f(u1,v1),
         new Vector2f(u1,v2),
         new Vector2f(u2,v2),
         new Vector2f(u2,v1)
        };
       
        TexCoords tc=new TexCoords(BufferUtils.createFloatBuffer(texCoords));
      q.setTextureCoords(tc);
      
      q.setModelBound(new BoundingBox());
      q.updateModelBound();
      return q;
   }

Why not also share the quad? That way you don't need to copy the geometry (which your solution as it looks now would need).

Ok.



I had change the code I little, instead of retreaving a TextureNode I retrive a TextureState.



And Made a SharedMesh.




...
nodoSurface.setRenderState(surface.getTextureNode().getTextureNode());
nodoSurface.updateRenderState();
...

 SharedMesh sharedGeom = new SharedMesh(surface.getGeomSurface());
 nodoSurface.attachChild(sharedGeom);



But I had a strange problem.

When I display something on the screen It show's the texture without modifications (u,v), but If I type "T" (I'm in debug mode) I could see for a little time the screen I want it.

Look at the screenshots below.

Bad:


Good: