[ODE] Transforming mass objects

Morgan McGuire morgan3d at yahoo.com
Fri Nov 18 01:00:53 MST 2005


I'm having trouble using transformed masses and transform geoms together.

I created a single body that has a single transform geom, which in turn has a
single ccylinder.  The transform moves the ccylinder so that the body space
origin is at one end of the cylinder (i.e., it translates by (0,0,h/2)).  I
transform the mass object in the same manner and then drop the ccylinder.  It
acts as if the mass was never translated; the collision occurs in the correct
location, however the ccylinder never tips over even if rotated by 45-degrees
because its center of mass is incorrectly on the end.  I verified that the mass
object's 'c' field is being correctly set; it just seems that the body is
ignoring it.

Please let me know if you suspect the cause of my problem or if you have some
sample code that uses transform geoms you can share.

I'm using today's ODE from CVS from the 'ode' module, trunk branch (which I
assume is the much maligned STABLE branch; I don't know how to check out the
UNSTABLE branch).

-m


 dGeomSetPositionAndRotation(geom, transform);
 odeGeometry = dCreateGeomTransform(space);
 dGeomTransformSetCleanup(odeGeometry, 1);
 dGeomTransformSetInfo(odeGeometry, 1);
 dGeomTransformSetGeom(odeGeometry, geom);

 dMassSetCappedCylinderTotal(&odeMass, m_mass, 3, r, h);
 dMassToWorldSpace(&odeMass, transform);
 dBodySetMass(body, &odeMass);

// TODO: the mass isn't acting like it is transformed by the body's frame

 dGeomSetBody(odeGeometry, body);

 dBodySetPositionAndRotation(body, m_frame);
 dBodySetLinearVel(body, m_linearVelocity);
 dBodySetAngularVel(body, m_angularVelocity);

-----------------------------------------------
void dMassToWorldSpace(dMass *m, const CoordinateFrame& cframe) {
    dMassRotate(m, cframe.rotation);
    dMassTranslate(m, cframe.translation);
}

void dBodySetPositionAndRotation(dBodyID id, const CoordinateFrame& cframe) {
    const Matrix3& g3dR = cframe.rotation;
    dMatrix3 odeR;
    toODE(g3dR, odeR);
    
    const Vector3& c = cframe.translation;

    dBodySetPosition(id, c.x, c.y, c.z);
    dBodySetRotation(id, odeR);
}




More information about the ODE mailing list