[ODE] Using transforms with dynamic bodies

Burton Radons loth at users.sourceforge.net
Thu Jul 18 13:11:01 2002


slipch wrote:

> Hello ode,
> I am new in it.
>  How can I attach two geometry objects to the same body object and set
>  their positions with respect to each other?


You can use the dGeomAttach (geom, body) function to attach them; it 
doesn't matter how many you add.  However, once it is attached to a body 
the rotation and position are set to the body's parameters here, so you 
can't just use a bare geometry.  You have to use dGeomTransform, which 
is at section 9.2.6 of the manual.


>  I would very appresiate a few line example, or any explanation.

Sure.  If your original geometry is "geom", your body "body", your space 
"space", then:

     dGeomID transform = dCreateGeomTransform (space);

     dGeomTransformSetGeom (transform, geom);
     dGeomTransformSetCleanup (transform, ownsthis); /* The value of 
"ownsthis" depends upon whether you want "geom" deleted when you delete 
"transform". */

     dGeomSetBody (transform, body); /* Don't set "geom" to the body */

     /* Now set the transforms on "geom".  Not on "transform", as it's 
matching the body position. */