Basic collision detection and normals

Started by
1 comment, last by rocklobster 12 years, 8 months ago
[font=arial, verdana, tahoma, sans-serif][size=2]Hi guys,

I've been working on basic collision detection (ball and a plane) and I can get desired results using this formula[/font]

newVelocity = I - (normal * 2 * I.dot( normal )

But this is with a hard coded value for the surface normal. My question is, in a more dynamic setting (say a ball bouncing around a room with a cube floating in the centre) where there will be multiple normals? Do i have to do something like this..

if (collides with back of cube)
normal = (0.0, 0.0, -1.0)
if (collides with bottom of cube)
normal = (0.0, -1.0, 0.0)

etc.

and then use the formula to calculate the angle of reflection?

Thanks for any help

-James
Advertisement
You typically use a scene wide query. eg:

[source]
while(1)
{
Vector3 collisionNormal;
Vector3 collisionPoint;
bool result = getCollisionFromAllObjectsInScene(oldVelocity, oldPosition, collisionNormal, collisionPoint);
if(!result) break;

// resolve collision

// update position and velocity of object
}
[/source]
So once you determine what two objects have collided, you check which normal you need to use for that particular surface?

This topic is closed to new replies.

Advertisement