• Create Account

Posted 30 April 2013 - 04:13 AM

So firstly, collision detection should have nothing to do with rendering.

Answer to your question is the Separating Axis Theorem (SAT). You can find good explanations on the internet, so I won't describe it.

As I said, you shouldn't "mix" physics with graphics. You should rather have two separate objects which handle rendering and simulation. Each of them should have a matrix (may be 3x3 matrix) and the vertices should be transformed separatly. In psedo-code it might look like this:

class GameObject
{
public:
GraphicsComponent graphics;
PhysicsComponent physics;

void update()
{
physics.update(); // check for collisions
graphics.matrix=physics.matrix; // copy transformation of the physical
// representation to graphical representation
graphics.draw();
}
};


Posted 30 April 2013 - 04:11 AM

So firstly, collision detection should have nothing to do with rendering.

Answer to your question is the Separate Axis Theorem (SAT). You can find good explanations on the internet, so I won't describe it.

As I said, you shouldn't "mix" physics with graphics. You should rather have two separate objects which handle rendering and simulation. Each of them should have a matrix (may be 3x3 matrix) and the vertices should be transformed separatly. In psedo-code it might look like this:

class GameObject
{
public:
GraphicsComponent graphics;
PhysicsComponent physics;

void update()
{
physics.update(); // check for collisions
graphics.matrix=physics.matrix; // copy transformation of the physical
// representation to graphical representation
graphics.draw();
}
};


Posted 30 April 2013 - 04:11 AM

So firstly, collision detection should have nothing to do with rendering.

Answer to your question is the Separate Axis Theorem (SAT). You can find good explanations on the internet, so I won't describe it.

As I said, you shouldn't "mix" physics with graphics. You should rather have two separate objects which handle rendering and simulation. Each of them should have a matrix (may be 3x3 matrix) and the vertices should be transformed separatly. In psedo-code it would look like this:

class GameObject
{
public:
GraphicsComponent graphics;
PhysicsComponent physics;

void update()
{
physics.update(); // check for collisions
graphics.matrix=physics.matrix; // copy transformation of the physical
// representation to graphical representation
graphics.draw();
}
};


PARTNERS