Page 1 of 2

New Tutorial: Integration with Newton Game Dynamics

Posted: Fri Mar 12, 2004 2:35 am
by Mercior
http://www.mercior.com/tut-newton.shtml

In this tutorial I explain how to use newton to create realisitic object interaction with a BSP mesh. Enjoy :o

Niko - If you want to add this to the tutorial page you can link to my site or use the plain html included in the example zip. I don't mind :)

Posted: Fri Mar 12, 2004 2:45 am
by deps
Goodie! Going to check it out right now! :)

Posted: Fri Mar 12, 2004 7:57 am
by Ayanami
very very cooool. big thanks!

collision hierarchy?

Posted: Fri Mar 12, 2004 2:16 pm
by Guest
Cool, thanks for the tutorial.

does newton allow to hierarchically define collision geometries? i think that would be a big PLUS for newton game dynamics especially if used with irrlicht. ODE doesn't allow that :(

cheers
gorgon

Posted: Fri Mar 12, 2004 2:19 pm
by Gorgon Zola
Sorry, that guest was me
cheers
gz

Posted: Fri Mar 12, 2004 3:42 pm
by deps
Got some problems with it.
I edited your code to remove the cubes and add a single car instead.
It collides with the map and everything, and i can throw it up in the air with a mouseclick.

But it often sinks through the floor.
I tried to decrease the values to NewtonCreateBox() and it helped a little, but not always.
Got any idea of what i could do to make it stay inside the map at alla times?

Also, when i first loaded the car into irrlicht it was drawn correctly, but after hooking it up to newton it was upside down. So i had to add mat.setRotationDegrees ( vector3df(180,0,0) );
to make it appear correctly.
Could that have someting to do with that fall-through-the-floor problem?

And finaly, thanks for a great tutorial.

Posted: Fri Mar 12, 2004 8:01 pm
by Mercior
Hmmm, when you say "sinks through the floor" do you mean lands on the floor but part of the model is submerged? Or is it just falling through the floor?

If it is landing but submerged, you'll have to increase the size of the newton box to match that of the model.. You could write some code that can determine the size of the newton box based off the irrlicht bounding box perhaps?

As for the model rotation, its just unlucky :) Your choices are either to open the model in a 3D editor and rotate it 180 degrees, or you could store an angle offset along with your newton objects to ensure that they're oriented correctly.

Newton is still on its first release so the SDK currently doesnt have any joints or vehicle code. The new version is due before the end of the month and promises vehicles, joints and some ragdoll-specific stuff :D I'll see about writing up a new tutorial when it comes out.

Posted: Fri Mar 12, 2004 9:09 pm
by deps
I did this to set the size. I think it works, because when the car is upside down and on the floor. The lowest parts of the wheels is visible. :)

Code: Select all

	aabbox3df box = wnode->getTransformedBoundingBox();
	vector3df size = box.MaxEdge - box.MinEdge;

	collision = NewtonCreateBox(nWorld, size.X, size.Y, size.Z, NULL);
And it falls through the floor. completley. and continues into the void.
But sometimes it gets stuck inside the floor, madly twisting and turning until it gets completley through.

And if i throw it, it will most of the time fly through the walls too.


That rotation code i posted earlier works for the rotation issue. Guess i could stick with it. No big problems there.

Posted: Fri Mar 12, 2004 9:14 pm
by Mercior
if its flying through walls and floors then either the box's dimensions are wrong, or its mass / inertia ratio is wrong. Have you altered the mass of the box?

Try printf()ing the size vector to check the values are ok.

Posted: Fri Mar 12, 2004 10:03 pm
by niko
Wow, cool. Yep I'll add it to the tutorial page with the next update, cool :)

Posted: Fri Mar 12, 2004 10:04 pm
by deps
Yes i altered the mass/inertia thingies. Was that bad of me? :)
Actually, i had no idea what that was for, well i know what "mass" is but not the other things, so i tried to randomly increase/decrease it to see if it had any effect. :) (Most of the time i program with an trial-and-error approach, when i dont have any clue what i am doing :D )
I did this because i used different sizes than the cubes had, so i figured i should probably change that one too. :)

What is the correct way to get that ratio? Got anything to do with the size of the object?

And i'm going to check those values.

Posted: Fri Mar 12, 2004 10:16 pm
by Guest
very cool tutorial! thanks! ...i think newton described the cause of your problem here -> http://www.physicsengine.com/forum/view ... =1112#1112

Posted: Fri Mar 12, 2004 10:18 pm
by Mercior
Yes newton explains the inertia matrix values on page 1 of that thread I think :)

Also his latest post explains how to get past a rotation bug in the irrlicht matrix - you might have noticed in my example sometimes cubes on the floor flicker at a different angle for a frame or 2.. I'll update the tutorial later :)

Posted: Fri Mar 12, 2004 11:49 pm
by deps
Goodie! Missed that thread on the newton board. Thanks! :)
All this matrix stuff makes me a bit confused, but 'm going to give it a try and see if i can solve it.

Posted: Mon Mar 15, 2004 1:37 pm
by Peter Müller
Looks great! I'm going to read it throug after meal