[ODE] My ODE++

royce3 at ev1.net royce3 at ev1.net
Wed Jan 7 15:53:03 MST 2004


> > I started building some C++ wrappers,

> What about the ones already in ODE?  How does yours compare to it?

I didn't know there were wrappers already. It took a few minutes, but I
finally managed to find the file.

Interestingly enough, there are no wrappers for dGeomID in odecpp.h, which
is where I spent most of my time.

The implementations for the other classes I did are extremely similar to
odecpp.h.

I think my work with the Geoms might possibly be suitable for submission,
once they are refactored a little bit to match the naming, style &
convention of odecpp.h

Here's a pared-down example from my modified test_boxstack.cpp with some
added documentation. What you see here is the entirely of the code necessary
to build all the types of bodies represented in the test_boxstack sample.

  // the assembler is a temporary class that manages initialization and
  // clean-up for building a body out of geoms
  DGeomAssembler assem ( *obj[i].body );

  if (cmd == 'b')
  {
    // a simple case where a single geom is put in the body...
    assem.AddGeom ( new DGeomBox ( space, DENSITY, sides[0], sides[1],
sides[2] ) );
  }
  else if (cmd == 'x')
  {
    // multiple transformed geoms are going to be in the body.
    for ( int i = 0; i < 3; i++ )
    {
      // first let's create our geom....
      DGeom* subgeom = 0;
      switch ( i )
      {
      case 0:
        subgeom = new DGeomSphere ( DENSITY, dRandReal() * 0.25 + 0.05 );
        break;
      case 1:
        subgeom = new DGeomBox ( DENSITY, sides[0], sides[1], sides[2] );
        break;
      case 2:
        subgeom = new DGeomCappedCylinder ( DENSITY, dRandReal()*0.1+0.05,
dRandReal()*1.0+0.1 );
        break;
      }

      // now create the transformer....
      DGeomTransform* xfrm = new DGeomTransform ( space, subgeom );

      // set the geom's relative position...
      xfrm->SetPosition (
        dRandReal()*0.3-0.15,
        dRandReal()*0.3-0.15,
        dRandReal()*0.3-0.15 );

      // ... and orientation
      xfrm->RFromAxisAndAngle (
        dRandReal()*2.0-1.0,
        dRandReal()*2.0-1.0,
        dRandReal()*2.0-1.0,
        dRandReal()*10.0-5.0 );

      // now attach this new geom to the assembler
      assem.AddGeom ( xfrm );
    }
  }

  // DGeomAssembler's dtor performs the final calculations necessary
  // to make it work.


--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .





More information about the ODE mailing list