Hi,

I can get out the vertices from a TriMesh, but the problem is that the vertices represent the initial position of the TriMesh and ignores the translations and rotations. The translations are no problem to solve, but when it comes to the rotations I don't know.

Now I use getMeshAsTrianglesVertices(Vector3f[] verts).

The reason I need this is because I'm implementing a snapping function, so that I can check if the vertices of different objekts are close enough to each other to snap or not. I have a version of this working, but as soon as an object is rotated it fails, since I can't get out the current positions of the vertices.

Anyone have any idea how to solve this problem?

Vertices in and of themselves do not have rotation but only translation/position in local/world space. The appearance of vertices being rotated is an effect of their translation relationships with each other forming polygons. I suspect that you are looking at the local translations of the vertices and not their world translations, as locally they remain relative to the entire mesh's center (0,0,0). See if you can coax out their world translations and solve your problem that way.

yeah, I know, that the entire problem. The vertices I get out from the TriMesh are just relative to the position where the TriMesh was created from the beginning. These vertices are not the same vertices as the ones that the TriMesh is currently consisting of (after translations and rotations).

I was wondering if anyone have a better option that to try and pull out all the individual vertices manually by calculating from for example the center of the box, since this would be quite many calculations and with a large probability of errors (from me).

Is there any jME function that can help me with this or at least a part of the problem? Or does anyone know a good mathematical formula which can make the calculations easier?

dj_danne said:

yeah, I know, that the entire problem. The vertices I get out from the TriMesh are just relative to the position where the TriMesh was created from the beginning. These vertices are not the same vertices as the ones that the TriMesh is currently consisting of (after translations and rotations).

I was wondering if anyone have a better option that to try and pull out all the individual vertices manually by calculating from for example the center of the box, since this would be quite many calculations and with a large probability of errors (from me).

Is there any jME function that can help me with this or at least a part of the problem? Or does anyone know a good mathematical formula which can make the calculations easier?

Rather hard to understand the last thing you said there, but if you want to find the absolute positions of the vertices (that is, world space, not local/object space as discussed), you have to transform them by a world matrix - which is composed of the scale/rotation/translation of the object, and brings those vertices from local to world space. I've notice jme doesn't really seem to expose this (or so I've seen), you can always just create this matrix by multiplying the world scale/rotation/translation together in that order.

Spatial.localToWorld no? just ensure your world data is up to date…

ncomp said:

Spatial.localToWorld no? just ensure your world data is up to date...

Hmm yes, I was wrong, Spatial does expose it.

yes, it worked perfectly!

I can't understand how I missed that function though, I was looking for EXACTLY that… I guess I was just tired or something!

anyway, thx for the help!