Maybe I'm doing something incorrect cause I can't get the triangles to be drawn/updated when assigning controller, applying, removing and then calling build. Here's what I do:
where JpctMeshData is just initialized as:
and controller.updateMeshData():
Had the same problem earlier. That's why I had to keep the controller but only update it the first time and then continue by only updating the attributes..
Code Select
int vertexCount = object.getMesh().getUniqueVertexCount();
JpctVertexController2 controller = new JpctVertexController2();
object.getMesh().setVertexController(controller, true);
JpctMeshData initData = new JpctMeshData(vertexCount);
controller.updateMeshData(initData.vertexData, initData.normalData);
object.getMesh().applyVertexController();
object.touch();
object.getMesh().removeVertexController();
object.build();
world.addObject(object);
where JpctMeshData is just initialized as:
Code Select
public JpctMeshData(int size) {
vertexData = new SimpleVector[size];
normalData = new SimpleVector[size];
for(int i = 0; i < vertexData.length; i++) {
vertexData[i] = new SimpleVector();
normalData[i] = new SimpleVector(0, -1, 0);
}
}
and controller.updateMeshData():
Code Select
public synchronized void updateMeshData(SimpleVector[] meshData, SimpleVector[] normalData) {
SimpleVector[] destinationMesh = getDestinationMesh();
SimpleVector[] destinationNormals = getDestinationNormals();
System.arraycopy(meshData, 0, destinationMesh, 0, meshData.length);
System.arraycopy(normalData, 0, destinationNormals, 0, normalData.length);
}
Had the same problem earlier. That's why I had to keep the controller but only update it the first time and then continue by only updating the attributes..