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.
tylerstreeter
Gnoblar
Posts: 24
Joined: Thu Apr 21, 2005 7:23 pm
Contact:

Post by tylerstreeter »

What facilites do you intend provide in regards of network games/simulation ?

(get pos/quat/accel/vel of all objects, time rewind, make simulation deterministic, etc..)
One of the developers (Alan Fischer) has talked about adding some easy-to-use (but hard-to-implement :)) networking capabilities into OPAL. It's on the long-term todo list, but don't expect it any time soon.
Check this a good addition to your ragdolls : http://www.mmandel.com/gdc
Seems like animation-driven ragdolls are becoming a pretty practical solution. I haven't experimented with this yet, but it should be pretty easy with OPAL. By using a Spring Motor (a simple PD controller that can be used to control position and/or orientation) on each part of the ragdoll, you could simply have the animation sequence drive the desired position/orientation of the Spring Motors.

On a related note, my master's thesis research deals with motor learning for physically-simulated creatures, i.e. another way to drive ragdolls (much more difficult, but hopefully more rewarding). Here's a link to some initial results:

http://www.vrac.iastate.edu/~streeter/avh/avh.html

And, if you haven't heard of Natural Motion's Endorphin software, check it out:

www.naturalmotion.com

User avatar
Bren
Goblin
Posts: 215
Joined: Tue Jul 08, 2003 4:41 pm
Location: 0,0,0
Contact:

Post by Bren »

Hey man, nice work!

I wonder if OPAL has any interfaces for managing different simulation spaces/quads in the ODE sense. If I wanted to subdivide a fairly large simulation, for example.

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

Post by tylerstreeter »

I wonder if OPAL has any interfaces for managing different simulation spaces/quads in the ODE sense. If I wanted to subdivide a fairly large simulation, for example.
You can create multiple simultaneous OPAL Simulators (similar to creating separate ODE worlds, each with their own spaces). Also, you can create multiple Space within a single Simulator.

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

Post by Olex »

You might want to add spaces to the list of your tutorials.
It's nothing hard, but I was expecting opal::Space to be able add objects to itself, but instead you have:

Code: Select all

opal::Simulator::createSpace()
opal::Simulator::createSolid()
opal::Solid::setSpace(Space * newSpace)
Which is fine to me, but many users will not see it the same way right off the start.

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

Post by Olex »

Does OPAL provide a list of objects that need to be updated since last frame?

The sample code does not seem to do that, instead it simply cycles through every shape.

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

Post by tylerstreeter »

Does OPAL provide a list of objects that need to be updated since last frame?

The sample code does not seem to do that, instead it simply cycles through every shape.
OPAL doesn't provide that, but you could do that pretty easily by just checking which objects are sleeping. If a Solid is sleeping (note that static Solids are also defined as sleeping), just make the 'update' function (that updates the Ogre SceneNode) return early.

I added this to my sample app. Thanks for the tip!

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

Post by Olex »

I added this to my sample app. Thanks for the tip!
No problem.

A quick question, though: how do you compile tinyxml as a library under Linux. The package of tinyxml does not provide that for Linux.

I could post that to sourceforge's tinyxml page, but I hoped you would be willing to answer that. (Just trying to get OPAL up and running as fast as I can... :wink: )

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

Post by tylerstreeter »

A quick question, though: how do you compile tinyxml as a library under Linux. The package of tinyxml does not provide that for Linux.

I could post that to sourceforge's tinyxml page, but I hoped you would be willing to answer that. (Just trying to get OPAL up and running as fast as I can... Wink )
Good question. I put an SConstruct for tinyxml in the 'tools' directory. So, if you have scons install, just copy the SConstruct to your tinyxml source directory and type 'scons'.

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

Post by Olex »

I'm trying that...

I have put tinyxml sources and SConscript into the same dir:

Code: Select all

-rw-r--r--  1    379 Apr 18 17:21 SConstruct
-rw-r--r--  1     88 Feb 11 16:40 readme.txt
-rw-r--r--  1   7810 Apr 16 01:30 tinystr.cpp
-rw-r--r--  1   6276 Apr 16 01:30 tinystr.h
-rw-r--r--  1  30022 Apr 16 01:30 tinyxml.cpp
-rw-r--r--  1  49548 Apr 16 01:30 tinyxml.h
-rw-rw-r--  1   1699 Apr 16 01:30 tinyxmlerror.cpp
-rw-r--r--  1  33575 Apr 16 01:30 tinyxmlparser.cpp
but get this error:

Code: Select all

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
-c -o tinystr.o tinystr.cpp
sh: - : invalid option
Usage:  sh [GNU long option] [option] ...
        sh [GNU long option] [option] script-file ...
GNU long options:
        --debug
        ......<cut>......
        --wordexp
Shell options:
        -irsD or -c command or -O shopt_option          (invocation only)
        -abefhkmnptuvxBCHP or -o option
scons: *** [tinystr.o] Error 2
scons: building terminated because of errors.
What could that be?

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

Post by tylerstreeter »

Hmm, it worked for me. Try changing the SConstruct to the following:

import os

sources = Split("""
tinystr.cpp tinyxml.cpp tinyxmlerror.cpp tinyxmlparser.cpp
""")

env = Environment(
ENV = os.environ
)

env.StaticLibrary('tinyxml', sources)

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

Post by Olex »

Thanks! That fixed it. :D

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

Post by Olex »

Sigh... :x

I have run into an infamous NAN problem with ODE. (I think so...)

I have migrated my app to OPAL from OgreRefApp. Under win32 it works like a charm, but under Linux (my primary development environment) it simply misbihaves:

Solid::getPosition() returns some random values: or range: 0...10^6.
I've had similar results before (with home grown ODE wrapper) and was not able to overcome them. Anybody ever had such issues? Is there a pit I felt into that is easy to avoid? :x

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

Post by tylerstreeter »

Solid::getPosition() returns some random values: or range: 0...10^6.
Are you simulating at all before you see this? Can you give more details about what all you do before this happens?

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

Post by Olex »

I'm using sample framework BaseOpalApp which is included with the OPAL source. So, I have added to a test project:
BaseOpalApp.h ExampleApplication.h ExampleFrameListener.h PhysicalCamera.h PhysicalEntity.h TemplateApp.cpp

then in the TemplateApp.cpp, I added the following code to MyApp::createScene() after the line: "// Load models, create physical objects, etc. here."

Code: Select all

String material( "cube.material" );
		{
			String name( "static baba" );
			Solid * s = this->mSimulator->createSolid();
			s->setStatic( true );
			BoxShapeData boxData;
			boxData.dimensions.set( 30, 1, 30 );
			s->addShape( boxData );
			Vector3 geom( 30, 1, 30 );
			PhysicalEntity * stat = createPhysicalEntityBox( name, material, geom, s );
		}
		{
			String name( "fast baba" );
			Solid * s = this->mSimulator->createSolid();
			opal::Matrix44r t;
			t.translate( 0, 10, 0 );
			s->setTransform( t );
			s->setStatic( false );
			BoxShapeData boxData;
			boxData.dimensions.set( 1, 1, 1 );
			s->addShape( boxData );
			Vector3 geom( 1, 1, 1 );
			PhysicalEntity * stat = createPhysicalEntityBox( name, material, geom, s );
		}
The static object does not have any problems. (it's not being updated anyway)
But the dynamic object exhibits issues I have described in my previous post. (NAN values)

Hope this helps clarify the situation.

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

Post by tylerstreeter »

Hmmm... the only thing that looks a little weird is the material name:
String material( "cube.material" );
Is that your material file name? The createPhysicalEntityBox function wants the actual material name within the file. If you look at my 'playpen' example, I use things like "Plastic/Red" which are defined in the basic.material file. So my function call would look like:

createPhysicalEntityBox("object name", "Plastic/Red", boxDimensions, solidPtr);

Do you get any error messages on standard output concerning the material? Maybe memory is getting corrupted somehow.

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

Post by Olex »

:roll: :)
To be honestly, I have commented out the line that sets the material in BaseOpalApp.h. cube.mesh picks up cube.material file just fine without that.

I did turn it back on just now, though. And replaced material line with:

Code: Select all

String material( "1 - Default" );
That works as far as material goes. (it worked the same beforehand)

The problem still stays there, though. And again, the issue only appears under Linux. Windows build (the same code) runs well. I did find some info about this error on ODE mailing list: http://q12.org/pipermail/ode/2004-March/011477.html

But then again, I have downloaded ode-0.5 and its tests work.
:shock:

So I have put its library in place of mine 0.5-r2 (gentoo) and rebuild opal-ode. But all in vain. :x

EDIT: BTW, OgreRefApp worked without NAN issues.

User avatar
epopov
Halfling
Posts: 85
Joined: Tue Jun 10, 2003 2:57 pm
Contact:

Post by epopov »

I don't know Linux, but under Windows, given what you describe, I would suggest to make really sure that the dll you think should be used *really* is the one used.
So in your case, are you really sure that the 'dll' (.so ?) for ODE 0.5 is the one your app really uses ? Even if you copy files in the directory you think is the right one, may be another 'dll' (the old ODE) is used...
Maybe the ODE lib has a function which tells you its version number, so you could check at runtime which 'dll' is loaded ?

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

Post by Olex »

Thanks for the tip.
Unfortunetly, it does not appear to be the problem. I have only one libode.a and only one libopcodes.a and only one libopal-ode.so. (I have scanned the entire system using "locate" under root)

I thought that maybe OGRE and OPAL do not like each other, so I have written this small console app:

Code: Select all

#include <opal/opal.h>

#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
	opal::Simulator * sim = opal::createSimulator();
	opal::Vec3r g( 0.0, -9.81, 0.0 );
	sim->setGravity( g );
	sim->setStepSize( 0.02 );

	opal::Solid * solid = sim->createSolid();

	solid->setLinearDamping( 0.2 );
	opal::Matrix44r transform;
	transform.translate( 1, 10, 1  );
	transform.rotate( 0, 0, 1, 0 );
	solid->setTransform( transform );
	solid->setStatic( false );

	opal::BoxShapeData boxData;
	boxData.dimensions.set( 1.0, 1.0, 1.0 );
	boxData.material.density = 1.0;
	solid->addShape( boxData );

	opal::Point3r pos = solid->getPosition();
	cout << "Before simulation: Solid: x: " << pos[0] << ", y: " << pos[1] << ", z: " << pos[2] << endl;

	for ( int i = 0; i < 10; ++i )
	{
		sim->simulate( 0.03 );

		opal::Point3r pos = solid->getPosition();
		cout << "Step:" << i << ", Solid: x: " << pos[0] << ", y: " << pos[1] << ", z: " << pos[2] << endl;
	}

	sim->destroySolid( solid );
	sim->destroy();

	return 0;
}
And here's what it returns:

Code: Select all

Before simulation: Solid: x: 1, y: 10, z: 1
Step:0, Solid: x: 0, y: 1.875, z: -3.30724e-12
Step:1, Solid: x: 0, y: 1.875, z: 135.494
Step:2, Solid: x: 0, y: 1.875, z: 787.944
Step:3, Solid: x: 0, y: 1.875, z: -2.87156e+17
Step:4, Solid: x: 0, y: 1.875, z: 4.2442e+37
Step:5, Solid: x: 0, y: 1.875, z: 1.46789e+33
Step:6, Solid: x: 0, y: 1.875, z: -2.6234e+07
Step:7, Solid: x: 0, y: 1.875, z: 8.29713e-27
Step:8, Solid: x: 0, y: 1.875, z: -5.97494e+34
Step:9, Solid: x: 0, y: 1.875, z: 1.40738e-27
:?: Maybe it is something with my system...
For example, I need to run:

Code: Select all

libtoolize --copy --force

otherwise ./configure complains. This has never caused a problem on my Gentoo system. But I hope that is where the problems come from. If it is, it will be easy to fix. I'll try on another machine for starters.

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

Post by Olex »

I have tried the above code on another machine, but it did not work.

@ tylerstreeter: Could you describe what Linux environment OPAL has been tested on? automake, autoconf, ode versions and such would be helpful.

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

Post by Olex »

I have reinstalled my Gentoo system from scratch, and I still get the same error.

I'm sorry to say, but OPAL just does not seem to work for me. :(

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

Post by Olex »

Personally, I don't get it. OgreRefApp works just fine (I just tried it), but OPAL has ODE NAN problems. :evil:

Great job with the library, guys, but I won't be joining it just yet.

BTW, are going to add XODE parser along your custom one?

User avatar
regress
Halfling
Posts: 78
Joined: Sat Mar 26, 2005 8:39 pm

Post by regress »

Just a curious question - how does this differ with Moster's gangsta plugin?

I played with the playpen program, was a lot of fun. Congrats on making it this far!
regards

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 »

@olex: Can you guys talk in another thread, please?
Somehow I feel that it is misplaced in a showcase thread. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
zarthrag
Greenskin
Posts: 128
Joined: Sat Jul 24, 2004 9:07 am
Location: Tulsa, Oklahoma

Post by zarthrag »

myak wrote:
tuan kuranes wrote:What facilites do you intend provide in regards of network games/simulation ?
I'm also very interested in this, especially in making simulation deterministic.
I swear to god, I'll rip out my ODE implementation from my engine RIGHT NOW if OPAL is deterministic.

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

Post by Olex »

jacmoe wrote:@olex: Can you guys talk in another thread, please?
Somehow I feel that it is misplaced in a showcase thread. :wink:
Sorry about that. I started to feel that, too. Could you move us to a more opt place? :?

Post Reply