Update of /cvsroot/opal/opal/src/ODE
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32471/src/ODE
Modified Files:
ODESolid.cpp
Log Message:
added more ShapeData classes
Index: ODESolid.cpp
===================================================================
RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** ODESolid.cpp 22 Feb 2005 01:25:57 -0000 1.65
--- ODESolid.cpp 22 Feb 2005 04:28:11 -0000 1.66
***************
*** 31,34 ****
--- 31,37 ----
#include "../SphereShapeData.h"
#include "../CapsuleShapeData.h"
+ #include "../PlaneShapeData.h"
+ #include "../RayShapeData.h"
+ #include "../MeshShapeData.h"
namespace opal
***************
*** 58,62 ****
while (!mGeomDataList.empty())
{
! // Note: do not delete the solid pointer. It will get deleted
// elsewhere.
--- 61,65 ----
while (!mGeomDataList.empty())
{
! // Note: do not delete the Solid pointer. It will get deleted
// elsewhere.
***************
*** 403,429 ****
{
BoxShapeData& boxData = (BoxShapeData&)sd;
! newGeomID = dCreateBox(spaceID, boxData.dimensions[0],
! boxData.dimensions[1], boxData.dimensions[2]);
! dMassSetBox(&newMass, sd.material.density,
! boxData.dimensions[0], boxData.dimensions[1],
! boxData.dimensions[2]);
newShape = new BoxShapeData(boxData);
break;
}
case SPHERE_SHAPE:
! // TODO
break;
case CAPSULE_SHAPE:
! // TODO
break;
case PLANE_SHAPE:
! // TODO
break;
case RAY_SHAPE:
! // TODO
break;
case MESH_SHAPE:
! // TODO
break;
default:
assert(false);
--- 406,514 ----
{
BoxShapeData& boxData = (BoxShapeData&)sd;
! newGeomID = dCreateBox(spaceID,
! (dReal)boxData.dimensions[0],
! (dReal)boxData.dimensions[1],
! (dReal)boxData.dimensions[2]);
! dMassSetBox(&newMass, (dReal)sd.material.density,
! (dReal)boxData.dimensions[0],
! (dReal)boxData.dimensions[1],
! (dReal)boxData.dimensions[2]);
newShape = new BoxShapeData(boxData);
break;
}
case SPHERE_SHAPE:
! {
! SphereShapeData& sphereData = (SphereShapeData&)sd;
! newGeomID = dCreateSphere(spaceID,
! (dReal)sphereData.radius);
! dMassSetSphere(&newMass, (dReal)sd.material.density,
! (dReal)sphereData.radius);
! newShape = new SphereShapeData(sphereData);
break;
+ }
case CAPSULE_SHAPE:
! {
! CapsuleShapeData& capsuleData = (CapsuleShapeData&)sd;
! newGeomID = dCreateCCylinder(spaceID,
! (dReal)capsuleData.radius, (dReal)capsuleData.length);
!
! //The "direction" parameter orients the mass along one of the
! //body's local axes; x=1, y=2, z=3. TODO: This might be weird
! //if this capsule is not oriented along one of the body's axes.
! //Maybe have a default value in the Simulator that the user can
! //change.
! dMassSetCappedCylinder(&newMass, (dReal)sd.material.density,
! 3, (dReal)capsuleData.radius, (dReal)capsuleData.length);
! newShape = new CapsuleShapeData(capsuleData);
break;
+ }
case PLANE_SHAPE:
! {
! PlaneShapeData& planeData = (PlaneShapeData&)sd;
! if (!mData.isStatic)
! {
! // TODO: print warning: opal::ODESolid::addPlane: plane
! // Shape added to a non-static Solid.
!
! // ODE planes can't have bodies, so make it static.
! setStatic(true);
! }
!
! // TODO: make this fail gracefully and print warning: plane
! // offset transform ignored.
! assert(!newTransformID);
!
! // ODE planes must have their normal vector (abc) normalized.
! Vec3r normal(planeData.abcd[0], planeData.abcd[1],
! planeData.abcd[2]);
! normal.normalize();
!
! newGeomID = dCreatePlane(mSpaceID, (dReal)normal[0],
! (dReal)normal[1], (dReal)normal[2],
! (dReal)planeData.abcd[3]);
!
! // Note: ODE planes cannot have mass, but this is already
! // handled since static Solids ignore mass.
!
! // Solids with planes are the only "placeable" Solids.
! mIsPlaceable = false;
! newShape = new PlaneShapeData(planeData);
break;
+ }
case RAY_SHAPE:
! {
! RayShapeData& rayData = (RayShapeData&)sd;
! newGeomID = dCreateRay(spaceID,
! (dReal)rayData.ray.getLength());
! Point3r origin = rayData.ray.getOrigin();
! Vec3r dir = rayData.ray.getDir();
! dGeomRaySet(newGeomID, (dReal)origin[0], (dReal)origin[1],
! (dReal)origin[2], (dReal)dir[0], (dReal)dir[1],
! (dReal)dir[2]);
! // Note: rays don't have mass.
! newShape = new RayShapeData(rayData);
break;
+ }
case MESH_SHAPE:
! {
! MeshShapeData& meshData = (MeshShapeData&)sd;
!
! // Setup trimesh data pointer. It is critical that the
! // size of OPAL reals at this point match the size of ODE's
! // dReals.
! newTrimeshDataID = dGeomTriMeshDataCreate();
! dGeomTriMeshDataBuildSimple(newTrimeshDataID,
! (dReal*)meshData.vertexArray, meshData.numVertices,
! meshData.faceArray, 3 * meshData.numFaces);
! newGeomID = dCreateTriMesh(spaceID,
! newTrimeshDataID, NULL, NULL, NULL);
!
! // TODO: either do more sophisticated mass calculations,
! // or just enforce that all mesh must be static.
! dMassSetSphere(&newMass, (dReal)sd.material.density, 1);
!
! newShape = new MeshShapeData(meshData);
break;
+ }
default:
assert(false);
***************
*** 433,438 ****
--- 518,525 ----
addMass(newMass, sd.offset);
+ // Store new Shape.
mData.shapes.push_back(newShape);
+ // Setup GeomData.
newGeomData->solid = this;
newGeomData->shape = newShape;
***************
*** 442,445 ****
--- 529,533 ----
newGeomData->trimeshDataID = newTrimeshDataID;
+ // Setup the geom.
setupNewGeom(newGeomData);
}
***************
*** 947,951 ****
{
setTransform(mData.transform);
- //internal_uploadTransformChanges();
}
}
--- 1035,1038 ----
|