I have this code:
[java] static private void sharpenCard(Node n) {
for (Spatial s: n.getChildren()) {
if (s instanceof Node) {
sharpenCard((Node)s);
} else {
Geometry g = (Geometry)s;
Mesh m = g.getMesh().cloneForAnim();
g.setMesh(m);
FloatBuffer data = (FloatBuffer)m.getBuffer(VertexBuffer.Type.Position).getData();
int index = 0;
while (index < data.limit()) {
float x = data.get(index);
float z = data.get(index+2);
data.put(index, x*(1-(z+2.5f)/5f));
index += 3;
}
m.setBuffer(VertexBuffer.Type.Position, 3, data);
}
}
}
[/java]
It’s supposed to take all the geometries inside a node (in this case a model loaded from the asset manager) and “sharpen” them.
It works perfectly - except that it also modifies every other mesh using that model:
You can see that every card has been turned into a triangle, not just the one that should have been.
I thought this line: Mesh m = g.getMesh().cloneForAnim();
would stop that but it hasn’t made any difference…
Thanks,
Z