And another one! Physics engine, that is!

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

Wow, lots of people integrating Newton into their projects :D :D

about the slowdown: you essentially have a stack of 300 boxes there... that's an extremely taxing thing to compute! Newton has a different solver than other engines. it doesn't have any "shortcuts". anyway, that means that it's not particurlary fast at calculating large stacks of objects, which are basically just used in demos anyway.. you wouldn't want something like that in a game enviornment anyway, considering you'd also have more graphics, AI, etc.
Go Go Gadget OGRE!!
Image

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

The amount of collision links/joints must be enormous for 300 boxes, I think 7 fps is good performance given the circumstances :)
Probably the physics engine runs into some kind of autodisable after a while when the stack has stabilised, thus FPS goes up.

elvencode
Gnoblar
Posts: 24
Joined: Fri Sep 03, 2004 1:29 pm
Location: Italy

Post by elvencode »

what kind of logic is better for handling collision with the naturescenemanager terrain? i'm trying to create a collision body (with treecollider) for every terrain LOD patch and enable/disable collision at runtime for right/wrong patch.
Is there a better way to simplify that thing? :wink:

User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

look at the Newton samples, there is an example of a heightmap-based collision that doesn't use TreeCollisions. it's very fast, and takes basically no extra memory, whereas making a TreeCollision object for every piece of terrain would require a LOT of memory. however if you want to make a TreeCollision, I would suggest only using the highest LOD level, because most active objects will probably be near the camera, and thus should react to the terrain realistically...


on a side thought, using the Heightmap collision system, you could probably get Newton working with the Paging Landscape scene manager as well!

I've personally not yet attempted to get this to work with Ogre, but I'm certain it's possible, assuming you can access the heightmap data.

p.s. my vehicle demo is coming along nicely, I finally got texture shadows working yesterday :D
Go Go Gadget OGRE!!
Image

User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

OgreNewt Vehicle demo

this is a WIP demo of my OgreNewt vehicle... using Newton for the vehicle dynamics. there is still a LOT to be adjusted, but I think it runs alright!

Image
Image

DOWNLOAD LINK

CONTROLS:
W S A D - acceleration / steering
Q Z shift up/down
SPACE BAR parking break
Go Go Gadget OGRE!!
Image

User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

Could you zip up your stl-port dll's and upload them too?
phear hingo

My Webpage

User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

didn't realize those would be necessary too...

I'll do that and re-upload...[edit]DONE[/edit]
Go Go Gadget OGRE!!
Image

User avatar
Sputnick
Greenskin
Posts: 110
Joined: Wed Sep 08, 2004 11:49 pm
Location: Lausanne, Switzerland

Post by Sputnick »

Very nice.

There some parts I don't understand:

1) When you try to climb the slope, you are often blocked at 1000 RPM. This correspond to 200 engine torque and 345 wheel torque, independently in which gear you're in. I would expect to get lot more torque at wheels in 1st gear than in 6th, in fact 5.7 time more as it is the reduction ratio from 6 to 1. Same thing for rear gear where you should get even more wheel torque.

2) It is probably coming from the engine toque curve, but in 1st gear, if you stop in the slope, you don't have enough power to climb again and you stay stucked at 1000 RPM. On the other hand, with a little speed, the engine gets to high RPM very fast. 200 seems to low at 1000 RPM.

3) The car seems to so light when it rolls and bounces and so heavy when it tries to climb the slope.

All these might come from my configuration as I just tried it on my laptop at work.

A few more question, is it front, rear or 4x4 wheel drive ?
How often is runing the Newton loop compared to the rendering one ?

- Sput

User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

the car is rear-wheel-drive.

Newton is being called once per loop.


all of those are issues with adjusting the vehicle settings... I'm glad there weren't any other big issues :D

right now, the RPM is set to never go lower than 1000rpm... which needs some adjusting! I think the way I'm limiting that is causing the problem. if you get it moving just a little, you can see that the gears produce very different torque... I'll continue working on the settings.

p.s. by editing the "smart.vehicle" file, you can change nearly all of the various settings for the vehicle, including the size/mass/suspenstion settings position of the tires, the engine power curve, etc. you can even make the car 4WD, or have 4-wheel-steering, etc.
Go Go Gadget OGRE!!
Image

stodge
Goblin
Posts: 217
Joined: Thu Oct 24, 2002 4:12 am
x 1
Contact:

Post by stodge »

Wow, that's cool. It seems odd that such a tiny car can rev to 7000RPM though.

User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

Are any of these updated bindings available for downlaod?
phear hingo

My Webpage

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Nice work, feels very solid although the suspension is a bit too spongy I think, but that's just parameter tweaking. Nice touch that you rendered an environment map from the level :)

User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

thanks for the replies!

I definately need to do some more tweaking on the suspension settings... as for the 7000rpm thing, that's just an issue of adjusting the power curve of the car. right now I have it hard-coded that all cars have a power curve defined between 1000-7000 rpm, and the engine uses linear-interpolation to get the engine torque each loop. by making the peak at a lowe rpm, I can make the engine "max out" at say 5000rpm or so. also the transmission is probably a bit unrealistic for such a tiny car as well.

I'm now modelling some other cars, working on a Ford Mustang right now...
SCREENSHOT HERE :D


p.s. the environment map was really easy using Gile[s] (and the exporter I'm working on) :D
Go Go Gadget OGRE!!
Image

User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

walaber or Monster: care to donate your source? :)
phear hingo

My Webpage

User avatar
monster
OGRE Community Helper
OGRE Community Helper
Posts: 1098
Joined: Mon Sep 22, 2003 2:40 am
Location: Melbourne, Australia
Contact:

Post by monster »

Your wish is my command;
monster wrote:COMMENTS DELETED
As the instructions and the News item says, it's unlikely that I'll be developing this wrapper further. Hopefully I'll be able to get an ODF wrapper working for Ogre and then create an OpenPhysics interface for Newton.
stodge wrote:It seems odd that such a tiny car can rev to 7000RPM though.
How so? Small engines tend to rev much higher than big engines. The 3 cylinder turbo-charged engine in this thing (it's like a little Smart car, isn't it?) would easily pull 7000rpm, the red-line would probably be more like 8500-9000, motorbikes rev to like 15,000 whilst big 'ol V8s wouldn't want to go much above maybe 5000. Or are you saying that 7000 isn't high enough?

Nice demo by the way walaber! If you find any of my code useful then feel free to make use of it.

Oh, and thanks again to Sascha Willems for permission to use the 'ramps' mesh.
Last edited by monster on Sat Jan 08, 2005 2:09 pm, edited 1 time in total.

User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

/me thanks you very much :)
phear hingo

My Webpage

User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

Monster - thanks for the comments, yes the car is a "Smart". I'm glad you recognized it! I'll continue to update the car settings, and eventually release a mini-game based on it.

very cool to see your source, unfortunately I'm leaving for a new years trip today, so I won't have a chance to look at it for a while.

my code is probably much simpler, but I'm happy with it so far...

once I release my mini-game, I'll release it's source as well.... with perhaps a simple tutorial explaining how to get Ogre and Newton to be friends :D

I already have lots of ideas for other physics-based games... just no time to implement them :?

take it easy and Happy New Year everyone!
Go Go Gadget OGRE!!
Image

User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

Well, monster, i downloaded Ogrewton, but its a little complex for my own tastes, so i'm trying my hand at my own uber simple wrapper :)

Anyway, i'm having trouble with box stacking:

Image

As you can see, the boxes don't seem to want to have the right bounds.

Any ideas?

The Pertinant Code:

Code: Select all

m_Collision = NewtonCreateBox(m_NewtonWorld, dimensions.x, dimensions.y, dimensions.z, NULL);
That creates the box primative

Code: Select all

Ogre::Vector3 aabb = *(m_Entity->getBoundingBox().getAllCorners());
m_Body = new NewtOgre::Body(m_Node, aabb, 5.0f);
that code is what i use to initialize the body on my entity

As you can see, it collides with the floor right (although every now and then one falls through, still need to get to that.

Any ideas on what i could fix to get this workign? Or more info if needed.

Thx, Robo

[EDIT]
Thanks to monster for the floor texture and various bits and bobs of code i mercilessly stole from him :)
phear hingo

My Webpage

User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

Fixed my problem, i needed to corret my bounds math, getAllCorners doesn't return the width, height, and depth :P

All fixed now :P
:

Image

All Better :P

Gonna do ragdolls, bouyancy, and trimeshes, and the basics are done :)
phear hingo

My Webpage

User avatar
monster
OGRE Community Helper
OGRE Community Helper
Posts: 1098
Joined: Mon Sep 22, 2003 2:40 am
Location: Melbourne, Australia
Contact:

Post by monster »

Well, monster, i downloaded Ogrewton, but its a little complex for my own tastes
Yeah, the code behind it's reasonably "interesting" but the interface is almost exactly equivalent to the standard Newton one.
Any ideas?

Nope, none!
;)

You realise that you're displaying the AABB, rather than the actual oriented bounds of the boxes, yes? (Ogrewton will display the 'true' collision geometries for you, if you like)

Also, are your box meshes centered about the origin, 'cos that's where the collision proxy will be (by default).

Apart from that, trace through your code to make sure the NewtonCreateBox call is being given the correct dimensions.

I've never seen any objects fall through any other objects in Newton, are you using a big box for your floor or a tree collision? I've heard it said that the optimisation of the tree collision mesh can 'lose' triangles, but I've never seen that myself.

[edit]D'oh, you fixed it before I could post![/edit]

User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

NewtOgre is coming together nicely, in a small lite package, that imho is very easy to use :)

2 main classes so far (with the Debug_Lines class ripped straight from Ogrewton ;) (i give u credit in the source monster)).

I still need to figure out a better way to see if i can autogenerate the bodies from the bounding boxes, as right now on certain meshes (including crate.mesh), i'm getting a "buffer" of a few units on the outside of the crate (can this be changed in the mesh, or is it autogened by the entity?)

Expect some more updates soon ;)

[edit]
Newton is very stable for box stacking:

http://centaurforce.sourceforge.net/100boxes.jpg

100 boxes stacked on each other :)
Last edited by Robomaniac on Thu Dec 30, 2004 8:55 am, edited 1 time in total.
phear hingo

My Webpage

User avatar
monster
OGRE Community Helper
OGRE Community Helper
Posts: 1098
Joined: Mon Sep 22, 2003 2:40 am
Location: Melbourne, Australia
Contact:

Post by monster »

...i'm getting a "buffer" of a few units on the outside of the crate (can this be changed in the mesh, or is it autogened by the entity?)
It's baked into the Mesh when the creator set the bounds with _setBounds(const AxisAlignedBox &bounds, bool pad=true).

But you can't tell from the mesh whether or not the bounds were padded when set, or not. It's your exporter that sets the bounds on your exported meshes, so only that will know whether or not the bounds were padded. The Ac3d exporter, for example, doesn't pad the bounding box so it should fit snugly.

The only reliable way to get the bounds is to calculate them yourself from the vertex buffer, like OgreOde does.

User avatar
Xypher
Gremlin
Posts: 180
Joined: Tue Jun 29, 2004 1:35 am
Location: Richmond, IN; USA
Contact:

Post by Xypher »

Those demos look great Walaber! Any estimate on a release for the rest of us to use? I'm sitting on a game right now, and trying to figure out Newton, but the going is slow, the docs are a little disappointing...

User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

well.. there's nothing really to "release".. but with my mini-game, I'll include the source, maybe some people will find it useful...

I have to do a bit of modelling now before I can go much farther though...

robomaniac- looking great!! I'd be interested to see if you get ragdolls working, I'm not yet familiar enough with Ogre to try! 8)
Go Go Gadget OGRE!!
Image

Vanish
Gnoblar
Posts: 16
Joined: Thu Dec 23, 2004 6:18 pm
Contact:

Post by Vanish »

Great job on those tuts monster. I got Ogre+Newton working in a snap with your wrapper.

Post Reply