Sign in to follow this  

bouncing ball using Newton?

Recommended Posts

I'm stumped. What's the trick to making a bouncing ball using Newton? Currently, my ball falls to the floor, rattles a bit, then stops. No real bounce. I set the body elasticity to 1.0. Am I misunderstanding the use of this parameter?

Share this post

Link to post
Share on other sites
Original post by Gowerlypuff
What's the code you're using? We'd probably need to see that before we find out what's going on here.

I'm guessing that he is using the Newton physics engine. Although I was as confused as you at first [smile] EDIT: Sorry, maybe you were aware of that point ^^ I should probably go to sleep...

I've never used the Newton physics engine so can't help you there.

Share this post

Link to post
Share on other sites
Oops. I assumed that Newton was a household name around here. The physics engine I'm using is "Newton Game Dynamics v1.53".

BTW, I was able to solve the bounce problem. If anyone cares, you just need to add a callback something like this:

NewtonMaterialSetCollisionCallback(nWorld, id, id, NULL, NULL, HitMe, NULL);


int _cdecl HitMe (const NewtonMaterial* material, const NewtonContact* contact)
float pos[3];
float norm[3];
float dir0[3];
float dir1[3];
float speed;
float tan_speed0, tan_speed1;

NewtonMaterialGetContactPositionAndNormal(material, pos, norm);
speed = NewtonMaterialGetContactNormalSpeed(material, contact);

speed *= 1.9;

norm[0] *= speed;
norm[1] *= speed;
norm[2] *= speed;

NewtonAddBodyImpulse(rigidBodyBox, norm, pos);

tan_speed0 = NewtonMaterialGetContactTangentSpeed(material, contact, 0);
tan_speed1 = NewtonMaterialGetContactTangentSpeed(material, contact, 1);

NewtonMaterialGetContactTangentDirections(material, dir0, dir1);

tan_speed0 *= -0.5;
tan_speed1 *= -0.5;

dir0[0] *= tan_speed0;
dir0[1] *= tan_speed0;
dir0[2] *= tan_speed0;

dir1[0] *= tan_speed1;
dir1[1] *= tan_speed1;
dir1[2] *= tan_speed1;

NewtonAddBodyImpulse(rigidBodyBox, dir0, pos);
NewtonAddBodyImpulse(rigidBodyBox, dir1, pos);

return 1;

Share this post

Link to post
Share on other sites

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