Force update on changed TextureCoordinates

Hi,
I am using custom meshes as described in :
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:custom_meshes

What I want is to change the texture coordinates of my mesh. At the moment i recreate the whole mesh and set it on the Geometry again.

The problem is, that it only sporadically updates the new texture. Only if i the vertices also changed the Mesh is updated correctly.
Can i somehow force the redraw of the Mesh/Geometry?
[java]
if (faces[xFace]) {
vertices.add(b);
vertices.add(f);
vertices.add(d);
vertices.add(h);
normals.add(xAxis);
normals.add(xAxis);
normals.add(xAxis);
normals.add(xAxis);

        Vector2f[] cords = tex.getTextureCoordinates(type.getTexturetype(), 0);
        texCoord.add(cords[0]);
        texCoord.add(cords[1]);
        texCoord.add(cords[2]);
        texCoord.add(cords[3]);

        indexes.add(verticesSize + 2);
        indexes.add(verticesSize + 0);
        indexes.add(verticesSize + 1);
        indexes.add(verticesSize + 1);
        indexes.add(verticesSize + 3);
        indexes.add(verticesSize + 2);
    }

[/java]

[java]
public void updateGeometry() {
this.geometry.setMesh(getMesh());
}
[/java]

How are you modifying the mesh?

I change my meshes all the time and I don’t even always tell the Geometry object about it. The buffers are resent to the GPU if you update them properly.

Like i said, i don’t update my mesh I create a new one and set it with setMesh on the geometry. Should I instead update the buffers of the mesh directly?

Either way: “Only if i the vertices also changed the Mesh is updated correctly.”

This is false. You are doing something else wrong. Changing buffers is changing buffers… whether you change the whole mesh out or just swap a new buffer into the mesh.

Produce a simple test case… 9 times out of 10 it works fine and you know the problem. 1 out of 10 times, we point out the problem here after seeing the code.

1 Like

And… you were absolutly right.
Thanks for that kick in the…

The error was offcourse in the part which i excluded first as source of the problem -.-