btConvexTriangleMeshShape raycasting question
-
- Posts: 73
- Joined: Tue Oct 06, 2009 3:19 pm
btConvexTriangleMeshShape raycasting question
I want to find out if there is some way to get the actual surface point with a raycast on a btConvexTriangleMeshShape? I am trying to place bullet decals on moveable objects.
-
- Posts: 7
- Joined: Sat Jul 10, 2010 8:34 pm
Re: btConvexTriangleMeshShape raycasting question
Of course, take a look at the RayCast demo :
Once you've done that, and if the ray hit something, "cb" contains everything you need such as the position of the hit, the normal of the plane, the rigid body etc.
I'm not an expert with this ( ), but i think you should be able to implement what you want to do by saving those, and querying the rigid body every frame to retrieve an offset.
Code: Select all
btCollisionWorld::ClosestRayResultCallback cb(source, destination);
collisionworld->rayTest (source, destination, cb);
Code: Select all
if (cb.hasHit ())
{
body = cb.m_collisionObject;
hit = cb.m_hitPointWorld;
normal = cb.m_hitNormalWorld;
}
-
- Posts: 73
- Joined: Tue Oct 06, 2009 3:19 pm
Re: btConvexTriangleMeshShape raycasting question
Thanks a ton, I am going to try this out. It is different from the way I was trying, which means it will probably work perfectly LOL.
-
- Posts: 73
- Joined: Tue Oct 06, 2009 3:19 pm
Re: btConvexTriangleMeshShape raycasting question
Well I tried it and got the same results as when I was using rayCastSingle. It reads the collision just fine but the point it returns is not on the surface of the mesh, there seems to be some sort of contact distance buffer. Additionally the normal is sometimes not correct. I have verified through debug rendering that the mesh confirms exactly to shape of the object, so it isn't that.
-
- Posts: 73
- Joined: Tue Oct 06, 2009 3:19 pm
Re: btConvexTriangleMeshShape raycasting question
I also tried creating the mesh as a btBvhTriangleMeshShape. Of course it doesn't really work for my purposes but the raycast actually hit the surface.