Detect point of intersection with raycast

l34ndr4

14-03-2006 20:53:47

hi,

I want to know if there is a way to know the exact triangles of the collision detection with the body in the rayCast.

In the RaySceneQuery I can only detect the bounding box, in all the forums I have found that OgreOpcode detect this, but I am using OgreNewt so I want to know if OgreNewt can do this because I dont want to use both, I think that it will be a great performance impact.

walaber

14-03-2006 23:55:22

newton will not give you the exact triangle, because it is using simplified geometry instead of the actual polygons. even with a TreeCollision object, it has the option to join coplanar faces into single faces.

it gives you the exact point of contact, and the normal, but it canot give you the exact triangle because Newton does not know that information about your visual mesh.

l34ndr4

15-03-2006 04:15:14

:? well my problem
is that I want to make bullet holes in the texture the bullet hits, so I need the exact point in the body so I can put a decal in it.

do u know how to do this?

walaber

15-03-2006 05:27:58

it is much easier to just stick a small textured plane where the bullet hits! if you want bullets to "attach" to movable objects, you can attach the plane to the same SceneNode as the main object, so that it moves with it.

you would just need to convert the global newton collision point into the local space of the body in question.

you can counter z-depth fighting issues by using the "depth_bias" on the material script.

l34ndr4

15-03-2006 14:13:21


you would just need to convert the global newton collision point into the local space of the body in question.


how do I know the global newton collision point ?
because the rayCast just gives me the BasicRaycastInfo
that has the mBody being hit.

or is this mNormal Vector3???

walaber

15-03-2006 16:01:26

please read the documentation. BasicRaycastInfo gives you the distance along the ray that the collision happened, along with the body, normal, and collision ID of the shape hit.


Ogre::Vector3 globalPt = rayStartPt + ( (rayEndPt - rayStartPt) * info.mDistance);