To get relative points on a collision shape (compound shape), I have tried the raytest from inside-out of the shape, but never worked from inside. it only worked from outside.
Here is my setup and the code:
- C++ openframeworks bullet physics addson
- Visual studio 2012
- made a rigidbody called "shape"
- made a btDiscreteDynamicsWorld called "world"
Here is a raytest code sample:
btVector3 ray_from = shape->getCenterOfMassPosition() ; // center of mass of the shape called stones[0]
btVector3 ray_to = ray_from + btVector3(0, -100., 0); // ray to the top
btCollisionWorld::AllHitsRayResultCallback allResults(ray_from, ray_to);
world->rayTest(ray_from, ray_to, allResults);
for (int i = 0; i < allResults.m_hitFractions.size(); i++)
{
btVector3 p = ray_from.lerp(ray_to, allResults.m_hitFractions[i]);
ray_all_results.push_back(new btVector3(p.getX(), p.getY(), p.getZ()));
}