|
From: Matthias B. <ba...@ir...> - 2005-03-03 09:59:14
|
Jonathan V Toups wrote:
> j.attach(geom1.getBody(),geom2.getBody());
>
> Causes a nasty error. This is because if one of the Geom objects is an
> immovable object, getBody returns None. This behaviour is puzzling, since
> in Linux, I am clearly getting a body, perhaps where I shouldn't be.
> So the question is, how do you handle adding contact joints to
> objects which do not have bodies? Or, how do you make an object with a
> body permanantly fixed in space? Or, am I doing something totally
> ridiculous?
PyODE contains an actual body object that represents the static
environment. And that's the ode.environment object. However, this
concept isn't really applied consistently throughout PyODE.
The getBody() method can return None, however the attach() method must
not be called with None as one of its arguments.
This means, you're near callback has to look somewhat like this.
...
b1 = geom1.getBody()
b2 = geom2.getBody()
if b1==None:
b1=ode.environment
if b2==None:
b2=ode.environment
j.attach(b1, b2)
...
The tutorial did work because the only object that has no body
associated with it was the ground floor which is a non-placeable object.
And calling getBody() on non-placeable objects always returns
ode.environment.
This situation is not really ideal. Either the ode.environment object
should be dropped and the value None will represent the static
environment. Or the environment concept should be consistent and
getBody() should never return None. I'm quite undecided about what
approach would be the better one (I'm probably slightly in favor of the
environment object...).
By the way, I don't know why you get a different behavior under Linux.
getBody() should also return None. What body is it actually returning?
- Matthias -
|