Modifying Texture Coordinates with Buffer Problem

It might be a bit hard to explain, but I want to reassign texture coordinates of a mesh. I used mesh.getFloatBuffer(Type.TexCoord) to get the FloatBuffer and used put(index, float). But it seems to only work well before optimizing the parent node with GeometryBatchFactory.

[java]for (int i = 0; i < node.getQuantity(); i++) {

Mesh mesh = ((Geometry) node.getChild(i)).getMesh();

FloatBuffer texCoords = mesh.getFloatBuffer(Type.TexCoord);

FloatBuffer vertices = mesh.getFloatBuffer(Type.Position);

for (int j = 0; j < mesh.getVertexCount() * 2;) {

lights.put(j, calcValue(vertices.get(j + j / 2), vertices.get(j + j / 2 + 1), vertices.get(j + j / 2 + 2)));

j += 2;





This is what happens in my code:

  1. Create mesh
  2. Attach to node
  3. Optimize node

    It always works when I do it between 2 and 3, but not after 3.



Optimising has probably taken its own copy of the buffer. Is this behaviour a problem?

@zarch Ah, that makes sense. Thanks. It’s not too much of a problem (for now), but it pauses for a fraction of a second when I recreate the mesh, even when I use executor.submit(callable).

I’m not sure what you mean by executor.submit.

You mean you are creating the mesh in a different thread and then sending it back to the app thread for processing?

If you are creating your own mesh why do you need to optimise it anyway? Can’t you just make it optimised?

Yes, I’m multithreading. I optimize it through GeometryBatchFactory since I attach geometries one at a time to a node, which accumulates to hundreds. It merges geometries with the same materials for me.