Sign in to follow this  

Basic collision detection and normals

This topic is 2335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[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[/size][/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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

This topic is 2335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this