Is there any API like getCenter() in OpenGL which I can get the center Translation Matrix of Mesh 3d-model? #998
-
I find that some mesh models don't put there models in their origin of coordinates, in 3d, T = (0, 0, 0) , so I need to get the translation matrix to rectify them. or whether if there are some methods or functions can already do that? And, does the class |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You can get the axis-aligned bounding box of a mesh with You can rotate around the "center" by translating so the center goes to the origin, rotating, and undoing the translation. The code in |
Beta Was this translation helpful? Give feedback.
-
Hummm I some how get lost in the api-doc, perhaps ... That's a nice way to solve my problem! |
Beta Was this translation helpful? Give feedback.
-
I just find that there is already a tutorial about how to scale-normalize and center the target mesh in here. # We scale normalize and center the target mesh to fit in a sphere of radius 1 centered at (0,0,0).
# (scale, center) will be used to bring the predicted mesh to its original center and scale
# Note that normalizing the target mesh, speeds up the optimization but is not necessary!
center = verts.mean(0)
verts = verts - center
scale = max(verts.abs().max(0)[0])
verts = verts / scale
# We construct a Meshes structure for the target mesh
trg_mesh = Meshes(verts=[verts], faces=[faces_idx]) |
Beta Was this translation helpful? Give feedback.
You can get the axis-aligned bounding box of a mesh with
.get_bounding_boxes()
and take the mean (over the last dimension)? Is that what you mean bycenter
? Or you could average all the vertices in a mesh?You can rotate around the "center" by translating so the center goes to the origin, rotating, and undoing the translation. The code in
transform3d.py
can do these things.