[ODE] Composite Bodies
Wesley Smith
wesley.hoke at gmail.com
Mon Apr 24 20:14:23 MST 2006
Hi,
I've been trying to figure out how I can make composite bodies work.
Following Jaap's example, I've got this code:
//assemble body[0] and body[2]
//step1: add masses together (not reversible)
dBodyGetMass(body[0], &m);
dBodyGetMass(body[2], &m2);
dMassAdd(&m, &m2);
//get position of body center to be added in world coordinates
dBodyGetRelPointPos(body[2], 0, 0, 0, result);
//disconnect body from Geom
dGeomSetBody(bodyBounds[2], 0);
//bind Geom to make composite body
dGeomSetBody(bodyBounds[2], body[0]);
//set body to assembled body relative coordinates
dBodyGetPosRelPoint(body[0], result[0], result[1], result[2], result2);
dGeomSetPosition(bodyBounds[2], result2[0], result2[1], result2[2]);
Now, by this point I have 2 Geoms connected to body[0] (bodyBound[0]
and bodyBound[2]). When I query their position, I get identical
results. As the ODE manual says, "If the geom is attached
to a body, the body's position / rotation / quaternion will also be
changed. " So, it seems that by adding the second Geom, I'm moving
the body position as well. I can't seem to wrap my head around the
mechanics of composite bodies in ODE...the docs are not very specific
on this issue. All they say are " The solution is to use a composite
collision object that is a combination of several geoms." I'm trying
to do this, but I don't think I'm getting it right.
For instance, when I want to draw the position of the 2 parts of the
composite object, I can't get their relative positions by querying the
dBodyGetPosition because there's only 1 and dGeomGetPosition gives me
the exact same answer for both Geoms.
So, what am I missing here?
thanks,
wes
More information about the ODE
mailing list