New Tutorial: Integration with Newton Game Dynamics

A forum to store posts deemed exceptionally wise and useful
Mercior
Posts: 100
Joined: Tue Feb 24, 2004 1:53 am
Location: UK
Contact:

New Tutorial: Integration with Newton Game Dynamics

Post 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 :)
deps
Posts: 115
Joined: Sat Jan 10, 2004 5:22 pm
Location: Tranås, Sweden

Post by deps »

Goodie! Going to check it out right now! :)
Ayanami
Posts: 24
Joined: Wed Jan 14, 2004 1:30 pm

Post by Ayanami »

very very cooool. big thanks!
Guest

collision hierarchy?

Post 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
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

Post by Gorgon Zola »

Sorry, that guest was me
cheers
gz
deps
Posts: 115
Joined: Sat Jan 10, 2004 5:22 pm
Location: Tranås, Sweden

Post 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.
Mercior
Posts: 100
Joined: Tue Feb 24, 2004 1:53 am
Location: UK
Contact:

Post 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.
deps
Posts: 115
Joined: Sat Jan 10, 2004 5:22 pm
Location: Tranås, Sweden

Post 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.
Mercior
Posts: 100
Joined: Tue Feb 24, 2004 1:53 am
Location: UK
Contact:

Post 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.
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Wow, cool. Yep I'll add it to the tutorial page with the next update, cool :)
deps
Posts: 115
Joined: Sat Jan 10, 2004 5:22 pm
Location: Tranås, Sweden

Post 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.
Guest

Post by Guest »

very cool tutorial! thanks! ...i think newton described the cause of your problem here -> http://www.physicsengine.com/forum/view ... =1112#1112
Mercior
Posts: 100
Joined: Tue Feb 24, 2004 1:53 am
Location: UK
Contact:

Post 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 :)
deps
Posts: 115
Joined: Sat Jan 10, 2004 5:22 pm
Location: Tranås, Sweden

Post 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.
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post by Peter Müller »

Looks great! I'm going to read it throug after meal
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
Post Reply