Game Development Community

dev|Pro Game Development Curriculum

ODEScript Physics

by Gary "ChunkyKs" Briggs · 12/08/2006 (10:29 am) · 106 comments

Download Code File

ODEScript
The Torque C++ modification

This code is an implementation of the ODE API, making it available to torquescript.

As a whole, the API is a "t" [for Torque] prefix on the normal ODE objects, and converted to think in terms of torque and objects rather than functions;

In C:
dBodyID b = dBodyCreate(world);
dBodySetLinearVel(b, x, y, z);

In TorqueScript:
datablock tdBodyData(bodydb) { foo="bar"; }; // foo="bar" is ignored
$b = new tdBody() { worldsim = $odeworld; datablock = bodydb; } ;
$b.SetLinearVel(x,y,z); // C Style
OR
$b.SetLinearVel("x y z"); // TorqueScript Style
Note that both calling styles are supported.


Build Instructions:

1) Edit shapeBase.h, and find this [around like 70 or so]:
friend class ShapeBase;
friend class Vehicle;
and add:
friend class ODEShape;
2) Add all the .cc/.h files in odescript/ to your build, and remember to link with ODE.
3) If you want projectiles to collide with ODEShapes, you'll need to edit game/projectile.cc and add "StaticShapeObjectType |" to your Projectile::csmStaticCollisionMask.

For more detailed instructions for each platform, check buildinstructions.lyx in odescript/.


Thanks to Ray "Noolness" Gebhardt for all his Torque help, including specifically, writing ExampleGameBase and ExampleCollider, from which all my objects derive.


ODERocks
The Torquescript demo of ODEScript

This is a mod for TGE, that should be run with starter.fps or similar, once you have ODEScript [the c++ source modification] built into your Torque install. Run the game with "-mod oderocks" on the command line

Once you're in-game, hold down the C or V button to see a small UI of physics buttons.

This isn't really anything exciting, it just serves to demo some of the objects in ODEScript, and has been used extensively by me during development


Here's a few videos of what it looks like in action:
First Demo [basic chain, single bodies]: youtube.com/watch?v=cA-ncyU51G8
Second Demo ["ragdolls", buoyancy]: youtube.com/watch?v=gjEeN5er6aM
Third Demo [Juggling, Inverse Kinematics]: www.youtube.com/watch?v=PEe55nibKHA

Chunky (-;

icculus.org/~chunky/
Page «Previous 1 2 3 4 5 6 Last »
#1
12/02/2006 (11:01 pm)
You Rock Gary!!
#2
12/04/2006 (11:58 am)
If you want to see an example of what this can do, check out
Youtube: youtube.com/watch?v=cA-ncyU51G8
Or a higher resolution quicktime movie: chunky.megastep.org/ODEScriptDemo.mov [43M]

Please refer to these videos if you're clicking buttons but stuff isn't being added to the simulations :-)

Gary (-;
#3
12/05/2006 (10:17 am)
Hey guys, sorry for the newbie question but im trying to compile this and i`m getting a lot of link errors.

I`ve added the ODE lib and include folders in tools->Options->Directories. I have also added ode.lib to "additional dependences" under the project settings.

What i`m missing?
#4
12/05/2006 (11:07 am)
What are your link errors?

If they're all dBodyBlah dWorldBlah, you're probably not *actually* linking with ode.lib. I don't know enough about windows compiler witchcraft to tell you how to make it work, this thread may provide useful information.

Gary (-;
#5
12/05/2006 (12:06 pm)
I just fixed that. I was forgetting to setup the release build too. Now let`s test that =p
#6
12/05/2006 (12:47 pm)
Nice, i got it running, but i can`t add any object. I press the buttons but nothing happens. What im missing Gary?
#7
12/05/2006 (3:16 pm)
Uh, do you get any console messages or the like?

Gary (-;
#8
12/05/2006 (4:57 pm)
Only when i press the buttons repeatedly:

Two bodies the same. Uhwha? b1=1603, b2=1603
Two bodies the same. Uhwha? b1=1603, b2=1603
Two bodies the same. Uhwha? b1=1603, b2=1603

Thanks
#9
12/05/2006 (7:07 pm)
Aha. Yeah, there's that bug, that's caused by something in the torque collision code I think, which I quietly ignore. The source code at that point includes this choice comment:

Con::warnf("Two bodies the same. Uhwha? b1=%i, b2=%i",
  getId(), mCollisionList.collision[i].object->getId());
  // Totally pretend it didn't happen

I suspect that what's happening is the bodies *Are* being added to your world, you're just looking in the wrong direction. Since ODERocks is just a testbed for me, the initial positions of the rocks are hardcoded, and the positioning is most appropriate in Stronghold, where the video linked above is looking.

Gary (-;
#10
12/06/2006 (5:11 am)
Hey Gary, dont know what i did but now i can add objects. However i cant shoot them, the crossbow didnt collide with them, just the player.

Ah, the objects movement is not smooth it flicks all the time.... is it normal?

Thanks
#11
12/06/2006 (5:22 am)
Hi Gary, I'm trying to do a car with trailer, I believe what the your ODE Script is the Solution, but, I have no idea of how I can do this. Can you help me?
#12
12/06/2006 (12:20 pm)
@Gustavo: I replied to your same questions in this thread

@Emerson: How to create models ... you should be able to do basically the same things using ODEScript as you would do using ODE; The ODE Wiki is a good start, the page I linked has links to two demos of vehicles in ODE, including source.

Gary (-;
#13
12/09/2006 (1:35 am)
Great resource Gary, thanks a lot! 8-)

STef
#15
01/18/2007 (1:55 pm)
Will this work with 1.5? I am testing now...
#16
01/19/2007 (12:00 pm)
I'm using it in 1.5 right now.

Gary (-;
#17
01/29/2007 (9:21 pm)
Thank you so much for sharing!
#18
01/30/2007 (7:43 pm)
By any chance, will this work with TGE 1.4.2? I'm getting about 10 link errors when trying to build with v1.4.2 that look like they are the result of a few things missing from original Torque files. If you think it should work, any idea what I'm doing wrong? Thanks!
#19
01/31/2007 (3:06 pm)
1.4.2, yes, I believe it does work. Open up ODEShape.cc and #if0 out the bits that refer to shadows. Or, as in the next version [in progress], I have this as the appropriate constructor:
ODEShapeData::ODEShapeData()
{
#if TORQUE_GAME_ENGINE>=1500
	genericShadowLevel = 0.4f;
	noShadowLevel = 0.02f;
	shadowEnable = true;
	shadowCanMove = true;
	shadowCanAnimate = true;
#endif
}

Gary (-;
#20
02/03/2007 (1:09 pm)
I definitely saw the complie errors and commented them out. I decided I might as well upgrade to 1.5 anyway, but I'm still getting the following link errors:

ode.lib(convex.obj) : error LNK2005: "void * __cdecl operator new(unsigned int,void *)" (??2@YAPAXIPAX@Z) already defined in winMemory.obj
ode.lib(error.obj) : error LNK2001: unresolved external symbol ___security_cookie
ode.lib(error.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
ode.lib(collision_space.obj) : error LNK2001: unresolved external symbol __ftol2
ode.lib(heightfield.obj) : error LNK2001: unresolved external symbol __ftol2
ode.lib(IceContainer.obj) : error LNK2001: unresolved external symbol __ftol2
ode.lib(OPC_OptimizedTree.obj) : error LNK2001: unresolved external symbol __ftol2
ode.lib(convex.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ)
ode.lib(convex.obj) : error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ)

Do I have a bad version of ode.lib? Sorry I wasn't specific about the link errors in my last post, and thanks for your help!
Page «Previous 1 2 3 4 5 6 Last »