[ODE] XML ODE Data Interchange Format

John Ratcliff jratcliff at ageia.com
Mon Mar 8 14:29:14 MST 2004


There were some formatting errors in the first example, some linefeeds
were missing.  Here is how the first simple sample should look:

-----------------------------------------
PsNameSpace test2

PsSceneBegin test2
PsPlane plane(0,0,1,0) static(true)
PsBox sides(5,5,5) mass(625) position(0,0,30) restitution(0) 
PsBox sides(4,4,4) mass(320) position(0,0,10) restitution(0) 
PsSceneEnd

PsReset
PsLoadScene test2 position(0,0,0)

-----Original Message-----
From: ode-bounces at q12.org [mailto:ode-bounces at q12.org] On Behalf Of John
Ratcliff
Sent: Monday, March 08, 2004 1:53 PM
To: Jani Laakso; ode at q12.org
Subject: RE: [ODE] XML ODE Data Interchange Format

I have been developing a physics scene definition language for the last
couple of weeks.  My language is designed to be run interactively in a
command line fashion as well as to be used as a data interchange format.


It can also be hooked into external scripting language, such as LUA, so
you can easily write scripts that define functions to create chains and
other complex objects.

The language uses a stack based approach so that you can set a variety
of default properties that are presumed to apply from that point
forward.  You can override default properties on a per instance basis.
You can push and pop state wherever you wish.

The language can be captured to disk as raw script and then played back
again.

The language interacts with a physics engine through an abstract
interface and can be hooked into any 3rd party physics API.  I have
personally hooked it up to 4 different Physics SDK's so I know it can be
done.

The scene definition language can be used to perform a complete
core-dump of a physics simulation.  It can be used to record and
playback an interactive simulation.  In fact, a front end application
that lets you select and drag objects can be written to run completely
through script, so that any sequence of actions can be played back
afterwards for debugging purposes.

The scene definition language can also be saved and loaded as XML.  The
definition of the language is in either format.  Obviously the command
line version is more human readable.

My intention is to make this physics scripting language, both the XML
and command line version, open source and public domain.

The language is still in the definition phase, that's why I haven't
brought it up sooner.  I will be happy to incorporate any features
suggested by the community.

Here is a very simple example which sets up one of the tests from Chris
Hecker and Jeff Lander's gamasutra article:
-----------------------------------------
PsNameSpace test2

PsSceneBegin test2
PsPlane plane(0,0,1,0) static(true)
PsBox sides(5,5,5) mass(625) position(0,0,30) restitution(0)
PsBox sides(4,4,4) mass(320) position(0,0,10) restitution(0)
PsSceneEnd

PsReset
PsLoadScene test2 position(0,0,0)
-----------------------------------


Here is a slightly more complex example, again from the Gamasutra
article, showing how to set up two bodies jointed together.
--------------------------------------------------------------
PsNameSpace test4


PsJointBegin  stiffjoint
PsJointOffset frame(primary)   body(primary)    offset(0,0,-5)
PsJointOffset frame(primary)   body(secondary)  offset(0,0,-5)
PsJointAxes   frame(primary)   body(primary)    xaxis(0,0,-1)
yaxis(0,1,0)
PsJointAxes   frame(secondary) body(secondary)  xaxis(0,0,-1)
yaxis(0,1,0)
PsJointAngular  swing1(locked) swing2(locked) twist(locked)
linear(locked,locked,locked)
PsJointEnd


PsSceneBegin test4
PsPlane plane(0,0,1,0) static(true)
PsBox name(box1) sides(5,5,5) mass(625) position(0,0,20) restitution(0)
PsBox name(box2) sides(4,4,4) mass(320) position(0,0,10) restitution(0)
PsJoint stiffjoint box1 box2
PsSceneEnd

PsReset
PsLoadScene test4 position(0,0,0)

---------------------------------------------

Here is an example of the physics scene definition language being
invoked from a Lua script to create a chain of arbitrary length
--------------------------------------------------------------
function AgChain(name,length)

  AgScript("PsJointBegin simple")
  AgScript("PsJointEnd")

  AgScript("PsSceneBegin %s",name)
  AgScript("PsPlane plane(0,0,1,0) static(true)")
  AgScript("PsDefaultSettings sides(0.1,0.1,0.25) localposition(0,0,0)")

  for x=1, length do

   AgScript("PsBox name(%s%d) position(0,0,%f)",name,x,x*0.3)

  end

  for x=1, (length-1) do

   AgScript("PsJoint simple %s%d %s%d", name, x, name, x+1 )

  end

  AgScript("PsSceneEnd")
  AgScript("PsReset")
  AgScript("PsLoadScene %s",name)

end




AgChain("box",20)

-------------------------------------------------
Here's an example of a script that creates a table as an aggregate
shape.
-------------------------------------------------------

PsNameSpace objects

PsAggregateBegin table
PsDefaultSettings sides(0.1,0.1,1)
PsBox localposition(-0.5,-0.5,0.5)
PsBox localposition( 0.5,-0.5,0.5)
PsBox localposition( 0.5, 0.5,0.5)
PsBox localposition(-0.5, 0.5,0.5)
PsBox sides(1,1,0.1) localposition(0,0,1)
PsAggregateEnd

PsSceneBegin tables
PsPlane plane(0,0,1,0) static(true)
PsAggregate table position(0,0,4) euler(0,0,90)
PsAggregate table position(1,0,8)
PsAggregate table position(0,1,12)
PsAggregate table position(1,1,16)
PsSceneEnd

PsReset
PsLoadScene tables position(0,0,0)

----------------------------------------------------------------
And, finally, here's a script that sets up a scene that contains a
newtons cradle.
------------------------------------------------------------------
PsNameSpace environment

PsJointBegin clackjoint
PsDefaultSettings erp(0.1,0.1) cfm(0.2,0.2)
PsJointOffset frame(primary)   body(primary)    offset(0,0,6)
PsJointOffset frame(primary)   body(secondary)  offset(0,0,6)
PsJointAxes   frame(primary)   body(primary)
xaxis(0.000000,0.000000,-1.000000) yaxis(0.000000,1.000000,0.000000)
PsJointAxes   frame(secondary) body(secondary)
xaxis(0.000000,0.000000,-1.000000) yaxis(0.000000,1.000000,0.000000)
PsJointLimit    swing1(0.1) swing2(1.2) twist(free)
PsJointEnd

PsAggregateBegin clack
PsBox    sides(0.001,0.01,5.8) localposition(0,0,3)
PsSphere radius(0.5)   localposition(0,0,0)
PsAggregateEnd

PsAggregateBegin clacker
PsBox sides(40,40,1) localposition(0,0,-0.5)
PsBox sides(40,40,0.2) localposition(0,0,8.1)
PsAggregateEnd

PsSceneBegin newtons_cradle
PsDefaultSettings position(0,0,0)
PsAggregate clacker name(clacker) locked(true)
PsAggregate clack name(clack1) position(0,0,2)  
PsAggregate clack name(clack2) position(1,0,2)
PsAggregate clack name(clack3) position(2,0,2)
PsAggregate clack name(clack4) position(3,0,2)
PsAggregate clack name(clack5) position(4,0,2)
PsAggregate clack name(clack6) position(5,0,2)
PsAggregate clack name(clack7) position(6,0,2)
PsAggregate clack name(clack8) position(7,0,2)
PsAggregate clack name(clack9) position(8,0,2)
PsJoint clackjoint clack1 clacker
PsJoint clackjoint clack2 clacker
PsJoint clackjoint clack3 clacker
PsJoint clackjoint clack4 clacker
PsJoint clackjoint clack5 clacker
PsJoint clackjoint clack6 clacker
PsJoint clackjoint clack7 clacker
PsJoint clackjoint clack8 clacker
PsJoint clackjoint clack9 clacker 
PsSceneEnd

PsReset
PsLoadScene newtons_cradle position(0,0,0)


_______________________________________________
ODE mailing list
ODE at q12.org
http://q12.org/mailman/listinfo/ode



More information about the ODE mailing list