Xors3d Engine
Raycasting

Functions

int xPhysicsCountHits ()
 Returns the number of hits of the last raycast.
float xPhysicsGetHitDistance (int index=0)
 Returns the distance to the hit point from the ray's start.
Entity * xPhysicsGetHitEntity (int index=0)
 Returns a handle of an entity which was hit by the last raycast.
float xPhysicsGetHitNormalX (int index=0)
 Returns the X component of the hit normal of the last raycast.
float xPhysicsGetHitNormalY (int index=0)
 Returns the Y component of the hit normal of the last raycast.
float xPhysicsGetHitNormalZ (int index=0)
 Returns the Z component of the hit normal of the last raycast.
float xPhysicsGetHitPointX (int index=0)
 Returns global X coordinate of the hit point of the last raycast.
float xPhysicsGetHitPointY (int index=0)
 Returns global Y coordinate of the hit point of the last raycast.
float xPhysicsGetHitPointZ (int index=0)
 Returns global Z coordinate of the hit point of the last raycast.
void xPhysicsRayCast (float fromX, float fromY, float fromZ, float toX, float toY, float toZ, int rcType=0, int rayGroup=0)
 Cast a ray trough the scene and gathers the detailed information on what was hit.

Function Documentation

void xPhysicsRayCast ( float  fromX,
float  fromY,
float  fromZ,
float  toX,
float  toY,
float  toZ,
int  rcType = 0,
int  rayGroup = 0 
)

Cast a ray trough the scene and gathers the detailed information on what was hit.

There are two types of raycasting: single and multiple. The first one reports about the closest hit. The second one reports about all hits. See Physics raycasting modes.
You can ignore hitting of some groups of bodies. See xPhysicsSetRaycastFilter() for more details.

Parameters:
fromXGlobal X coordinate of the ray's start
fromYGlobal Y coordinate of the ray's start
fromZGlobal Z coordinate of the ray's start
toXGlobal X coordinate of the ray's end.
toYGlobal Y coordinate of the ray's end.
toZGlobal Z coordinate of the ray's end.
rcTypeSingle or multiple raycast type. See Physics raycasting modes.
rayGroupGroup of the ray for the filtering.
Entity* xPhysicsGetHitEntity ( int  index = 0)

Returns a handle of an entity which was hit by the last raycast.

Parameters:
indexHit index. Should be in the range [0; xPhysicsCountHits() - 1]. Default value is 0.
float xPhysicsGetHitPointX ( int  index = 0)

Returns global X coordinate of the hit point of the last raycast.

Parameters:
indexHit index. Should be in the range [0; xPhysicsCountHits() - 1]. Default value is 0.
float xPhysicsGetHitPointY ( int  index = 0)

Returns global Y coordinate of the hit point of the last raycast.

Parameters:
indexHit index. Should be in the range [0; xPhysicsCountHits() - 1]. Default value is 0.
float xPhysicsGetHitPointZ ( int  index = 0)

Returns global Z coordinate of the hit point of the last raycast.

Parameters:
indexHit index. Should be in the range [0; xPhysicsCountHits() - 1]. Default value is 0.
float xPhysicsGetHitNormalX ( int  index = 0)

Returns the X component of the hit normal of the last raycast.

Parameters:
indexHit index. Should be in the range [0; xPhysicsCountHits() - 1]. Default value is 0.
float xPhysicsGetHitNormalY ( int  index = 0)

Returns the Y component of the hit normal of the last raycast.

Parameters:
indexHit index. Should be in the range [0; xPhysicsCountHits() - 1]. Default value is 0.
float xPhysicsGetHitNormalZ ( int  index = 0)

Returns the Z component of the hit normal of the last raycast.

Parameters:
indexHit index. Should be in the range [0; xPhysicsCountHits() - 1]. Default value is 0.
float xPhysicsGetHitDistance ( int  index = 0)

Returns the distance to the hit point from the ray's start.

Parameters:
indexHit index. Should be in the range [0; xPhysicsCountHits() - 1]. Default value is 0.
int xPhysicsCountHits ( )

Returns the number of hits of the last raycast.

The returned value is 0 if there were no hits. If there were some hits the returned value is always 1 for the PXRC_SINGLE.