I have a model that I want to break down into its named/grouped components and then operate against those individual components to accomplish various things. I identified the model components as TriMesh so that I could work with the model parts individually.
The most basic (so I think) operation I want to conduct is to return each TriMesh's local or world translation (so that I could, for example, measure the distance between two model parts). I thought I could do this easily by using TriMesh.getLocalTranslation or TriMesh.getWorldTranslation. However, that returns the model's local and world translation and not the TriMesh's. This also raises the question about setLocalTranslation and setWorldTranslation – would these applied to TriMesh also operate against the parent and not the individual TriMesh?
How should I go about doing this? Is there a method that does this specifically (that I obviously haven't discovered yet) or do I have to use something like getMeshAsTriangles or getMeshAsTrianglesVertices and then operate against it from there?
Your model is probably set up in a way such that each model part has it's origin at the model's origin.
Animations are most likely done by animating vertices rather than local translations/rotations, so the translations and rotations of each individual TriMesh will never change.
If whatever animates your model also updates the bounding volumes for the individual parts you could use their bounding volumes' center locations to get an idea of how the model parts are moving when animated.
To see if the individual parts have bounding volumes, you can press "b" in SimpleGame subclasses.
Interesting! Thanks for your reply.
I'm relatively certain (based on previous work although I have not checked the current work) that the model's component TriMeshes each have their own individual bounding volumes, or can be made to have them. Given that they do, how is the center of the bounding volume retrieved from the TriMesh? I don't see anything in the documentation (not being at my dev workstation right now to look directly at the code) that links directly back to bounding volume from TriMesh.
And… how about the other part of the question regarding translations of individual TriMeshes within a node/model? Would something like translating or scaling an individual TriMesh within a parent nodel/model be possible? (As an example: a space station corridor with a TriMesh identified as "Door". Translate "Door" +10 on the y without affecting the node/model's y.)
ashtonv said:
how is the center of the bounding volume retrieved from the TriMesh?
Spatial.getWorldBound() and BoundingVolume.getCenter() are your friends.
ashtonv said:
Would something like translating or scaling an individual TriMesh within a parent nodel/model be possible?
Definitely.
So… something like (and this might not be correct syntax):
BoundingVolume tmBV = new BoundingVolume(TriMesh.getWorldBound());
Vector3f tmBVCenter = new Vector3f(tmBV.getCenter());
will return the TriMesh's bounding volume center? Veddy nice, if so!
The code actually works out to:
BoundingVolume bvTM = TM.getWorldBound();
Vector3f bvTMCenter = bvTM.getCenter();
and it works like a charm! Thanks!