Its been a long time… ( Lots of people shouting at us for going into hibernation :) ).
We can understand how the newbies feel and a lot of them have been asking about Raycast in Physics Engine. The Raycasting discussed below is related to Physics Engine only and not the Raytracing used in 3D Engines.
Raycasting is the mechanism of collision detection with rays. Raycasting can be done against all types of rigid bodies and terrains. There are two methods provided with Director Ageia Engine RayCastAll() and RayCastClosest() .
RayCastAll( ) - Gives a raycast_list of all rigidbodies that are in the path of the ray cast from a origin. In the image shown above,the method would return blue and orange rigid body. The purple and green rigid body would not be in the raycast_list as they donot lie in the path of the cast ray.
Syntax: raycast_list = world.rayCastAll(vector origin, vector direction)
RayCastClosest( ) - This method returns the reference of the closest rigid body or terrain that is found along the ray from the specified origin and specified direction. The method returns ( raycast_list ) the closest rigid body from the origin on the cast ray. With reference to the image above only the blue rigidbody would be returned.
Syntax: raycast_list = world.rayCastClosest(vector origin, vector direction)
The raycast_list ( just a variable name given ) list containing the following information:
- Rigid body / Terrain reference
- Contact Point
- Contact Normal
- Distance of the rigid body or terrain, from the origin of the ray.
Note: The objects that lie in the cast ray and list returned by the method RayCastAll()will not be in a sorted order, hence you will have to sort it yourself. Fixed with D11 HF3 .
Be First To Comment
Related Post
Leave Your Comments Below