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
Xypher
Gremlin
Posts: 180
Joined: Tue Jun 29, 2004 1:35 am
Location: Richmond, IN; USA
Contact:

Post by Xypher »

so, the newton wrapper is velcroed to your game? The source would help me infinitely right now as I'm lost as to getting the BSP level geometry from ogre to Newton...if you please :)

Xypher.Orion@Gmail.com =D

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 »

no, not 'velcroed' to my game in any way, it's a wrapper-class for the Newton system. however, I'm only wrapping commands as I need them, so it is by no means complete.

however I'm very happy with the implementation of the TreeCollisions and the ConvexHulls, which work great, even with scaled objects.

my vehicle implementation, while simple, is also working well for me... but for example, I haven't even touched joints, buoyancy, ragdolls, advanced material callbacks yet... :wink:
Go Go Gadget OGRE!!
Image

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

Post by Vanish »

Just to let people know, I am currently working on an addition to monster's ngd Ogrewton wrapper, the ngd::Vehicle. No visible progress yet, but the vehicle physics are really easy to follow for the most part in newton. Just wrapping Ogre::Vector3 to float* etc right now. Hopefully I'll have something like Walaber's soon.

I was very pleased being able to load my racetrack and have the ball run on it first time :)

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

Post by Xypher »

Walaber, my main concern right now is how you got the BSP level geometry and sent it over to Newton. I've been beating my head on the desk for weeks trying to figure out how to even GET the BSP level geometry from the SceneManager. ODE seems to just be able to read (with a little help) SceneQueries, so thats easy. But I don't want to use ODE. So please, enlighten me!!! =)

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

Post by Robomaniac »

meh, the Newton material system is one wierd system :X

I wish he had just made each material independant instead of these group thingees :X
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 »

how you got the BSP level geometry and sent it over to Newton.
I could be wrong, but isn't Walaber using the TreeCollision (i.e. just a Trimesh)?

I think if you want BSP collision you'll have to use the user mesh collision. Newton will call you back when it wants all the polygons in a given region of space, then you can build a list of planes (like the refapp does), then clip these planes to the region of space Newton gave you to create polygons it needs. And you'll have to coerce the ray callback into a ray scene query, which shouldn't be too tricky.
the Newton material system is one wierd system
monster wrote:COMMENTS DELETED
Last edited by monster on Sat Jan 08, 2005 2:11 pm, edited 2 times in total.

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

Post by Robomaniac »

Ok, I think i possibly got the picture, although i keep seeing references to single materials, but i can only seem to find 1 function that deals with them (NewtonMaterialGetGroupID() or smthg. Anyways, off to design my abstraction classes :)
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 »

Do you mean the "const NewtonMaterial* material" that's passed to lots of functions, like NewtonMaterialSetContactSoftness?

That's what I mean, in this context the "Material" is actually an interaction. You set the default values for the interactions with things like NewtonMaterialSetDefaultSoftness where you pass the IDs of the two materials (GroupIDs) and that's what gets applied to the collision when these two materials collide.

Unless you use NewtonMaterialSetCollisionCallback. In which case you get told when a particular interaction (e.g. Rubber/Asphalt) occurs, and there you can use things like NewtonMaterialSetContactSoftness to override the defaults based on (for example) the force that's at the collision which you can get with NewtonMaterialGetContactForce.

The functions that take a "const NewtonMaterial* material" parameter can only be called from your collision callback (NewtonContactBegin, NewtonContactProcess, or NewtonContactEnd) since that's the only place you're given a material handle to play with (i.e. don't save them yourself).

If you need to store more information about a material interaction use the userData to NewtonMaterialSetCollisionCallback to set the data for each interaction. Then in your callback you can use NewtonMaterialGetMaterialPairUserData to retrieve it.

Phew, hope that makes sense!

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

Post by Robomaniac »

hm, was thinking of doing it one way, but i don't think it will work now.

Basically, I want to be able to use materials to detect collision between two entities and do a callback function to the entities.

ex.

Body A is inside of Body B
inject an event that says BodyA collided with BodyB into the event queue, one destined for both BodyA and BodyB
entity parses that event and calls the "OnCollision(Entity* a, Entity* b)"
and handles it

hm... now that i wrote that out, I think i see a way it works :)

Will post when i get it (or not)
phear hingo

My Webpage

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

Post by Robomaniac »

Alright, i the concept down now, however, the material system's generic callbacks are tied to my game engine's event system
phear hingo

My Webpage

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

Post by Vanish »

Well ngd::Vehicle seems to be working, but I have yet to be able to define a vehicle that doesn't do one of the following:

1.) Bounce into oblivion
2.) Tires fall thru ground until car body is sitting on the ground.

But it is working, now all I have to do is figure out how to convert the global coords they give in the tire functions to local (I'm sure monster doe sit somewhere in ngd::body) and I'll be all set. Screens soon.

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 »

Presumably you're doing something like;

Code: Select all

int CALLBACK_NewtonContactBegin(const NewtonMaterial* material, const NewtonBody* body0, const NewtonBody* body1)
{
    PostEvent(EVT_COLLISION,NewtonBodyGetUserData(body0),NewtonBodyGetUserData(body1));
}
Where you've already stored your Entity pointers in your Body's user data pointer?

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

Post by Robomaniac »

ok, i'm generating an event structure as follows:

GenericContactBegin(...): Get the names of the collided bodies, if the one is level geometry, just set the name to NULL

GenericContactProcess(...): Set the inpact and slide speeds, and the contact position

GenericContactEnd(...): Create:

Code: Select all

Core::Gamecore::Get()->GetEntityManager()->GetEventProcessor()->SendEvent(
Core::Event(body1Name, "Physics_System", "Entity_Collision", body2Name));
and the same for the other body if it isn't "NULL"


Then the entity takes that event and calls the OnCollision(Entity* other) and parses as required, ex. for items, it picks the item up, for a player colliding with a trigger, the trigger does its event, etc.

I think this will work, although i still don't know about level data, I will probably just create a generic impact sound for bullets and stuff
and the other collded entity will play its impact sound too.
phear hingo

My Webpage

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

Post by Vanish »

Well everything is working except one little bit. I can't get the graphical wheels to be in the correct position. The only function I find for the tires returns a Matrix in global space, but I need them in local space (relative to the vehicle joint) I tried connecting the tire nodes to root and using the global tire matrix function to see what would happen, and it almost worked, except the tires were noticeably lagged somehow.

This seems like it should be such a trivial thing.

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 wheels should be separate objects to your vehicle, as far as Ogre's concerned, you shouldn't have the wheels connected as child scene nodes to the body. It's Newton that will determine the location of the wheels with respect to the car, not Ogre, so they should all be children of the root scene node and (as you say) you should be using all transformations and orientations in global space.

The only reason I can imagine for there to be a "lag" is if you're not updating your vehicle body and wheels at the same time.

User avatar
Kolobrod
Gnoblar
Posts: 10
Joined: Wed Jul 21, 2004 1:39 pm
Location: Krasnodar, Russia
Contact:

Post by Kolobrod »

I just write a script for 3ds max that can be used to export bodys from scene
This thing can be usefull for level physic geometry definitions (static or dynamic). Loader can be integrated to ode or newton wrapper i think...

Example:
Scene in 3ds max:
http://tool.hotbox.ru/tmp/dc_01.jpg
And in OGRE:
http://tool.hotbox.ru/tmp/dc_03.jpg
http://tool.hotbox.ru/tmp/dc_04.jpg
http://tool.hotbox.ru/tmp/dc_06.jpg

Exports box, sphere and capsule geometry types for now. I crate it to avoid using trimeshes, but they will be supported to if i need it.
Script will be here soon if your like this.

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 »

Cool. What format does it export to? XODE, PSCL, or something else?

User avatar
Kolobrod
Gnoblar
Posts: 10
Joined: Wed Jul 21, 2004 1:39 pm
Location: Krasnodar, Russia
Contact:

Post by Kolobrod »

XML =)
Now it somthing like this:
<body name="string" static="bool" type="Box|Sphere|Capsule" position="x y z" rotation="x y z " size="x y z" />

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 »

Any reason why you chose not to use XODE?
http://tanksoftware.com/xode/

Or PXL?
http://www.physicstools.org/forum1/23.html

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 »

late reply: I'm not using BSP, just a standard .mesh file... although if Ogre provides a way to access the BSP data, you can turn that into faces, and send that to the TreeCollision... I know that there is a demo for the Irrlicht (sp?) engine that showed a bsp working with Newton as a TreeCollision, so I'm sure the same is also possible with Ogre.

if you're curious how I setup the vehicle in my demo, just look at the "simple.vehicle" file, it's a text file that is used to load all of the vehicle settings...
Go Go Gadget OGRE!!
Image

User avatar
Kolobrod
Gnoblar
Posts: 10
Joined: Wed Jul 21, 2004 1:39 pm
Location: Krasnodar, Russia
Contact:

Post by Kolobrod »

It was just a test ... Script very simple and it always can be modiffied. Also and loader.

xode... pxl... i never used this before :)
I look on them!

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

Post by Vanish »

Woohoo, I got it all working now. The lag problem was due to which callback I was syncing with.

Now I can finally work on building engine, transmission, steering, and suspension classes, along with getting that framerate up :P

http://img.photobucket.com/albums/v23/V ... hicle1.png
http://img.photobucket.com/albums/v23/V ... hicle2.png
http://img.photobucket.com/albums/v23/V ... hicle3.png

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 »

very cool to see another vehicle running in Ogre! I'm making slow progress on my project as well... I have a lot of modelling to do though.

I think all of these Newton projects are proof of how solid, and easy to implement the system is 8)
Go Go Gadget OGRE!!
Image

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 »

monster wrote:COMMENTS DELETED
Having said all that, I still think it's a great physics engine, and I really hope it continues to go from strength to strength.
Last edited by monster on Sat Jan 08, 2005 2:12 pm, edited 1 time in total.

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

Post by Robomaniac »

monster: http://newtondynamics.com/forum/viewtopic.php?t=963

that post just completely turned me away from newton. I am now going to use ODE, (novodex is too much $$$ :X).

That entire post is just absurd, look at ogre for instance, its documentation is great AND its free!
phear hingo

My Webpage

Post Reply