Game Development Community

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«First 1 2 3 4 5 6 Next»
#101
06/09/2008 (1:12 pm)
Quote:The onStaticModified method accepts one more argument now in 1.7.0 than it used to.
Great, this was the missing piece! The code seems to work with ode 0.8 and 0.9.

Quote:but after running newbox(); the box just sits where it spawned.
I can't confirm the problem with nexbox() when running the engine with -dir oderocks.

Quote:* The simulation is very jerky... and stuff still falls through the floor on occasion :(
Same here, hope there'll be a solution for this as well soon :)
#102
08/21/2008 (12:04 pm)
Having a heck of a time trying to get this compiled with TGEA 1.7.1, haven't had any trouble compiling this with any of the other engines before. I've tried to use ODE .8 and .9 from their site.

Quote:
1>tworldconsole.cc
1>C:\Program Files\ODE\include\ode/memory.h(52) : warning C4002: too many actual parameters for macro 'dRealloc'
1>C:\Program Files\ODE\include\ode/memory.h(52) : error C2059: syntax error : 'string'
1>..\..\..\..\..\Engine\source\odescript\tworldconsole.cc(111) : warning C4305: 'argument' : truncation from 'double' to 'dReal'
1>..\..\..\..\..\Engine\source\odescript\tworldconsole.cc(124) : warning C4305: 'argument' : truncation from 'double' to 'dReal'
1>tworld.cc
1>C:\Program Files\ODE\include\ode/memory.h(52) : warning C4002: too many actual parameters for macro 'dRealloc'
1>C:\Program Files\ODE\include\ode/memory.h(52) : error C2059: syntax error : 'string'
1>..\..\..\..\..\Engine\source\odescript\tworld.cc(122) : warning C4305: 'argument' : truncation from 'double' to 'F32'
1>tmassconsole.cc
1>C:\Program Files\ODE\include\ode/memory.h(52) : warning C4002: too many actual parameters for macro 'dRealloc'
1>C:\Program Files\ODE\include\ode/memory.h(52) : error C2059: syntax error : 'string'
1>tmass.cc
...
#103
08/22/2008 (12:57 am)
Well apparently somehow the fact that both ODE and Torque were using a function declared as dRealloc caused the problem. I renamed ODE's dRealloc to dReAlloc and it fixed the problem.
#104
11/22/2008 (3:02 am)
hi all,
got this working with TGEA 1.8 Beta, but when I spawn one of the ragdolls, the limbs all float apart, like away from each other. really weird, dont know why. any ideas??

edit:

ok, bodies create fine, simulate at creation, but no simulation when shot, only explosions, no reactions at all
#105
10/10/2009 (9:27 pm)
Helppppp......ODE internal error 1

assertion "bNormalizationResult" failed in../../include\ode/odemath.h:326

any takers on what went wrong......

All I do is hold down the v key, then select create humanoid over water

Donnie
#106
01/15/2010 (5:05 pm)
Thank you, topic creator
Page«First 1 2 3 4 5 6 Next»