Xors3d Engine
Entity collision

Functions

BBDECL void BBCALL xClearCollisions ()
 Clears the collision information list.
BBDECL Entity *BBCALL xCollisionEntity (Entity *entity, int index)
 Returns the other entity involved in a particular collision.
BBDECL float BBCALL xCollisionNX (Entity *entity, int index)
 Returns the x component of the normal of a particular collision.
BBDECL float BBCALL xCollisionNY (Entity *entity, int index)
 Returns the y component of the normal of a particular collision.
BBDECL float BBCALL xCollisionNZ (Entity *entity, int index)
 Returns the z component of the normal of a particular collision.
BBDECL void BBCALL xCollisions (int srcType, int destType, int collideMethod, int response)
 Enables collisions between two different entity types.
BBDECL Surface *BBCALL 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.
BBDECL float BBCALL xCollisionTime (Entity *entity, int index)
 Returns the time taken to calculate a particular collision.
BBDECL int BBCALL 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.
BBDECL float BBCALL xCollisionX (Entity *entity, int index)
 Returns the world x coordinate of a particular collision.
BBDECL float BBCALL xCollisionY (Entity *entity, int index)
 Returns the world y coordinate of a particular collision.
BBDECL float BBCALL xCollisionZ (Entity *entity, int index)
 Returns the world z coordinate of a particular collision.
BBDECL int BBCALL xCountCollisions (Entity *entity)
 Returns how many collisions an entity was involved in during the last xUpdateWorld()
BBDECL void BBCALL xEntityBox (Entity *entity, float x, float y, float z, float width, float height, float depth)
 Sets the dimensions of an entity's collision box.
BBDECL Entity *BBCALL xEntityCollided (Entity *entity, int typeID)
 Returns true if an entity collided with any other entity of the specified type.
BBDECL void BBCALL xEntityPickMode (Entity *entity, int mode, bool obscurer=true, bool recursive=true)
 Sets the pick mode for an entity.
BBDECL void BBCALL xEntityRadius (Entity *entity, float xRadius, float yRadius=0.0f)
 Sets the radius of an entity's collision sphere.
BBDECL void BBCALL 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.
BBDECL void BBCALL xResetEntity (Entity *entity)
 Resets the collision state of an entity.

Function Documentation

BBDECL void BBCALL 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
BBDECL void BBCALL 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.

BBDECL void BBCALL xResetEntity ( Entity *  entity)

Resets the collision state of an entity.

Parameters:
entityEntity handle
BBDECL void BBCALL 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
BBDECL void BBCALL 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
BBDECL void BBCALL 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
BBDECL Entity* BBCALL 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
BBDECL int BBCALL xCountCollisions ( Entity *  entity)

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

Parameters:
entityEntity handle
BBDECL float BBCALL 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
BBDECL float BBCALL 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
BBDECL float BBCALL 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
BBDECL float BBCALL 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
BBDECL float BBCALL 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
BBDECL float BBCALL 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
BBDECL float BBCALL 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
BBDECL Entity* BBCALL 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
BBDECL Surface* BBCALL 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
BBDECL int BBCALL 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
BBDECL void BBCALL 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