Xors3d Engine
Raycasting

Functions

BBDECL int BBCALL xPhysicsCountHits ()
 Returns the number of hits of the last raycast.
BBDECL float BBCALL xPhysicsGetHitDistance (int index=0)
 Returns the distance to the hit point from the ray's start.
BBDECL Entity *BBCALL xPhysicsGetHitEntity (int index=0)
 Returns a handle of an entity which was hit by the last raycast.
BBDECL float BBCALL xPhysicsGetHitNormalX (int index=0)
 Returns the X component of the hit normal of the last raycast.
BBDECL float BBCALL xPhysicsGetHitNormalY (int index=0)
 Returns the Y component of the hit normal of the last raycast.
BBDECL float BBCALL xPhysicsGetHitNormalZ (int index=0)
 Returns the Z component of the hit normal of the last raycast.
BBDECL float BBCALL xPhysicsGetHitPointX (int index=0)
 Returns global X coordinate of the hit point of the last raycast.
BBDECL float BBCALL xPhysicsGetHitPointY (int index=0)
 Returns global Y coordinate of the hit point of the last raycast.
BBDECL float BBCALL xPhysicsGetHitPointZ (int index=0)
 Returns global Z coordinate of the hit point of the last raycast.
BBDECL void BBCALL 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

BBDECL void BBCALL 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.
BBDECL Entity* BBCALL 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.
BBDECL float BBCALL 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.
BBDECL float BBCALL 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.
BBDECL float BBCALL 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.
BBDECL float BBCALL 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.
BBDECL float BBCALL 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.
BBDECL float BBCALL 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.
BBDECL float BBCALL 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.
BBDECL int BBCALL 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.