Open Physics Abstraction Layer sample app

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

No worries :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

laweya
Kobold
Posts: 28
Joined: Mon Jan 17, 2005 3:48 pm
Location: Kenya
Contact:

Great Work

Post by laweya »

I have just spent the whole day playing around with OPAl and having used ogreode and ogrenewt I have to say this is pretty good. Easy to set up, good peformance (I wount be blowing up any towers in my game).

Just a thought though, in 3dsmax, the Z axis points up. I exported a thin box primitive from max to act as a plane/ground and as expected it pointed up instead. Any body having this problem should change the box shape dimensions to reflect this.

Neat trick - lets say you have a car in max, set up the shapes in max to represent it and export the xml. Open up the xml in a text editor, copy the shape nodes from other solid nodes (including their transformation data) into one solid node. Delete the empty solid nodes.
In you code you can now iterate through the shapes and add them to a solid which you will use to represent your mesh.

I've only tried it once and it seems to work fine so test it out first.

I've found my physics engine and I'm sticking to it.

User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus
Contact:

Post by SuprChikn »

I'm tired and I want to go to sleep, so I cant be bothered reading the full 2+ pages of this thread.
Just a quck question about the demo: are the arms and legs of the "human" meant to be able to break off? Its just that while messing around with the demo, I couldnt help but smash the crap outta the guy with the log :twisted:
In doing so, I found that I could get his arms and legs to go flying off into the void. :)

laweya
Kobold
Posts: 28
Joined: Mon Jan 17, 2005 3:48 pm
Location: Kenya
Contact:

Yes its a feature

Post by laweya »

The joints in OPAL can be set to be breakable or unbreakable.

User avatar
Olex
Hobgoblin
Posts: 593
Joined: Fri Apr 08, 2005 6:08 pm
Location: WA, USA

Post by Olex »

Yes, it is a feature to be able to smash them off.

In fact, OPAL provides two types of breakable techniques:
1. once a force large enough is applied to a joint, it breaks
2. once joint has accumulated enough damage, it breaks

tylerstreeter
Gnoblar
Posts: 24
Joined: Thu Apr 21, 2005 7:23 pm
Contact:

Post by tylerstreeter »

I had been getting notifed via email when people replied to this thread, but I think it stopped notifying me when the thread was moved. So I didn't think people were still posting. :)
@ tylerstreeter: Could you describe what Linux environment OPAL has been tested on? automake, autoconf, ode versions and such would be helpful.
Just using SCons on Redhat 8 and Redhat Enterprise 3. Not sure what SCons uses internally. I've only ever used OPAL with ODE 0.5. By the way, currently OPAL uses ODE as a static library, so opal-ode.so/opal-ode.dll do not need an ODE dll/so at runtime.
Personally, I don't get it. OgreRefApp works just fine (I just tried it), but OPAL has ODE NAN problems.
Sorry it's not working for you. I'm hoping someone else will come up with similar problems to help debug the problem. One thing I thought of: in your non-Ogre test app, you use the same variable name for 'pos' twice (once before the for loop, and once inside the for loop). This shouldn't be a problem on most compilers, but maybe it's giving yours trouble. Have you tried using a different name for the second Point3r?
Just a curious question - how does this differ with Moster's gangsta plugin?
Not sure - I don't know much about it. I've only seen the pictures in that thread in the Showcase forum. Do you have more details about its features?
I swear to god, I'll rip out my ODE implementation from my engine RIGHT NOW if OPAL is deterministic.
Supposedly ODE is deterministic (and OPAL uses ODE, in case you didn't know). Lots of people have supposedly gotten repeatable results with ODE. Make sure you're either using world step (i.e. OPAL's highest Simulator accuracy level), or that you hack ODE to reset its random seed. See the ODE wiki for more details on this stuff.
Just a thought though, in 3dsmax, the Z axis points up. I exported a thin box primitive from max to act as a plane/ground and as expected it pointed up instead. Any body having this problem should change the box shape dimensions to reflect this.
I made the exporter maintain the same Y/Z direction as in Max. So, if in Max your box's 'up' direction is in the +Y direction, when you load it into OPAL, +Y will still be its 'up' direction.

Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1
Contact:

Post by Vectrex »

just a small one, are there functions for creating simple auto physics bodies? The demos have a load of code for turning an ogre mesh into a physics body. Since 90% of time you'd be assigning simple primities could the 'makePhysical' (or whatever ;) ) function just accept a primitive type and automatically get the bounding box parameters and assign everything? Would make the demo code look nicer :)

tylerstreeter
Gnoblar
Posts: 24
Joined: Thu Apr 21, 2005 7:23 pm
Contact:

Post by tylerstreeter »

just a small one, are there functions for creating simple auto physics bodies? The demos have a load of code for turning an ogre mesh into a physics body. Since 90% of time you'd be assigning simple primities could the 'makePhysical' (or whatever Wink ) function just accept a primitive type and automatically get the bounding box parameters and assign everything? Would make the demo code look nicer Smile
I'm not exactly sure what you mean. Do you mean taking a mesh and automatically generating the physical representation from its bounding box? In this demo I just used a couple of mesh files (sphere.mesh, box.mesh, etc.), and I scale them depending on what dimensions you pass to the createPhysicalEntity* functions, allowing me to generate a bunch of objects from a few mesh files. With the 'automatic physics generation' method, you would have to store a different mesh files for each size you needed. In 'real' scenarios (i.e. not simple demos), I guess you probably would have a different mesh for each object though. Also, it would be hard to determine the dimensions automatically for capsules just from the loaded mesh.

One sort of related idea (which could be added to OPAL eventually) is to take some arbitrary geometry (e.g. an Ogre mesh), put it into an octree of whatever depth you want, and generate physical box shapes from the filled octree nodes.

So, no, OPAL doesn't currently have any auto Solid generation (other than the 3ds max exporter, which generates/exports all the physical shapes from the visual geometry), but it could in the future. Seems like that would greatly streamline the workflow. Does that answer your question at all? :)

User avatar
Olex
Hobgoblin
Posts: 593
Joined: Fri Apr 08, 2005 6:08 pm
Location: WA, USA

Post by Olex »

tylerstreeter wrote:
Personally, I don't get it. OgreRefApp works just fine (I just tried it), but OPAL has ODE NAN problems.
Sorry it's not working for you. I'm hoping someone else will come up with similar problems to help debug the problem. One thing I thought of: in your non-Ogre test app, you use the same variable name for 'pos' twice (once before the for loop, and once inside the for loop). This shouldn't be a problem on most compilers, but maybe it's giving yours trouble. Have you tried using a different name for the second Point3r?
I'm using GCC 3.4 to compile, so it does not cause any problems. (Thanks for nice ANSI support from open source compiler!) But just in case, I've tried using different names, and that does not resolve the problems.

Personally, I think that the problem comes from some float/double/etc. collision/overflows, who knows what, in the collision system in ODE. The reason I think so is because OgreRefApp works fine, and it uses its own collision generator.

Which brings me to an idea: Is it possible to replace OPAL collision system with OGRE's?

tylerstreeter
Gnoblar
Posts: 24
Joined: Thu Apr 21, 2005 7:23 pm
Contact:

Post by tylerstreeter »

Personally, I think that the problem comes from some float/double/etc. collision/overflows, who knows what, in the collision system in ODE. The reason I think so is because OgreRefApp works fine, and it uses its own collision generator.
Btw, OPAL's reals are typedef'd to float by default, and it's expecting ODE to also use floats for dReals. Are you using floats for everything?
Which brings me to an idea: Is it possible to replace OPAL collision system with OGRE's?
Not currently - OPAL uses ODE's collision detection exclusively. But maybe in the future.

User avatar
Olex
Hobgoblin
Posts: 593
Joined: Fri Apr 08, 2005 6:08 pm
Location: WA, USA

Post by Olex »

tylerstreeter wrote:Btw, OPAL's reals are typedef'd to float by default, and it's expecting ODE to also use floats for dReals. Are you using floats for everything?
Umm... Gentoo seems to compile ODE with doubles, so this could lead to troubles, although, I did try to remove ODE libs, and compile it myself with a single precision, but I was not trying forcefully to figure out if this could resolve the issues.

I will give it a try.

User avatar
Olex
Hobgoblin
Posts: 593
Joined: Fri Apr 08, 2005 6:08 pm
Location: WA, USA

Post by Olex »

HOLY SHISON! :lol: :D :P

It worked! It really did work!

This makes me both mad and happy at the same time! Oooh, come to papa now, OPAL!

Thanks a lot, tylerstreeter!

User avatar
Olex
Hobgoblin
Posts: 593
Joined: Fri Apr 08, 2005 6:08 pm
Location: WA, USA

Post by Olex »

This is really quite a pitfall, I think you should make it clear somewhere in documentation that OPAL's real is float not a double, so that folks don't lose their time, trying to resolve this.

Here's the current output from my code that now uses correctly build ODE with SINGLE PRECISION, guys!

Code: Select all

Before simulation: position: x: 0, y: 0, z: 0
--------------------------------------------------
Step: 0 solid: x: 0, y: -0.0409019, z: 0
Step: 1 solid: x: 0, y: -0.179071, z: 0
Step: 2 solid: x: 0, y: -0.413054, z: 0
Step: 3 solid: x: 0, y: -0.741421, z: 0
Step: 4 solid: x: 0, y: -1.16276, z: 0
Step: 5 solid: x: 0, y: -1.67569, z: 0
Step: 6 solid: x: 0, y: -2.27883, z: 0
Step: 7 solid: x: 0, y: -2.97084, z: 0
Step: 8 solid: x: 0, y: -3.75039, z: 0
Step: 9 solid: x: 0, y: -4.61618, z: 0
Gravity is (0, -9.81, 0)

:P Happy time!

User avatar
bana
Greenskin
Posts: 132
Joined: Mon Aug 02, 2004 7:40 am
Location: Austin, Texas
Contact:

Post by bana »

This might be a bit premature in asking, but what is the next physics library that you are planning to include with Opal? Novodex, Newton etc... I put my vote in for Novodex as it has the PhysX coming out for it ;)

Other than that, great work so far, can't wait to see the blender plugin and whatever you add next :)

And I think that you should create a forum on your website, as currently there is nowhere for a community to form (unless you don't want that, which would be silly).
A proud member of the OpenFrag Coding Team.
http://coolhands.blogspot.com/

tylerstreeter
Gnoblar
Posts: 24
Joined: Thu Apr 21, 2005 7:23 pm
Contact:

Post by tylerstreeter »

This is really quite a pitfall, I think you should make it clear somewhere in documentation that OPAL's real is float not a double, so that folks don't lose their time, trying to resolve this.
I'm glad to hear that things work now. Sorry for all the trouble. I've added a note to the build instructions in the readme file. Thanks for sticking with it!
This might be a bit premature in asking, but what is the next physics library that you are planning to include with Opal? Novodex, Newton etc... I put my vote in for Novodex as it has the PhysX coming out for it Wink
We'd like to stick with cross-platform physics engines. If Ageia decides to support more platforms than Win32 for Novodex, then maybe. Someone from Ageia told me at the GDC this year he had compiled it on Linux but didn't know if they would support it anytime soon.
And I think that you should create a forum on your website, as currently there is nowhere for a community to form (unless you don't want that, which would be silly).
The SourceForge forums are available: http://sourceforge.net/projects/opal

tylerstreeter
Gnoblar
Posts: 24
Joined: Thu Apr 21, 2005 7:23 pm
Contact:

Post by tylerstreeter »

The SourceForge forums are available: http://sourceforge.net/projects/opal
Scratch that. Olex has graciously offered to host an OPAL forum. Here's a link to the new forum:

http://www.speedacm.org/~o0lozi01/forum/index.php

User avatar
Olex
Hobgoblin
Posts: 593
Joined: Fri Apr 08, 2005 6:08 pm
Location: WA, USA

Post by Olex »

tylerstreeter wrote:Scratch that. Olex has graciously offered to host an OPAL forum. Here's a link to the new forum:
http://www.speedacm.org/~o0lozi01/forum/index.php
No problem.

DarkCloud
Gnoblar
Posts: 6
Joined: Mon Feb 21, 2005 10:12 pm
Location: Vilnius, Lithuania

nice OPAL

Post by DarkCloud »

Was looking yesterday for suitable physics abstraction layer for me to start learning physics and i came upon OPAL.
I liked it immediately, and made a cube fall down in less than two hours in my own project. That is good.
Especially i like that OPAL is easy to set up - just new simulator(); and create some solids, then simulate. in addition, easy to separate from the rest of the game.

Will be using OPAL further, so please develope it ;)
Dark

User avatar
Olex
Hobgoblin
Posts: 593
Joined: Fri Apr 08, 2005 6:08 pm
Location: WA, USA

Post by Olex »

OPAL could be even better, if you help it as well. :wink:

For example, you could create XODE parser for it.

User avatar
lhunath
Kobold
Posts: 34
Joined: Mon Apr 04, 2005 10:01 pm

Post by lhunath »

This project looks really promesing, I've just had a look at it, and I must say I really like the way you've managed to bring simplicity to physics while maintaining extensive featuresets.

I've not yet had the time for a deep investigation; and I'm off to fairyland now, but I've got a quick question before I go:
Is it possible to do some collision (using your gravity) with a terrain scene? As I understand it so far, the collision engine works by colliding your own primitives with each other; which wouldn't allow for this. If so, would it be possible to access the collision engine and tell it about the collision after having done the collision checking yourself using Ogre's RaySceneQuerys?

Once more, nice work, and good luck on future development; I'd love to see this one reach a high.

User avatar
Olex
Hobgoblin
Posts: 593
Joined: Fri Apr 08, 2005 6:08 pm
Location: WA, USA

Post by Olex »

You are not limited only to primitives. You can also use Mesh: see documentation here: http://opal.sourceforge.net/api/html/cl ... _data.html

I'm not sure about telling the engine about collisions. Although you could extend the simulator class and override what you need to change. :?

User avatar
lhunath
Kobold
Posts: 34
Joined: Mon Apr 04, 2005 10:01 pm

Post by lhunath »

Hmm, so in theory, if I gave that the mesh of one of those tiles, it should be able to make physical objects collide with it?

Edit./
Hmm; everything's acting weird in Opal =P
And it's really getting on my nerves when things like:

Code: Select all

physical->getSolid()->setEnabled(alive);
assert(physical->getSolid()->isEnabled() == alive);
begin failing.. -_-

User avatar
Olex
Hobgoblin
Posts: 593
Joined: Fri Apr 08, 2005 6:08 pm
Location: WA, USA

Post by Olex »

:? Never had such a problem.

Make sure, though, that you have compiled OPAL with the same precision as ODE. Otherwise, you might experience problems.

User avatar
lhunath
Kobold
Posts: 34
Joined: Mon Apr 04, 2005 10:01 pm

Post by lhunath »

That fixed alot; I'd read it in the installation guide of opal, too; but as ode was an ebuild package in gentoo, I'd given it no considderation. Set to double by default :\ I filed a bug there for now. Thanks for the reminder.

How about the terrain collision through the tiles, though?

User avatar
Olex
Hobgoblin
Posts: 593
Joined: Fri Apr 08, 2005 6:08 pm
Location: WA, USA

Post by Olex »

How about the terrain collision through the tiles, though?
In the end, you will have to provide OPAL with the mesh of the resulting terrain. It does not provide you with such built-in feature as breaking down tiles into triangle mesh. I think OGRE or one of its addons can give you that, though.

Post Reply