Keep in Touch



3D Collision Detection Project

This system is aiming providing interfaces for collision detection.



There are two basic defining the collider of the gameobject, the first one defines how a collider looks like in this library.

class Collider
    Collider(std::vector<Vector3>& i_v);
    Collider(const Collider& i_v);
    Collider(std::string i_path);

    eae6320::cResult InitData(std::string i_path);;
    void UpdateTransformation(eae6320::Math::cMatrix_transformation i_t);
    Vector3 Center();
    bool IsCollided(Collider& i_B);

In addition, according to that a gameobject can have more than one collider, the collider list is be defined as following

class ColliderList
    ColliderList(const Collider& i_c);
    ColliderList(const ColliderList& i_c);

    void ClearAllCollider();
    void AddCollider(Collider i_c);
    size_t GetSize();
    Collider GetColliderByIndex(int i_index);
    bool IsCollided(ColliderList& i_queryColliderList);
    void UpdateTransformation(eae6320::Math::cMatrix_transformation i_t);

Also, I create a collider builder for integrating the collider you want, this is what a collider file would look like

return {
    vertices = {

Something need to be declared, you need to ensure every collider is a polyhedron, because currently the algorithm for collision detection relies on the premise of that every collider is a polyhedron, otherwise, unexpected results maybe happened.

Instruction using library

What you need to do is adding ColliderList or Collider structure to your gameobject or your collider

class GameObject
    eae6320::Graphics::RenderObject m_renderObject;
    eae6320::Physics::sRigidBodyState m_rigidBodyStatue;
    PlutoShe::Physics::ColliderList m_colliders;

In addition, you need to update transformation every time before you using the collider detection. Or you could update the collider transformation at your update function avoiding the extra operations before using the collider.


About creating collider, there are two ways.

First one is what I metioned before, use the collider file to load it.

PlutoShe::Physics::Collider colliderA("data/colliders/sphereOrigin.bin");

Another one is to introduce the vertices of collider directly

std::vector<PlutoShe::Physics::Vector3> vertices;
// After adding neccessary vertices to this array
PlutoShe::Physics::Collider colliderA(vertices)
// or you can directly add to your colliderList

Future development

I am still adding collision response to this library, I will update it after finishing this part.

What I struggled with and what I learned

I mainly struggled with the algorithm to determine two polyhedrons are collided or not. Through learning various collision algorithm, I have deeper understanding toward the 3d math and algebra.

However, after implementing the collision, I was stuck at how colliders react to each other. I Wanted to use Impulse-based contact model, but I found my situations weren't match because there were not only one point collided with two collider. By searching related source, I found a method named Constraint Based Physics. I am still implementing it on my library.

Source Code

Get Source code version 1.0 from here