Re: question about usages of dMassSetParameters and dBodySetMass

"Bram Stolk" <[email protected]> Sun, 7 Oct 2007 08:04:37 -0700
Newsgroups gmane.comp.lib.ode
Message-ID <[email protected]>
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, [email protected] <[email protected]> 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
> [email protected]
> http://ode.org/mailman/listinfo/ode
>



-- 
Zapp: Captain's log, stardate...er..
Kif: Ohhh. April 13th.
Zapp: April 13th. Point 2.

_______________________________________________
ODE mailing list
[email protected]
http://ode.org/mailman/listinfo/ode