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;
}