Collision Model, will represent the mesh to be tested for collisions. More...
#include <collision_model_3d.h>
Public Types | |
enum | ModelType { DynamicModel, StaticModel } |
Various model types. More... | |
Public Member Functions | |
CollisionModel3D (ModelType type=StaticModel) | |
~CollisionModel3D () | |
void | setTriangleCount (std::size_t count) |
Optional: Optimization for construction speed. If you know the number of triangles. More... | |
void | addTriangle (float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3) |
Add a triangle to the mesh. More... | |
void | addTriangle (const float v1[3], const float v2[3], const float v3[3]) |
void | finalize () |
All triangles have been added, process model. More... | |
void | setTransform (const float m[16]) |
The current affine matrix for the model. More... | |
bool | modelCollision (ModelCollisionTest *test, int maxProcessingTime=0) const |
Check for collision with another model (do not mix model types) More... | |
bool | rayCollision (RayCollisionTest *test) const |
Returns true if the ray given in world space coordinates intersects with the object. More... | |
bool | sphereCollision (SphereCollisionTest *test) const |
Returns true if the given sphere collides with the model. More... | |
Collision Model, will represent the mesh to be tested for collisions.
It has to be notified of all triangles, via addTriangle().
After all triangles are added, a call to finalize() will process the information and prepare for collision tests.
Call modelCollision(), rayCollision(), sphereCollision() to check for a collision
For each mesh, create a collision model with:
(Shared meshes can use the same model)
Add all the triangles the mesh has to the collision model with:
Then call:
Definition at line 70 of file collision_model_3d.h.
Various model types.
Definition at line 74 of file collision_model_3d.h.
Claudette::CollisionModel3D::CollisionModel3D | ( | ModelType | type = StaticModel | ) |
Claudette::CollisionModel3D::~CollisionModel3D | ( | ) |
void Claudette::CollisionModel3D::addTriangle | ( | float | x1, |
float | y1, | ||
float | z1, | ||
float | x2, | ||
float | y2, | ||
float | z2, | ||
float | x3, | ||
float | y3, | ||
float | z3 | ||
) |
Add a triangle to the mesh.
void Claudette::CollisionModel3D::addTriangle | ( | const float | v1[3], |
const float | v2[3], | ||
const float | v3[3] | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Claudette::CollisionModel3D::finalize | ( | ) |
All triangles have been added, process model.
bool Claudette::CollisionModel3D::modelCollision | ( | ModelCollisionTest * | test, |
int | maxProcessingTime = 0 |
||
) | const |
Check for collision with another model (do not mix model types)
test | the test object for mesh/mesh collisions |
maxProcessingTime | determines the maximum time in milliseconds to check for collision. If a rejection is not found by that time, the function will return true. |
bool Claudette::CollisionModel3D::rayCollision | ( | RayCollisionTest * | test | ) | const |
Returns true if the ray given in world space coordinates intersects with the object.
void Claudette::CollisionModel3D::setTransform | ( | const float | m[16] | ) |
The current affine matrix for the model.
Matrix format is column-major order :
void Claudette::CollisionModel3D::setTriangleCount | ( | std::size_t | count | ) |
Optional: Optimization for construction speed. If you know the number of triangles.
bool Claudette::CollisionModel3D::sphereCollision | ( | SphereCollisionTest * | test | ) | const |
Returns true if the given sphere collides with the model.