Author Topic: How to get the center of a mesh  (Read 1937 times)

Angelo

  • Jr. Member
  • **
  • Posts: 32
How to get the center of a mesh
« on: April 21, 2012, 07:13:45 AM »
Is there a fast way of getting the Vec3 that represents position of center of a mesh, instead of reading all its vertices?

jerome_j

  • Administrator
  • *****
  • Posts: 116
    • Bonzai Engine
Re: How to get the center of a mesh
« Reply #1 on: April 21, 2012, 01:53:55 PM »
Yes, use it's bounding volume. It's much more efficient and compatible with model with animation.

You can get box and sphere volumes (axis aligned or oriented).
Here's an exemple to get an axis aligned bounding box of all visible meshes of a model:

Then the center of the BoundingBox or BoundingSphere is pretty obvious.
« Last Edit: July 08, 2013, 09:52:19 AM by jerome_j »