[ODE] question about usages of dMassSetParameters and dBodySetMass

Bram Stolk b.stolk at gmail.com
Sun Oct 7 08:04:37 MST 2007


Look at the SVN trunk, in the demo_moving_trimesh example.
It shows how to correctly treat the mass of an object with a trimesh
geometry.
Older versions of ODE did not yet have proper c.o.m. calculations for
trimeshes.

      dTriMeshDataID new_tmdata = dGeomTriMeshDataCreate();
      dGeomTriMeshDataBuildSingle(new_tmdata, &Vertices[0], 3 *
sizeof(float), VertexCount, (int*)&Indices[0], IndexCount, 3 * sizeof(int));

      obj[i].geom[0] = dCreateTriMesh(space, new_tmdata, 0, 0, 0);

      // remember the mesh's dTriMeshDataID on its userdata for convenience.
      dGeomSetData(obj[i].geom[0], new_tmdata);

      dMassSetTrimesh( &m, DENSITY, obj[i].geom[0] );
      printf("mass at %f %f %f\n", m.c[0], m.c[1], m.c[2]);
      dGeomSetPosition(obj[i].geom[0], -m.c[0], -m.c[1], -m.c[2]);
      dMassTranslate(&m, -m.c[0], -m.c[1], -m.c[2]);

As you can see, the trick is to translate the geometry and mass afterwards
so that you have a nice 0,0,0 com again.

  bram


On 10/7/07, yyd_iris at yahoo.com <yyd_iris at yahoo.com> wrote:
>
> Hi
>
> I have a Body that only has one Mesh Geom.
> I plan to use dMassSetParameters and then dBodySetMass
> to set the mass parameters.
>
> Since ODE requies the Body's reference point must
> coincide with center of mass. Does it mean that in the
> function dMassSetParameter, the center of mass
> parameters must be zeros?
>
> Thank you very much!
>
> Yuandong
>
>
>
>       ____________________________________________________________________________________
> Check out the hottest 2008 models today at Yahoo! Autos.
> http://autos.yahoo.com/new_cars.html
> _______________________________________________
> ODE mailing list
> ODE at ode.org
> http://ode.org/mailman/listinfo/ode
>



-- 
Zapp: Captain's log, stardate...er..
Kif: Ohhh. April 13th.
Zapp: April 13th. Point 2.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ode.org/pipermail/ode/attachments/20071007/4ccb6d43/attachment.htm


More information about the ODE mailing list