From: Timothy S. <ti...@st...> - 2005-06-23 17:06:49
|
On Wed, 2005-06-22 at 15:23 -0400, Peter Doege wrote: > I tried creating a list of the objects using namedChild() and then creating > and attaching them. However, I get the suspicion from looking at the parser > code that it has already done that. That is correct. The parser attaches all the objects together based on the input file. > I am also have trouble figuring out what to do with hinges. I have not been > able to figure out how to differentiate between a body and a hinge. I've > been trying to use isinstance() and hasattr() to test for various things but > it seems really, well, non-optimal. isinstance() is the way I would do it... > If someone has a code snippet that shows how to move an > object/joint from the parser to ODE I would love to see it. Here is a minimal example: doc = '''<?xml version="1.0"> <xode> <world name="myWorld"> <body name="body1"> <mass><mass_shape density="2500"> <sphere radius="0.05"/> </mass_shape></mass> </body> <body name="body2"> <mass><mass_shape density="2500"> <sphere radius="0.05"/> </mass_shape></mass> <joint name="joint1"> <link1 body="body1"/> <ball><anchor x="0" y="0" z="0"/></ball> </joint> </world> </xode>''' import xode.parser p = xode.parser.Parse() root = p.parseString(doc) world = root.namedChild("world").getODEObject() while 1: world.step(0.1) # do something I suggest you take a look at tutorial2.py in the examples/ directory of the PyODE source distribution. You can ignore the function buildObjects(); it does the same thing as buildObjectsXODE() but without using XODE. -- Timothy Stranex <ti...@st...> |