Using RayTest
From Physics Simulation Wiki
Ray casting is like shooting a virtual laser between two points, and seeing if (and what) it hit. See also the Wikipedia article. There is a number of useful things you can do with ray casting, such as firing weapons.
To do a raycast, you need to:
- Create a RayResultCallback object
- Do the raytest
- Process the results of the raycast
Basic example
// Start and End are vectors btCollisionWorld::ClosestRayResultCallback RayCallback(Start, End); // Perform raycast World->rayTest(Start, End, RayCallback); if(RayCallback.hasHit()) { End = RayCallback.m_hitPointWorld; Normal = RayCallback.m_hitNormalWorld; // Do some clever stuff here }
