le3d - LightEngine 3D
A straightforward C++ 3D software engine for real-time graphics
Enumerations | Functions
LeCollisions Namespace Reference

Enumerations

enum  COLLISIONS_RECT_RESULT {
  COLLISIONS_RECT_NO_COL = 0x00, COLLISIONS_RECT_LEFT_COL = 0x01, COLLISIONS_RECT_RIGHT_COL = 0x02, COLLISIONS_RECT_TOP_COL = 0x03,
  COLLISIONS_RECT_BOTTOM_COL = 0x04
}
 Return values of the collideRectRect routine. More...
 
enum  COLLISIONS_SPHERE_RESULT { COLLISIONS_SPHERE_NO_COL = 0x00, COLLISIONS_SPHERE_SURFACE = 0x01 }
 Return values of the collideSphereSphere routine. More...
 
enum  COLLISIONS_BOX_RESULT { COLLISIONS_BOX_NO_COL = 0x00, COLLISIONS_BOX_SIDE = 0x01, COLLISIONS_BOX_EDGE = 0x02, COLLISIONS_BOX_CORNER = 0x03 }
 Return values of the collideSphereBox routine. More...
 
enum  COLLISIONS_MESH_RESULT { COLLISIONS_MESH_NO_COL = 0x00, COLLISIONS_MESH_SIDE = 0x01, COLLISIONS_MESH_EDGE = 0x02 }
 Return values of the collideSphereMesh routine. More...
 
enum  COLLISIONS_BOX_TRACE_RESULT {
  COLLISIONS_BOX_TRACE_NO_INTER = 0x00, COLLISIONS_BOX_TRACE_LEFT = 0x01, COLLISIONS_BOX_TRACE_RIGHT = 0x02, COLLISIONS_BOX_TRACE_BOTTOM = 0x03,
  COLLISIONS_BOX_TRACE_TOP = 0x04, COLLISIONS_BOX_TRACE_BACK = 0x05, COLLISIONS_BOX_TRACE_FRONT = 0x06
}
 Return values of the traceBox routine. More...
 

Functions

int collideRectRect (float &ansX, float &ansY, float srcX, float srcY, float srcW, float srcH, float dstX, float dstY, float dstW, float dstH)
 Compute the intersection between two rectangles. More...
 
int collideSphereSphere (LeVertex &ans, LeVertex &contact, const LeVertex &pos, float srcRadius, float dstRadius)
 Compute the intersection between two spheres. More...
 
int collideSphereBox (LeVertex &ans, LeVertex &contact, const LeVertex &pos, float srcRadius, const LeVertex &dstSize)
 Compute the intersection between a sphere and a box. More...
 
int collideSphereMesh (LeVertex &ans, LeVertex &contact, const LeVertex &pos, float srcRadius, const LeMesh *dstMesh)
 Compute the intersection between a sphere and a mesh. More...
 
int traceSphere (const LeVertex &pos, float radius, const LeVertex &axis, float &distance)
 
int traceBox (const LeVertex &pos, const LeVertex &size, const LeVertex &axis, float &distance)
 Compute the intersection between a casted ray and a box. More...
 
int traceMesh (const LeMesh *mesh, const LeAxis &axis, float &distance)
 Compute the intersection between a casted ray and a mesh. More...
 

Enumeration Type Documentation

Return values of the collideSphereBox routine.

Enumerator
COLLISIONS_BOX_NO_COL 

No collision has occured

COLLISIONS_BOX_SIDE 

Side collision has occured

COLLISIONS_BOX_EDGE 

Edge collision has occured

COLLISIONS_BOX_CORNER 

Corner collision has occured

Return values of the traceBox routine.

Enumerator
COLLISIONS_BOX_TRACE_NO_INTER 

No intersection has occured

COLLISIONS_BOX_TRACE_LEFT 

Intersection with left side (negative x)

COLLISIONS_BOX_TRACE_RIGHT 

Intersection with right side (positive x)

COLLISIONS_BOX_TRACE_BOTTOM 

Intersection with bottom side (negative y)

COLLISIONS_BOX_TRACE_TOP 

Intersection with top side (positive y)

COLLISIONS_BOX_TRACE_BACK 

Intersection with back side (negative z)

COLLISIONS_BOX_TRACE_FRONT 

Intersection with front side (positive z)

Return values of the collideSphereMesh routine.

Enumerator
COLLISIONS_MESH_NO_COL 

No collision has occured

COLLISIONS_MESH_SIDE 

Side collision has occured

COLLISIONS_MESH_EDGE 

Edge collision has occured

Return values of the collideRectRect routine.

Enumerator
COLLISIONS_RECT_NO_COL 

No collision has occured

COLLISIONS_RECT_LEFT_COL 

Left side (negative x) collision has occured

COLLISIONS_RECT_RIGHT_COL 

Right side (positive x) collision has occured

COLLISIONS_RECT_TOP_COL 

Top side (negative y) collision has occured

COLLISIONS_RECT_BOTTOM_COL 

Bottom side (positive y) collision has occured

Return values of the collideSphereSphere routine.

Enumerator
COLLISIONS_SPHERE_NO_COL 

No collision has occured

COLLISIONS_SPHERE_SURFACE 

Surface collision has occured

Function Documentation

int LeCollisions::collideRectRect ( float &  ansX,
float &  ansY,
float  srcX,
float  srcY,
float  srcW,
float  srcH,
float  dstX,
float  dstY,
float  dstW,
float  dstH 
)

Compute the intersection between two rectangles.

Parameters
[out]ansXx coordinate of answer / correction vector
[out]ansYy coordinate of answer / correction vector
[in]srcXx coordinate of source rectangle
[in]srcYy coordinate of source rectangle
[in]srcWwidth of source rectangle
[in]srcHheight of source rectangle
[in]dstXx coordinate of destination rectangle
[in]dstYy coordinate of destination rectangle
[in]dstWwidth of destination rectangle
[in]dstHheight of destination rectangle
Returns
intersection type (see COLLISIONS_RECT_RESULT)
int LeCollisions::collideSphereBox ( LeVertex ans,
LeVertex contact,
const LeVertex pos,
float  srcRadius,
const LeVertex dstSize 
)

Compute the intersection between a sphere and a box.

Parameters
[out]ansanswer / correction vector
[out]contactplace of contact vector
[in]posrelative position of the sphere to the box center
[in]srcRadiusradius of source sphere
[in]dstSizesize of destination box
Returns
place of collision (see COLLISIONS_BOX_RESULT)
int LeCollisions::collideSphereMesh ( LeVertex ans,
LeVertex contact,
const LeVertex pos,
float  srcRadius,
const LeMesh dstMesh 
)

Compute the intersection between a sphere and a mesh.

Parameters
[out]ansanswer / correction vector
[out]contactplace of contact vector
[in]posrelative position of the sphere to the mesh center
[in]srcRadiusradius of source sphere
[in]dstMeshpointer to a destination mesh
Returns
place of collision (see COLLISIONS_MESH_RESULT)
int LeCollisions::collideSphereSphere ( LeVertex ans,
LeVertex contact,
const LeVertex pos,
float  srcRadius,
float  dstRadius 
)

Compute the intersection between two spheres.

Parameters
[out]ansanswer / correction vector
[out]contactplace of contact vector
[in]posrelative position of spheres
[in]srcRadiusradius of source sphere
[in]dstRadiusradius of destination sphere
Returns
place of collision (see COLLISIONS_SPHERE_RESULT)
int LeCollisions::traceBox ( const LeVertex pos,
const LeVertex size,
const LeVertex axis,
float &  distance 
)

Compute the intersection between a casted ray and a box.

Parameters
[in]posposition of the center of the box
[in]sizesize of the box
[in]axiscasted ray axis
[out]distancedistance from axis origin to box surface
Returns
mesh box side or -1 (no intersection) (see)
int LeCollisions::traceMesh ( const LeMesh mesh,
const LeAxis axis,
float &  distance 
)

Compute the intersection between a casted ray and a mesh.

Parameters
[in]meshpointer to a mesh
[in]axiscasted ray axis
[out]distancedistance from axis origin to mesh surface
Returns
mesh triangle index or -1 (no intersection)
int LeCollisions::traceSphere ( const LeVertex pos,
float  radius,
const LeVertex axis,
float &  distance 
)