Hi
I want to get the local-translation of TriMesh-Objects that are part of an imported *.obj-model. Since they
are not loaded into those TriMeshs, there have to be a way to find out where they are in the whole model.
I discovered that TriMeshs are represented with floatbuffers and so on, and I have no idea how to get
those local-translations out of it. I hope you can help me with this
Wasserleiche said:
Hi
I want to get the local-translation of TriMesh-Objects that are part of an imported *.obj-model. Since they
are not loaded into those TriMeshs, there have to be a way to find out where they are in the whole model.
I discovered that TriMeshs are represented with floatbuffers and so on, and I have no idea how to get
those local-translations out of it. I hope you can help me with this :)
Well, Objects in an imported .obj simply don't have a local translation, the vertices are just at the point where they are. However, you can achieve what I think you think you want to achieve with this:
TriMesh t = obj.getChild(..);
t.setModelBound(new BoundingBox());
t.updateModelBound(),
System.err.println(t.getCenter());
It calculates the center of the TriMesh you want
Thanks for the quick reply.
I tried this out before, but this doesn't work either (and I still don't know why). At least the center
of the boundingvolume is not equal to the center of the whole node (where the TriMesh is attached to),
but there is still no difference.
The thing is, I try to set another object to the same position as the loaded TriMesh, but when I
set the world-translation of the other object to the center of the boundingvolume, the other object
again appears in the middle of the whole node. Do I have to update anything while reseting the
position?
EDIT: You wrote that *.obj-files don't have local-translations. But there are other model-types that
have them? And maybe I could just export my *.obj-files to another format?
The model import/loader must have functionality that breaks a model into sub-meshes, such as HOTTBJ (Blender), MS3D (MilkShape3d), etc. Once you have the model loaded you should be able to do a getChild() on the main mesh and identify a sub-mesh. From there you should be able to assign a bounding shape (if one has not already been assigned) and then get the center of the bounding volume.
If you need help beyond this, I can dig up some code at home and copy it here so that you can see what I'm talking about.
ashtonv said:
Once you have the model loaded you should be able to do a getChild() on the main mesh and identify a sub-mesh. From there you should be able to assign a bounding shape (if one has not already been assigned) and then get the center of the bounding volume.
Thats exactly the code I posted above ;)
Well exactly for this purpose you should only use staderized models.
Define within your team how a model should be positioned in a medelling programm relative to (0,0,0) and those problems are gone. (or i case of models from i-net siilar, just reposition it yourself, safes more trouble than it makes!