[ODE] Encapsulating geometries with transforms

Joe Ante joe at otee.dk
Sun Sep 19 14:15:38 MST 2004


Hi Jeffrey,

I am not sure if it is necessary but our code specifically ignores
collisions between geom's in the same collection.

Also the space you use for the box geom has to be 0. The transform geom's
space is the normal space you use normally.

Here is the code i am using to setup primitive collider's. I remember that
the interface was quite strange and took a bit to get working correctly:

dGeomID PrimitiveCollider::Primitive::MakeGeom (dSpaceID space,
PrimitiveCollider *data)
{
    DestroyGeom ();
    dGeomID primitiveGeom = 0;
    dGeomID transformGeom = 0;
    dSpaceID primitiveSpace;
    
    bool needsTransformGeom = !CompareApproximately (m_Position,
Vector3f::zero);
    
    if (needsTransformGeom)
        primitiveSpace = 0;
    else
        primitiveSpace = space;

    // Setup primitive geom
    if (m_Type == kColliderBox)
        primitiveGeom = dCreateBox (primitiveSpace, m_Size.x, m_Size.y,
m_Size.z);
    else if (m_Type == kColliderSphere)
        primitiveGeom = dCreateSphere (primitiveSpace, m_Radius);
    else if (m_Type == kColliderCappedCylinder)
        primitiveGeom = dCreateCCylinder (primitiveSpace, m_Size.z,
m_Radius);
    else
        Assert ();
        
    dGeomSetData (primitiveGeom, data);
    dGeomSetPosition (primitiveGeom, m_Position.x, m_Position.y,
m_Position.z);

    if (needsTransformGeom)
    {
        transformGeom = dCreateGeomTransform (space);
        // Clean children when destroying transform
        dGeomTransformSetCleanup (transformGeom, true);
        // When a contact is found the actual geometry is returned not the
transformGeom
        dGeomTransformSetInfo (transformGeom, 0);

        dGeomTransformSetGeom (transformGeom, primitiveGeom);
        dGeomSetData (transformGeom, data);
    
        m_Geom = transformGeom;
    }
    else
        m_Geom = primitiveGeom;

    return m_Geom;
}


Joachim Ante
www.otee.dk




More information about the ODE mailing list