Xors3d Engine
Entity collision

Functions

void xClearCollisions ()
 Clears the collision information list.
Entity * xCollisionEntity (Entity *entity, int index)
 Returns the other entity involved in a particular collision.
float xCollisionNX (Entity *entity, int index)
 Returns the x component of the normal of a particular collision.
float xCollisionNY (Entity *entity, int index)
 Returns the y component of the normal of a particular collision.
float xCollisionNZ (Entity *entity, int index)
 Returns the z component of the normal of a particular collision.
void xCollisions (int srcType, int destType, int collideMethod, int response)
 Enables collisions between two different entity types.
Surface * xCollisionSurface (Entity *entity, int index)
 Returns the handle of the surface belonging to the specified entity that was closest to the point of a particular collision.
float xCollisionTime (Entity *entity, int index)
 Returns the time taken to calculate a particular collision.
int xCollisionTriangle (Entity *entity, int index)
 Returns the index number of the triangle belonging to the specified entity that was closest to the point of a particular collision.
float xCollisionX (Entity *entity, int index)
 Returns the world x coordinate of a particular collision.
float xCollisionY (Entity *entity, int index)
 Returns the world y coordinate of a particular collision.
float xCollisionZ (Entity *entity, int index)
 Returns the world z coordinate of a particular collision.
int xCountCollisions (Entity *entity)
 Returns how many collisions an entity was involved in during the last xUpdateWorld()
void xEntityBox (Entity *entity, float x, float y, float z, float width, float height, float depth)
 Sets the dimensions of an entity's collision box.
Entity * xEntityCollided (Entity *entity, int typeID)
 Returns true if an entity collided with any other entity of the specified type.
void xEntityPickMode (Entity *entity, int mode, bool obscurer=true, bool recursive=true)
 Sets the pick mode for an entity.
void xEntityRadius (Entity *entity, float xRadius, float yRadius=0.0f)
 Sets the radius of an entity's collision sphere.
void xEntityType (Entity *entity, int typeID, bool recurse=false)
 Sets the collision type for an entity. A collision type value of 0 indicates that no collision checking will occur with that entity. A collision value of [1; 999] will mean collision checking will occur.
void xResetEntity (Entity *entity)
 Resets the collision state of an entity.

Function Documentation

void xCollisions ( int  srcType,
int  destType,
int  collideMethod,
int  response 
)

Enables collisions between two different entity types.

Entity types are just numbers you assign to an entity using xEntityType(). Then uses the entity types to check for collisions between all the entities that have those entity types. Where any ways of checking for collisions, as denoted by the method parameter. However, collision checking is always ellipsoid to something. In order to know what size a source entity is, you must first assign an entity radius to all source entities using xEntityRadius(). In the case of collision detection method SPHERETOSPHERE being selected, then the destination entities concerned will need to have an xEntityRadius() assigned to them too. In the case of method SPHERETOBOX being selected, then the destination entities will need to have an xEntityBox() assigned to them. Method SPHERETOTRIMESH requires nothing to be assigned to the destination entities. Engine not only check for collisions, but it acts upon them when it detects them too, as denoted by the response parameter. You have three options in this situation. You can either choose to make the source entity stop, slide or only slide upwards. All collision checking occurs, and collision responses are acted out, when xUpdateWorld() is called. Finally, every time the xCollisions() command is used, collision information is added to the collision information list. This can be cleared at any time using the xClearCollisions() command.

Parameters:
srcTypeEntity type to be checked for collisions
destTypeEntity type to be collided with
collideMethodCollision detection method. See 'Collision types' for more information
responseWhat the source entity does when a collision occurs. See 'Response types' for more information
void xClearCollisions ( )

Clears the collision information list.

Whenever you use the Collisions command to enable collisions between two different entity types, information is added to the collision list. This command clears that list, so that no collisions will be detected until the Collisions command is used again.

void xResetEntity ( Entity *  entity)

Resets the collision state of an entity.

Parameters:
entityEntity handle
void xEntityRadius ( Entity *  entity,
float  xRadius,
float  yRadius = 0.0f 
)

Sets the radius of an entity's collision sphere.

An entity radius should be set for all entities involved in spherical collisions, which is all source entities (as collisions are always sphere-to-something), and whatever destination entities are involved in sphere-to-sphere collisions

Parameters:
entityEntity handle
xRadiusx radius of entity's collision sphere
yRadiusy radius of entity's collision sphere
void xEntityBox ( Entity *  entity,
float  x,
float  y,
float  z,
float  width,
float  height,
float  depth 
)

Sets the dimensions of an entity's collision box.

Parameters:
entityEntity handle
xx position of entity's collision box
yx position of entity's collision box
zx position of entity's collision box
widthWidth of entity's collision box
heightHeight of entity's collision box
depthDepth of entity's collision box
void xEntityType ( Entity *  entity,
int  typeID,
bool  recurse = false 
)

Sets the collision type for an entity. A collision type value of 0 indicates that no collision checking will occur with that entity. A collision value of [1; 999] will mean collision checking will occur.

Parameters:
entityEntity handle
typeIDCollision type of entity. Must be in the range [0; 999]
recurseTrue to apply collision type to entity's children
Entity* xEntityCollided ( Entity *  entity,
int  typeID 
)

Returns true if an entity collided with any other entity of the specified type.

Parameters:
entityEntity handle
typeIDType of entity
int xCountCollisions ( Entity *  entity)

Returns how many collisions an entity was involved in during the last xUpdateWorld()

Parameters:
entityEntity handle
float xCollisionX ( Entity *  entity,
int  index 
)

Returns the world x coordinate of a particular collision.

Index should be in the range [0; xCountCollisions(entity) - 1]

Parameters:
entityEntity handle
indexIndex of collision
float xCollisionY ( Entity *  entity,
int  index 
)

Returns the world y coordinate of a particular collision.

Index should be in the range [0; xCountCollisions(entity) - 1]

Parameters:
entityEntity handle
indexIndex of collision
float xCollisionZ ( Entity *  entity,
int  index 
)

Returns the world z coordinate of a particular collision.

Index should be in the range [0; xCountCollisions(entity) - 1]

Parameters:
entityEntity handle
indexIndex of collision
float xCollisionNX ( Entity *  entity,
int  index 
)

Returns the x component of the normal of a particular collision.

Index should be in the range [0; xCountCollisions(entity) - 1]

Parameters:
entityEntity handle
indexIndex of collision
float xCollisionNY ( Entity *  entity,
int  index 
)

Returns the y component of the normal of a particular collision.

Index should be in the range [0; xCountCollisions(entity) - 1]

Parameters:
entityEntity handle
indexIndex of collision
float xCollisionNZ ( Entity *  entity,
int  index 
)

Returns the z component of the normal of a particular collision.

Index should be in the range [0; xCountCollisions(entity) - 1]

Parameters:
entityEntity handle
indexIndex of collision
float xCollisionTime ( Entity *  entity,
int  index 
)

Returns the time taken to calculate a particular collision.

Index should be in the range [0; xCountCollisions(entity) - 1]

Parameters:
entityEntity handle
indexIndex of collision
Entity* xCollisionEntity ( Entity *  entity,
int  index 
)

Returns the other entity involved in a particular collision.

Index should be in the range [0; xCountCollisions(entity) - 1]

Parameters:
entityEntity handle
indexIndex of collision
Surface* xCollisionSurface ( Entity *  entity,
int  index 
)

Returns the handle of the surface belonging to the specified entity that was closest to the point of a particular collision.

Index should be in the range [0; xCountCollisions(entity) - 1]

Parameters:
entityEntity handle
indexIndex of collision
int xCollisionTriangle ( Entity *  entity,
int  index 
)

Returns the index number of the triangle belonging to the specified entity that was closest to the point of a particular collision.

Index should be in the range [0; xCountCollisions(entity) - 1]

Parameters:
entityEntity handle
indexIndex of collision
void xEntityPickMode ( Entity *  entity,
int  mode,
bool  obscurer = true,
bool  recursive = true 
)

Sets the pick mode for an entity.

Parameters:
entityEntity handle
modeEntity picking mode. See 'Picking types' for more infromation
obscurerTrue to determine that the entity 'obscures' other entities during an xEntityVisible() call.
recursivePick mode will automatically applied to all entity childs