Getting coordinates of lowest point on object

Nick
Posts: 3
Joined: Tue Oct 12, 2010 1:52 pm

Getting coordinates of lowest point on object

Post by Nick »

Hi all, I'm trying to work out how I can compute the coordinates of the "lowest" point in an object/shape in the world, by which I mean the point with the lowest y-coordinate.

Now, clearly I can get the lowest y-coordinate from the AABB, but I can't see how I would then proceed to get the x- and z- coordinates.

Can anyone point me in the right direction?
Ripiz
Posts: 47
Joined: Mon Aug 16, 2010 10:43 am

Re: Getting coordinates of lowest point on object

Post by Ripiz »

I think you'll have to loop through every vertex and compare to find lowest one.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Getting coordinates of lowest point on object

Post by Erwin Coumans »

It depends on the collision shape type. For convex objects (btBoxShape, btSphereShape, btConvexHullShape, btCylinderShape etc), you can use the 'getSupportingVertex' method:

Given a convex shape and a world transform, you can try something like:

Code: Select all

btVector3 direction(0,-1,0);
btVector3 supportAxisInA = (direction)* worldTransform.getBasis();
btVector3 pInA = convexShape->localGetSupportVertexWithoutMarginNonVirtual(supportAxisInA);
btVector3  pointInWorld = worldTransform(pInA);
For compound shapes and triangle meshes, it requires a bit more work.
Thanks,
Erwin