[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] PyODE



> Hi.  Ode is really fidly, you have to set all the values well or it just
> wont work as expected.  It can be hard to get it to work right, especially
> if you are constraining it to 2 axis.  (It's designed around 3).  I have
> used pyode a few times in the past, but am by no means an expert.

This is my experience as well.

Gotchas I have come across so far include:
- to use GeomTransform, do something like this:

    geom = ode.GeomBox(lengths=body.boxsize)
    geom.setPosition(offset)
    t = ode.GeomTransform(space)
    t.setGeom(geom)
    t.setBody(body)
    space.add(t)

Specifically, don't add the "shifted" geom to the space, but add the
transform geom. And set the position and rotation of the geom as necessary
to move it from (0, 0, 0) object-local coordinates.

- setCFM to something like 1e-8 if you want "hard" materials. I have seen
some really strange results with other CFMs, see
http://sourceforge.net/mailarchive/forum.php?thread_id=30731154&forum_id=38876.

- geoms and joints "don't count" if you don't keep a reference to them.

In my experience, for "simulating" 2d, you can set every object to center
at z=0 and things pretty much work the way you expect them to. I've got in
my program a check every tick to make sure the objects haven't jumped out
of the XY plane. So far every time they have, it's due to some larger
problem, but that might not be true for you. (I don't have much use for
rotating objects, for instance.)

I tried at first to sandwich things between z=1 and z=-1 planes, but I
needed to make "circles" with radius greater than 1, and the version of
ODE I'm using (0.5) doesn't support cylinders (and I think python-pyode
doesn't have bindings for them), so I had to use spheres, so I had to
ditch the plane idea.

Ethan