Hi!
I want to build a wall (TriMesh) with an inner side, an outer side and the top.
Each one should be textured differently.
Because of historical reasons I want to use a TriMesh (once in JME1
it was a Geometry with TriangleBatch objects, the TriangleBatch
had been textured separately).
Is it possible to treat sections of a TriMesh separately?
Let's say the first 6 vertices inside the TriMesh are green,
the next 6 vertices are blue, and so on.
Or do I have to build a TriMesh array (or collection) ?
This would mean big changes in my code, so I wanted to avoid that.
TriangleMesh wallMesh;
int[] leftSideIndices, float[] leftSideVertices, float[] leftSideCoords;
int[] rightSideIndices, float[] rightSideVertices, float[] rightSideCoords;
int[] topIndices, float[] topVertices, float[] topCoords;
final int LEFT, RIGHT, TOP;
addBatch(wallMesh, LEFT, leftSideIndices, leftSideVertices, leftSideCoords);
addBatch(wallMesh, RIGHT, rightSideIndices, rightSideVertices, rightSideCoords);
addBatch(wallMesh, TOP, topIndices, topVertices, topCoords);
// this is pseudo-code
private void addBatch(TriMesh mesh, int batchIndex, int[] indices, float[] vertices, float[] texCoords) {
mesh.add(BufferUtils.createFloatBuffer(vertices), null, null,
new TexCoords(BufferUtils.createFloatBuffer(texCoords)),
BufferUtils.createIntBuffer(indices)); // pseudo, but should behave like mesh.reconstruct
if (batchIndex == LEFT) // left texture
mesh.setRenderState(leftRenderState);
else if (batchIndex == RIGHT) // right texture
mesh.setRenderState(leftRenderState);
else if (batchIndex == RIGHT) // no texture
batch.setTextureCombineMode(TextureCombineMode.Off);
}
Thanks,
Bernd