opal-commits Mailing List for Open Physics Abstraction Layer (Page 24)
Status: Inactive
Brought to you by:
tylerstreeter
You can subscribe to this list here.
| 2005 |
Jan
|
Feb
(162) |
Mar
(134) |
Apr
(113) |
May
(13) |
Jun
(60) |
Jul
(18) |
Aug
(25) |
Sep
|
Oct
(2) |
Nov
(35) |
Dec
(76) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
| 2008 |
Jan
|
Feb
|
Mar
(3) |
Apr
(8) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
(1) |
Mar
(12) |
Apr
(16) |
May
(2) |
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
|
Nov
|
Dec
(3) |
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(15) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: tylerstreeter <tyl...@us...> - 2005-02-25 06:40:37
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5241/src/ODE Modified Files: ODEJoint.cpp ODEJoint.h ODESimulator.cpp ODESimulator.h ODESolid.cpp ODESolid.h Log Message: updated XML parsing to reflect new object creation method Index: ODESimulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.cpp,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** ODESimulator.cpp 23 Feb 2005 06:35:46 -0000 1.79 --- ODESimulator.cpp 25 Feb 2005 06:40:26 -0000 1.80 *************** *** 76,80 **** setSolverAccuracy(defaults::solverAccuracy); ! setSleepiness(defaults::sleepiness); mCollisionCount = 0; } --- 76,80 ---- setSolverAccuracy(defaults::solverAccuracy); ! //setDefaultSleepiness(defaults::sleepiness); mCollisionCount = 0; } *************** *** 711,740 **** } ! void ODESimulator::collide(const Solid* solid, std::vector<Solid*>* solids) ! { ! mCollisionCount++; ! mCollidedSolids.clear(); ! const std::vector<GeomData*>* geomList = ! ((ODESolid*)solid)->internal_getGeomDataList(); ! ! //check for collisions; this will fill up mCollidedSolids ! std::vector<GeomData*>::const_iterator iter; ! for (iter = geomList->begin(); iter != geomList->end(); ++iter) ! { ! dSpaceCollide2((*iter)->geomID, (dGeomID)mRootSpaceID, this, ! &ode_hidden::internal_pickingCollisionCallback); ! } ! std::vector<Solid*>::iterator solidIter; ! for (solidIter = mCollidedSolids.begin(); ! solidIter != mCollidedSolids.end(); ++solidIter) ! { ! //we don't want the picking solid to be added ! if (*solidIter != solid) ! { ! solids->push_back(*solidIter); ! } ! } ! } RayHit ODESimulator::shootRay(const Point3r& origin, const Vec3r& dir, --- 711,740 ---- } ! //void ODESimulator::collide(const Solid* solid, std::vector<Solid*>* solids) ! //{ ! // mCollisionCount++; ! // mCollidedSolids.clear(); ! // const std::vector<GeomData*>* geomList = ! // ((ODESolid*)solid)->internal_getGeomDataList(); ! // ! // //check for collisions; this will fill up mCollidedSolids ! // std::vector<GeomData*>::const_iterator iter; ! // for (iter = geomList->begin(); iter != geomList->end(); ++iter) ! // { ! // dSpaceCollide2((*iter)->geomID, (dGeomID)mRootSpaceID, this, ! // &ode_hidden::internal_pickingCollisionCallback); ! // } ! // std::vector<Solid*>::iterator solidIter; ! // for (solidIter = mCollidedSolids.begin(); ! // solidIter != mCollidedSolids.end(); ++solidIter) ! // { ! // //we don't want the picking solid to be added ! // if (*solidIter != solid) ! // { ! // solids->push_back(*solidIter); ! // } ! // } ! //} RayHit ODESimulator::shootRay(const Point3r& origin, const Vec3r& dir, *************** *** 779,825 **** } ! void ODESimulator::setSleepiness(real value) ! { ! assert(value >= 0.0 && value <= 1.0); ! ! if (0.0 == value) ! { ! //no sleeping at all ! dWorldSetAutoDisableFlag(mWorldID, false); ! } ! else ! { ! //enable sleeping ! dWorldSetAutoDisableFlag(mWorldID, true); ! } ! //as value goes from 0.0 to 1.0: ! //AutoDisableLinearThreshold goes from min to max, ! //AutoDisableAngularThreshold goes from min to max, ! //AutoDisableSteps goes from max to min, ! //AutoDisableTime goes from max to min ! real range = defaults::ode::autoDisableLinearMax - ! defaults::ode::autoDisableLinearMin; ! dWorldSetAutoDisableLinearThreshold(mWorldID, value * range + ! defaults::ode::autoDisableLinearMin); ! range = defaults::ode::autoDisableAngularMax - ! defaults::ode::autoDisableAngularMin; ! dWorldSetAutoDisableAngularThreshold(mWorldID, value * range + ! defaults::ode::autoDisableAngularMin); ! range = (real)(defaults::ode::autoDisableStepsMax - ! defaults::ode::autoDisableStepsMin); ! dWorldSetAutoDisableSteps(mWorldID, ! (int)((real)defaults::ode::autoDisableStepsMax - value * range)); ! range = defaults::ode::autoDisableTimeMax - ! defaults::ode::autoDisableTimeMin; ! dWorldSetAutoDisableTime(mWorldID, ! defaults::ode::autoDisableTimeMax - value * range); ! Simulator::setSleepiness(value); ! } void ODESimulator::setSolverAccuracy(SolverAccuracyLevel level) --- 779,823 ---- } ! //void ODESimulator::setDefaultSleepiness(real value) ! //{ ! // Simulator::setDefaultSleepiness(value); ! // if (0 == value) ! // { ! // // No default sleeping for new Solids. ! // dWorldSetAutoDisableFlag(mWorldID, false); ! // } ! // else ! // { ! // // Enable default sleeping for new Solids. ! // dWorldSetAutoDisableFlag(mWorldID, true); ! // } ! // // As value goes from 0.0 to 1.0: ! // // AutoDisableLinearThreshold goes from min to max, ! // // AutoDisableAngularThreshold goes from min to max, ! // // AutoDisableSteps goes from max to min, ! // // AutoDisableTime goes from max to min. ! // real range = defaults::ode::autoDisableLinearMax - ! // defaults::ode::autoDisableLinearMin; ! // dWorldSetAutoDisableLinearThreshold(mWorldID, value * range + ! // defaults::ode::autoDisableLinearMin); ! // range = defaults::ode::autoDisableAngularMax - ! // defaults::ode::autoDisableAngularMin; ! // dWorldSetAutoDisableAngularThreshold(mWorldID, value * range + ! // defaults::ode::autoDisableAngularMin); ! // range = (real)(defaults::ode::autoDisableStepsMax - ! // defaults::ode::autoDisableStepsMin); ! // dWorldSetAutoDisableSteps(mWorldID, ! // (int)((real)defaults::ode::autoDisableStepsMax - value * range)); ! // range = defaults::ode::autoDisableTimeMax - ! // defaults::ode::autoDisableTimeMin; ! // dWorldSetAutoDisableTime(mWorldID, ! // defaults::ode::autoDisableTimeMax - value * range); ! //} void ODESimulator::setSolverAccuracy(SolverAccuracyLevel level) Index: ODESolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** ODESolid.cpp 23 Feb 2005 06:35:46 -0000 1.70 --- ODESolid.cpp 25 Feb 2005 06:40:26 -0000 1.71 *************** *** 123,126 **** --- 123,129 ---- setSleeping(data.sleeping); + // Set the Solid's sleepiness level. + setSleepiness(data.sleepiness); + // Set whether the Solid is enabled. setEnabled(data.enabled); *************** *** 267,270 **** --- 270,277 ---- mBodyID = dBodyCreate(mWorldID); + // Set the ODE sleepiness params using the stored Solid + // sleepiness param. + setSleepiness(mData.sleepiness); + // Set the position of the new body. dMatrix3 R = *************** *** 403,406 **** --- 410,463 ---- } + void ODESolid::setSleepiness(real s) + { + Solid::setSleepiness(s); + + /// If this Solid has no ODE body, just return. The sleepiness + /// level will still be saved and applied if this Solid ever + /// becomes dynamic. + if (mData.isStatic) + { + return; + } + + if (0 == s) + { + // No sleeping at all for the Solid. + dBodySetAutoDisableFlag(mBodyID, false); + } + else + { + // Enable sleeping for the Solid.. + dBodySetAutoDisableFlag(mBodyID, true); + } + + // As value goes from 0.0 to 1.0: + // AutoDisableLinearThreshold goes from min to max, + // AutoDisableAngularThreshold goes from min to max, + // AutoDisableSteps goes from max to min, + // AutoDisableTime goes from max to min. + + real range = defaults::ode::autoDisableLinearMax - + defaults::ode::autoDisableLinearMin; + dBodySetAutoDisableLinearThreshold(mBodyID, s * range + + defaults::ode::autoDisableLinearMin); + + range = defaults::ode::autoDisableAngularMax - + defaults::ode::autoDisableAngularMin; + dBodySetAutoDisableAngularThreshold(mBodyID, s * range + + defaults::ode::autoDisableAngularMin); + + range = (real)(defaults::ode::autoDisableStepsMax - + defaults::ode::autoDisableStepsMin); + dBodySetAutoDisableSteps(mBodyID, + (int)((real)defaults::ode::autoDisableStepsMax - s * range)); + + range = defaults::ode::autoDisableTimeMax - + defaults::ode::autoDisableTimeMin; + dBodySetAutoDisableTime(mBodyID, + defaults::ode::autoDisableTimeMax - s * range); + } + void ODESolid::translateMass(const Vec3r& offset) { *************** *** 979,983 **** //} ! //bool ODESolid::getFastRotation() //{ // if (mStatic) --- 1036,1040 ---- //} ! //bool ODESolid::getFastRotation()const //{ // if (mStatic) *************** *** 1001,1005 **** //} ! real ODESolid::getMass() { if (mData.isStatic) --- 1058,1062 ---- //} ! real ODESolid::getMass()const { if (mData.isStatic) Index: ODESimulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.h,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** ODESimulator.h 23 Feb 2005 06:35:46 -0000 1.55 --- ODESimulator.h 25 Feb 2005 06:40:26 -0000 1.56 *************** *** 75,80 **** //convenience collision check function ! virtual void OPAL_CALL collide(const Solid* solid, ! std::vector<Solid*>* solids); //convenience ray casting function --- 75,80 ---- //convenience collision check function ! //virtual void OPAL_CALL collide(const Solid* solid, ! // std::vector<Solid*>* solids); //convenience ray casting function *************** *** 86,90 **** virtual Vec3r OPAL_CALL getGravity()const; ! virtual void OPAL_CALL setSleepiness(real value); virtual void OPAL_CALL setSolverAccuracy(SolverAccuracyLevel level); --- 86,90 ---- virtual Vec3r OPAL_CALL getGravity()const; ! //virtual void OPAL_CALL setDefaultSleepiness(real value); virtual void OPAL_CALL setSolverAccuracy(SolverAccuracyLevel level); Index: ODEJoint.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODEJoint.h,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ODEJoint.h 23 Feb 2005 03:58:23 -0000 1.28 --- ODEJoint.h 25 Feb 2005 06:40:26 -0000 1.29 *************** *** 57,61 **** //virtual void OPAL_CALL setLimits(int axisNum, JointLimits l); ! //virtual const JointLimits& OPAL_CALL getLimits(int axisNum); virtual void OPAL_CALL setEnabled(bool e); --- 57,61 ---- //virtual void OPAL_CALL setLimits(int axisNum, JointLimits l); ! //virtual const JointLimits& OPAL_CALL getLimits(int axisNum)const; virtual void OPAL_CALL setEnabled(bool e); *************** *** 87,93 **** /// Helper function to make it easier to get parameters for /// various ODE Joint types. ! //real getJointParam(int parameter); ! /// Returns the current amount of stress on this Joint. virtual real calcStress(); --- 87,93 ---- /// Helper function to make it easier to get parameters for /// various ODE Joint types. ! //real getJointParam(int parameter)const; ! /// Returns the current amount of stress on this Joint. virtual real calcStress(); Index: ODESolid.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.h,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** ODESolid.h 23 Feb 2005 04:56:49 -0000 1.62 --- ODESolid.h 25 Feb 2005 06:40:26 -0000 1.63 *************** *** 77,80 **** --- 77,82 ---- virtual bool OPAL_CALL isSleeping()const; + virtual void OPAL_CALL setSleepiness(real s); + virtual void OPAL_CALL setStatic(bool s); *************** *** 132,136 **** //virtual void OPAL_CALL setFastRotation(bool fast); ! //virtual bool OPAL_CALL getFastRotation(); //virtual void OPAL_CALL setFastRotationAxis(Vec3r axis); --- 134,138 ---- //virtual void OPAL_CALL setFastRotation(bool fast); ! //virtual bool OPAL_CALL getFastRotation()const; //virtual void OPAL_CALL setFastRotationAxis(Vec3r axis); *************** *** 138,142 **** /// Returns the Solid's mass. This will return 0 if the Solid /// is static. ! virtual real OPAL_CALL getMass(); virtual void OPAL_CALL internal_updateOPALTransform(); --- 140,144 ---- /// Returns the Solid's mass. This will return 0 if the Solid /// is static. ! virtual real OPAL_CALL getMass()const; virtual void OPAL_CALL internal_updateOPALTransform(); Index: ODEJoint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODEJoint.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** ODEJoint.cpp 23 Feb 2005 03:58:23 -0000 1.24 --- ODEJoint.cpp 25 Feb 2005 06:40:26 -0000 1.25 *************** *** 310,314 **** //} ! //const JointLimits& ODEJoint::getLimits(int axisNum) //{ --- 310,314 ---- //} ! //const JointLimits& ODEJoint::getLimits(int axisNum)const //{ *************** *** 752,756 **** } ! //real ODEJoint::getJointParam(int parameter) //{ // real value = 0; --- 752,756 ---- } ! //real ODEJoint::getJointParam(int parameter)const //{ // real value = 0; *************** *** 793,801 **** switch(mData.breakMode) { ! case UNBREAKABLE: ! //don't waste time calculating the stress here break; ! case THRESHOLD: //fall through... ! case ACCUMULATED: { dJointFeedback* jf = dJointGetFeedback(mJointID); --- 793,802 ---- switch(mData.breakMode) { ! case UNBREAKABLE_MODE: ! // Nothing to do. break; ! case THRESHOLD_MODE: ! // Fall through... ! case ACCUMULATED_MODE: { dJointFeedback* jf = dJointGetFeedback(mJointID); *************** *** 805,809 **** Vec3r t2(jf->t2[0], jf->t2[1], jf->t2[2]); ! //this is a simplification, but it should still work currentStress = f1.length() + t1.length() + f2.length() + t2.length(); --- 806,810 ---- Vec3r t2(jf->t2[0], jf->t2[1], jf->t2[2]); ! // This is a simplification, but it should still work. currentStress = f1.length() + t1.length() + f2.length() + t2.length(); |
|
From: tylerstreeter <tyl...@us...> - 2005-02-25 06:40:37
|
Update of /cvsroot/opal/opal/vc7 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5241/vc7 Modified Files: opal-ode.vcproj Log Message: updated XML parsing to reflect new object creation method Index: opal-ode.vcproj =================================================================== RCS file: /cvsroot/opal/opal/vc7/opal-ode.vcproj,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** opal-ode.vcproj 23 Feb 2005 03:58:24 -0000 1.12 --- opal-ode.vcproj 25 Feb 2005 06:40:26 -0000 1.13 *************** *** 122,125 **** --- 122,128 ---- </File> <File + RelativePath="..\src\BlueprintInstance.cpp"> + </File> + <File RelativePath="..\src\BlueprintManager.cpp"> </File> *************** *** 131,134 **** --- 134,140 ---- </File> <File + RelativePath="..\src\Logger.cpp"> + </File> + <File RelativePath="..\src\Motor.cpp"> </File> *************** *** 146,149 **** --- 152,158 ---- </File> <File + RelativePath="..\src\SolidData.cpp"> + </File> + <File RelativePath="..\src\SpringMotor.cpp"> </File> *************** *** 165,168 **** --- 174,180 ---- </File> <File + RelativePath="..\src\BlueprintInstance.h"> + </File> + <File RelativePath="..\src\BlueprintManager.h"> </File> *************** *** 192,195 **** --- 204,210 ---- </File> <File + RelativePath="..\src\Logger.h"> + </File> + <File RelativePath="..\src\MeshShapeData.h"> </File> |
|
From: tylerstreeter <tyl...@us...> - 2005-02-23 06:35:56
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19126/src Modified Files: Simulator.cpp Simulator.h SolidData.h Log Message: minor fixes Index: SolidData.h =================================================================== RCS file: /cvsroot/opal/opal/src/SolidData.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SolidData.h 23 Feb 2005 04:56:49 -0000 1.4 --- SolidData.h 23 Feb 2005 06:35:46 -0000 1.5 *************** *** 31,34 **** --- 31,40 ---- #include "Defines.h" #include "ShapeData.h" + #include "BoxShapeData.h" + #include "SphereShapeData.h" + #include "CapsuleShapeData.h" + #include "PlaneShapeData.h" + #include "RayShapeData.h" + #include "MeshShapeData.h" namespace opal *************** *** 59,66 **** virtual ~SolidData() { ! while (!shapes.empty()) { ! delete shapes.back(); ! shapes.pop_back(); } } --- 65,134 ---- virtual ~SolidData() { ! destroyShapes(); ! } ! ! /// Adds a new Shape to the SolidData. This automatically ! /// allocates the right ShapeData type. ! virtual void OPAL_CALL addShape(const ShapeData& data) ! { ! ShapeData* newShape = NULL; ! ! switch(data.getType()) { ! case BOX_SHAPE: ! { ! newShape = new BoxShapeData((BoxShapeData&)data); ! break; ! } ! case SPHERE_SHAPE: ! { ! newShape = new SphereShapeData((SphereShapeData&)data); ! break; ! } ! case CAPSULE_SHAPE: ! { ! newShape = new CapsuleShapeData((CapsuleShapeData&)data); ! break; ! } ! case PLANE_SHAPE: ! { ! newShape = new PlaneShapeData((PlaneShapeData&)data); ! break; ! } ! case RAY_SHAPE: ! { ! newShape = new RayShapeData((RayShapeData&)data); ! break; ! } ! case MESH_SHAPE: ! { ! newShape = new MeshShapeData((MeshShapeData&)data); ! break; ! } ! default: ! assert(false); ! } ! ! mShapes.push_back(newShape); ! } ! ! /// Returns the number of Shapes in this SolidData. ! virtual int OPAL_CALL getNumShapes()const ! { ! return (int)(mShapes.size()); ! } ! /// Returns a pointer to the ShapeData at the given index. ! virtual ShapeData* OPAL_CALL getShapeData(unsigned int i)const ! { ! return mShapes.at(i); ! } ! ! /// Destroys all Shapes in the SolidData. ! virtual void OPAL_CALL destroyShapes() ! { ! while (!mShapes.empty()) ! { ! delete mShapes.back(); ! mShapes.pop_back(); } } *************** *** 95,101 **** real linearDamping; real angularDamping; ! std::vector<ShapeData*> shapes; ! protected: private: --- 163,169 ---- real linearDamping; real angularDamping; ! protected: + std::vector<ShapeData*> mShapes; private: Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** Simulator.cpp 22 Feb 2005 01:25:55 -0000 1.34 --- Simulator.cpp 23 Feb 2005 06:35:46 -0000 1.35 *************** *** 66,70 **** } ! internal_collectGarbage(); while (!mSpaceList.empty()) --- 66,70 ---- } ! collectGarbage(); while (!mSpaceList.empty()) *************** *** 220,224 **** // Deallocate memory here now that it's safe. ! internal_collectGarbage(); return stepOccurred; --- 220,224 ---- // Deallocate memory here now that it's safe. ! collectGarbage(); return stepOccurred; *************** *** 741,745 **** } ! void Simulator::internal_collectGarbage() { for (size_t i=0; i<mSolidGarbageList.size(); ++i) --- 741,745 ---- } ! void Simulator::collectGarbage() { for (size_t i=0; i<mSolidGarbageList.size(); ++i) Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** Simulator.h 22 Feb 2005 01:25:55 -0000 1.73 --- Simulator.h 23 Feb 2005 06:35:46 -0000 1.74 *************** *** 132,136 **** /// A convenient volume collision check function. TODO: replace ! /// with a Sensor. virtual void OPAL_CALL collide(const Solid* solid, std::vector<Solid*>* solids) = 0; --- 132,138 ---- /// A convenient volume collision check function. TODO: replace ! /// with a Sensor. TODO: the vector pointer here is bad because ! /// memory is allocated within the DLL and deallocated on the ! /// user's side virtual void OPAL_CALL collide(const Solid* solid, std::vector<Solid*>* solids) = 0; *************** *** 138,143 **** /// A convenient ray casting function. TODO: replace with a /// Sensor. ! virtual void OPAL_CALL shootRay(const Point3r& origin, ! const Vec3r& dir, real length, RayHit& rayHit) = 0; /// Sets the gravity used in the simulation. --- 140,145 ---- /// A convenient ray casting function. TODO: replace with a /// Sensor. ! virtual RayHit OPAL_CALL shootRay(const Point3r& origin, ! const Vec3r& dir, real length) = 0; /// Sets the gravity used in the simulation. *************** *** 145,149 **** /// Returns the gravity used in the simulation. ! virtual void OPAL_CALL getGravity(Vec3r& gravity)const = 0; virtual void OPAL_CALL setSleepiness(real value); --- 147,151 ---- /// Returns the gravity used in the simulation. ! virtual Vec3r OPAL_CALL getGravity()const = 0; virtual void OPAL_CALL setSleepiness(real value); *************** *** 268,272 **** /// Destroys all objects in the Simulator marked as garbage. ! void internal_collectGarbage(); /// Adds a Solid to the internal list of Solids. --- 270,274 ---- /// Destroys all objects in the Simulator marked as garbage. ! void collectGarbage(); /// Adds a Solid to the internal list of Solids. |
|
From: tylerstreeter <tyl...@us...> - 2005-02-23 06:35:55
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19126/src/ODE Modified Files: ODESimulator.cpp ODESimulator.h ODESolid.cpp Log Message: minor fixes Index: ODESimulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.h,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** ODESimulator.h 22 Feb 2005 01:25:56 -0000 1.54 --- ODESimulator.h 23 Feb 2005 06:35:46 -0000 1.55 *************** *** 79,88 **** //convenience ray casting function ! virtual void OPAL_CALL shootRay(const Point3r& origin, ! const Vec3r& dir, real length, RayHit& rayHit); virtual void OPAL_CALL setGravity(const Vec3r& gravity); ! virtual void OPAL_CALL getGravity(Vec3r& gravity)const; virtual void OPAL_CALL setSleepiness(real value); --- 79,88 ---- //convenience ray casting function ! virtual RayHit OPAL_CALL shootRay(const Point3r& origin, ! const Vec3r& dir, real length); virtual void OPAL_CALL setGravity(const Vec3r& gravity); ! virtual Vec3r OPAL_CALL getGravity()const; virtual void OPAL_CALL setSleepiness(real value); Index: ODESimulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.cpp,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** ODESimulator.cpp 22 Feb 2005 01:25:56 -0000 1.78 --- ODESimulator.cpp 23 Feb 2005 06:35:46 -0000 1.79 *************** *** 738,743 **** } ! void ODESimulator::shootRay(const Point3r& origin, const Vec3r& dir, ! real length, RayHit& rayHit) { mRayHit.solid = NULL; --- 738,743 ---- } ! RayHit ODESimulator::shootRay(const Point3r& origin, const Vec3r& dir, ! real length) { mRayHit.solid = NULL; *************** *** 754,757 **** --- 754,758 ---- &ode_hidden::internal_rayCastingCollisionCallback); + RayHit rayHit; rayHit.solid = mRayHit.solid; //note that this may remain NULL rayHit.intersection = mRayHit.intersection; *************** *** 761,764 **** --- 762,767 ---- // finished with ray, so destroy it dGeomDestroy(rayGeomID); + + return rayHit; } *************** *** 768,775 **** } ! void ODESimulator::getGravity(Vec3r& gravity)const { ! dReal vec[3] = {gravity[0], gravity[1], gravity[2]}; ! dWorldGetGravity(mWorldID, vec); } --- 771,780 ---- } ! Vec3r ODESimulator::getGravity()const { ! dVector3 g; ! dWorldGetGravity(mWorldID, g); ! Vec3r gravity(g[0], g[1], g[2]); ! return gravity; } Index: ODESolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** ODESolid.cpp 23 Feb 2005 04:56:49 -0000 1.69 --- ODESolid.cpp 23 Feb 2005 06:35:46 -0000 1.70 *************** *** 103,111 **** { // Destroy the old Shapes. ! while (!mData.shapes.empty()) ! { ! delete mData.shapes.back(); ! mData.shapes.pop_back(); ! } // Destroy the old ODE geoms. --- 103,107 ---- { // Destroy the old Shapes. ! mData.destroyShapes(); // Destroy the old ODE geoms. *************** *** 119,125 **** // Add the new Shapes. ! for (unsigned int i=0; i<data.shapes.size(); ++i) { ! addShape(*(data.shapes[i])); } --- 115,121 ---- // Add the new Shapes. ! for (int i=0; i<data.getNumShapes(); ++i) { ! addShape(*(data.getShapeData(i))); } *************** *** 425,429 **** dSpaceID spaceID = NULL; dMass newMass; - ShapeData* newShape = NULL; if(Matrix44r() == data.offset) --- 421,424 ---- *************** *** 460,464 **** (dReal)boxData.dimensions[1], (dReal)boxData.dimensions[2]); - newShape = new BoxShapeData(boxData); break; } --- 455,458 ---- *************** *** 470,474 **** dMassSetSphere(&newMass, (dReal)data.material.density, (dReal)sphereData.radius); - newShape = new SphereShapeData(sphereData); break; } --- 464,467 ---- *************** *** 486,490 **** dMassSetCappedCylinder(&newMass, (dReal)data.material.density, 3, (dReal)capsuleData.radius, (dReal)capsuleData.length); - newShape = new CapsuleShapeData(capsuleData); break; } --- 479,482 ---- *************** *** 519,523 **** // Solids with planes are the only "placeable" Solids. mIsPlaceable = false; - newShape = new PlaneShapeData(planeData); break; } --- 511,514 ---- *************** *** 533,537 **** (dReal)dir[2]); // Note: rays don't have mass. - newShape = new RayShapeData(rayData); break; } --- 524,527 ---- *************** *** 553,558 **** // or just enforce that all mesh must be static. dMassSetSphere(&newMass, (dReal)data.material.density, 1); - - newShape = new MeshShapeData(meshData); break; } --- 543,546 ---- *************** *** 565,573 **** // Store new Shape. ! mData.shapes.push_back(newShape); // Setup GeomData. newGeomData->solid = this; ! newGeomData->shape = newShape; newGeomData->geomID = newGeomID; newGeomData->transformID = newTransformID; --- 553,561 ---- // Store new Shape. ! mData.addShape(data); // Setup GeomData. newGeomData->solid = this; ! newGeomData->shape = mData.getShapeData(mData.getNumShapes() - 1); newGeomData->geomID = newGeomID; newGeomData->transformID = newTransformID; |
|
From: tylerstreeter <tyl...@us...> - 2005-02-23 06:35:55
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19126 Modified Files: todo.txt Log Message: minor fixes Index: todo.txt =================================================================== RCS file: /cvsroot/opal/opal/todo.txt,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** todo.txt 23 Feb 2005 03:58:24 -0000 1.43 --- todo.txt 23 Feb 2005 06:35:46 -0000 1.44 *************** *** 4,14 **** Joints, Solids, etc. -> JointData, SolidData, etc. -> Blueprint -> saveToXML(Blueprint, filename) ... loadFromXML(filename) -> Blueprint -> JointData, SolidData, etc. -> Joints, Solids, etc. - * joints - - one init function: takes separate params - - other init: takes a bp - - can be init'd more than once with different types - - * all objects have an init function that takes a data object - * look at scons dylib-building problem on os x --- 4,7 ---- *************** *** 28,41 **** * all modes with multiple options (e.g. spring motor, accel sensor) should take bit flags - * "BP" (blueprint) structs/classes - - all parameters use defaults from Defines.h - - search and replace "blueprint" with "BP", except for the base Blueprint class - - overloaded init functions (or "loadFromBP") can take these instead of individual params - - objects each have "saveToBP(BP&)" functions - - how do different BPs refer to other objects? by name? by int id? - - shapes can be added to solids in two ways (or should we just do one?) - - add a ShapeBP to a SolidBP, then create the Solid - - create a Solid, then add a shape by passing it a ShapeBP - * XML loader, manager - update parsing --- 21,24 ---- *************** *** 46,51 **** - BPs can be requested by name/ID - * reenable collision detection for static-static, static-sleeping cases (or have an option) - * fix naming descrepancies - desiredPos, desiredPosition, getState, getVelocity, etc. --- 29,32 ---- *************** *** 60,63 **** --- 41,47 ---- * Add a boolean to Solid that determines if it generates contacts at all (the docking volume shouldn't collide with anything but should generate collision events still). + - maybe look at a more powerful solution with collide flags + + * reenable collision detection for static-static, static-sleeping cases (or have an option) * change description (on website and sf project page) to highlight the main attractions *************** *** 84,88 **** * implement sensors - RayCastSensor (i.e. "PSD (position sensitive detector)" or "rangefinder"): measures distance from sensor to first intersection (attach to a solid [be sure to ignore collisions with the attached solid] or nothing) ! - must be updated manually by user? (to keep raycasting from getting call every step) - ContactSensor - hold a queue of contact events (attach to a solid, to a single shape, or to nothing?) --- 68,74 ---- * implement sensors - RayCastSensor (i.e. "PSD (position sensitive detector)" or "rangefinder"): measures distance from sensor to first intersection (attach to a solid [be sure to ignore collisions with the attached solid] or nothing) ! - not updated regularly; must be updated manually by user ! - VolumeSensor (i.e. "proximity sensor?"): similar to RayCastSensor, but for a volume; finds all Solids colliding with a given (attached) Solid ! - not updated regularly; must be updated manually by user - ContactSensor - hold a queue of contact events (attach to a solid, to a single shape, or to nothing?) *************** *** 100,103 **** --- 86,90 ---- * look at (and maybe remove) mass ratio stuff + - there may be a problem when you have a tiny object between two massive objects; one massive object should affect the other but can't Build System *************** *** 109,114 **** * add SConstructs to samples - * put headers in separate dir from source? (e.g. root contains src, include) - Possible Ideas ============== --- 96,99 ---- *************** *** 270,273 **** --- 255,267 ---- - custom Motors + * Most objects can be created in two ways + - create the object (automatically uses default values); change specific parameters + - setup a Data object and pass it into the object's init function + - some objects (e.g. Joints) must have init called before using them + + * Shapes can be added to solids in two ways + - add a ShapeBP to a SolidBP, then create the Solid + - create a Solid, then add a shape by passing it a ShapeBP + * custom motors cannot be saved to/loaded from an XML file |
|
From: tylerstreeter <tyl...@us...> - 2005-02-23 04:56:58
|
Update of /cvsroot/opal/opal/samples/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27467/samples/src Modified Files: CarObject.cpp Log Message: added Solid init function; fixed sample apps Index: CarObject.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/src/CarObject.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** CarObject.cpp 22 Feb 2005 19:46:26 -0000 1.20 --- CarObject.cpp 23 Feb 2005 04:56:48 -0000 1.21 *************** *** 53,60 **** // Setup a JointData object to reuse for several Joints. ! opal::JointData jd; ! jd.solid0 = mBody; ! jd.axis[0] = suspensionAxis; ! jd.axis[1] = wheelAxis; // Setup a SphereData object to reuse for the wheels. --- 53,60 ---- // Setup a JointData object to reuse for several Joints. ! opal::JointData jointData; ! jointData.solid0 = mBody; ! jointData.axis[0] = suspensionAxis; ! jointData.axis[1] = wheelAxis; // Setup a SphereData object to reuse for the wheels. *************** *** 72,79 **** // Add front left Joint. mFLJoint = sim->createJoint(); ! jd.type = opal::HINGE_2_JOINT; ! jd.solid1 = mFLWheel; ! jd.anchor = M.getPosition(); ! mFLJoint->init(jd); // Add front right wheel Solid. --- 72,79 ---- // Add front left Joint. mFLJoint = sim->createJoint(); ! jointData.setType(opal::HINGE_2_JOINT); ! jointData.solid1 = mFLWheel; ! jointData.anchor = M.getPosition(); ! mFLJoint->init(jointData); // Add front right wheel Solid. *************** *** 86,93 **** // Add front right Joint. mFRJoint = sim->createJoint(); ! jd.type = opal::HINGE_2_JOINT; ! jd.solid1 = mFRWheel; ! jd.anchor = M.getPosition(); ! mFRJoint->init(jd); // Add rear left wheel. --- 86,93 ---- // Add front right Joint. mFRJoint = sim->createJoint(); ! jointData.setType(opal::HINGE_2_JOINT); ! jointData.solid1 = mFRWheel; ! jointData.anchor = M.getPosition(); ! mFRJoint->init(jointData); // Add rear left wheel. *************** *** 100,108 **** // Add rear left Joint. mRLJoint = sim->createJoint(); ! jd.type = opal::HINGE_JOINT; ! jd.solid1 = mRLWheel; ! jd.anchor = M.getPosition(); ! jd.axis[0] = wheelAxis; ! mRLJoint->init(jd); // Add rear right wheel. --- 100,108 ---- // Add rear left Joint. mRLJoint = sim->createJoint(); ! jointData.setType(opal::HINGE_JOINT); ! jointData.solid1 = mRLWheel; ! jointData.anchor = M.getPosition(); ! jointData.axis[0] = wheelAxis; ! mRLJoint->init(jointData); // Add rear right wheel. *************** *** 115,123 **** // Add rear right Joint. mRRJoint = sim->createJoint(); ! jd.type = opal::HINGE_JOINT; ! jd.solid1 = mRRWheel; ! jd.anchor = M.getPosition(); ! jd.axis[0] = wheelAxis; ! mRRJoint->init(jd); //translate mass downward to keep car from rolling --- 115,123 ---- // Add rear right Joint. mRRJoint = sim->createJoint(); ! jointData.setType(opal::HINGE_JOINT); ! jointData.solid1 = mRRWheel; ! jointData.anchor = M.getPosition(); ! jointData.axis[0] = wheelAxis; ! mRRJoint->init(jointData); //translate mass downward to keep car from rolling *************** *** 133,146 **** //mRRHinge->setBreakParams(opal::THRESHOLD, 2000.0, 0.0); mFLMotor = sim->createGearedMotor(); ! mFLMotor->init(mFLJoint, 1); ! mFLMotor->setMaxTorque(15); ! mFLMotor->setMaxVelocity(5000); ! mFRMotor = sim->createGearedMotor(); ! mFRMotor->init(mFRJoint, 1); ! mFRMotor->setMaxTorque(15); ! mFRMotor->setMaxVelocity(5000); ! //mBody->setTransform(transform); } --- 133,151 ---- //mRRHinge->setBreakParams(opal::THRESHOLD, 2000.0, 0.0); + // Setup a GearedMotorData object to reuse for both front wheels. + opal::GearedMotorData motorData; + motorData.joint = mFLJoint; + motorData.jointAxisNum = 1; + motorData.maxTorque = 15; + motorData.maxVelocity = 5000; + + // Create and setup the front left Motor. mFLMotor = sim->createGearedMotor(); ! mFLMotor->init(motorData); ! // Create and setup the front right Motor. ! mFRMotor = sim->createGearedMotor(); ! motorData.joint = mFRJoint; ! mFRMotor->init(motorData); } |
|
From: tylerstreeter <tyl...@us...> - 2005-02-23 04:56:58
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27467 Modified Files: changelog.txt Log Message: added Solid init function; fixed sample apps Index: changelog.txt =================================================================== RCS file: /cvsroot/opal/opal/changelog.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** changelog.txt 17 Feb 2005 06:13:26 -0000 1.8 --- changelog.txt 23 Feb 2005 04:56:48 -0000 1.9 *************** *** 2,5 **** --- 2,6 ---- , 2005 ------------------------------------------ + * New additional object creation system: all objects can be created from/saved to a data structure * Separate Joint types were combined into a single Joint class * Numerous API changes |
|
From: tylerstreeter <tyl...@us...> - 2005-02-23 04:56:58
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27467/src/ODE Modified Files: ODESolid.cpp ODESolid.h Log Message: added Solid init function; fixed sample apps Index: ODESolid.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.h,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** ODESolid.h 23 Feb 2005 03:58:23 -0000 1.61 --- ODESolid.h 23 Feb 2005 04:56:49 -0000 1.62 *************** *** 67,70 **** --- 67,72 ---- virtual ~ODESolid(); + virtual void OPAL_CALL init(const SolidData& data); + virtual void OPAL_CALL setEnabled(bool e); *************** *** 159,162 **** --- 161,167 ---- void setupNewGeom(GeomData* newGeom); + /// Destroys all of this Solid's ODE geoms. + void destroyGeoms(); + virtual void applyForce(const Force& f); Index: ODESolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** ODESolid.cpp 23 Feb 2005 03:58:23 -0000 1.68 --- ODESolid.cpp 23 Feb 2005 04:56:49 -0000 1.69 *************** *** 59,62 **** --- 59,74 ---- ODESolid::~ODESolid() { + destroyGeoms(); + + if (!mData.isStatic) + { + // This is a dynamic solid, so it has an ODE body that needs + // to be destroyed. + dBodyDestroy(mBodyID); + } + } + + void ODESolid::destroyGeoms() + { while (!mGeomDataList.empty()) { *************** *** 72,80 **** if (0 != mGeomDataList.back()->trimeshDataID) { ! // This geom uses a trimesh. Destroy it. dGeomTriMeshDataDestroy(mGeomDataList.back()->trimeshDataID); } ! // Destroy the actual geom. dGeomDestroy(mGeomDataList.back()->geomID); --- 84,94 ---- if (0 != mGeomDataList.back()->trimeshDataID) { ! // This geom uses a trimesh. Destroy it. (This does NOT ! // touch the user's mesh data, just internal ODE trimesh ! // data.) dGeomTriMeshDataDestroy(mGeomDataList.back()->trimeshDataID); } ! // Destroy the ODE geom. dGeomDestroy(mGeomDataList.back()->geomID); *************** *** 84,94 **** mGeomDataList.pop_back(); } ! if (!mData.isStatic) { ! // this is a dynamic solid, so it has an ODE body that needs to be ! // destroyed ! dBodyDestroy(mBodyID); } } --- 98,140 ---- mGeomDataList.pop_back(); } + } ! void ODESolid::init(const SolidData& data) ! { ! // Destroy the old Shapes. ! while (!mData.shapes.empty()) { ! delete mData.shapes.back(); ! mData.shapes.pop_back(); } + + // Destroy the old ODE geoms. + destroyGeoms(); + + // Set whether the Solid is static. + setStatic(data.isStatic); + + // Set the new transform. + setTransform(data.transform); + + // Add the new Shapes. + for (unsigned int i=0; i<data.shapes.size(); ++i) + { + addShape(*(data.shapes[i])); + } + + // Set whether the Solid is sleeping. + setSleeping(data.sleeping); + + // Set whether the Solid is enabled. + setEnabled(data.enabled); + + // Set damping levels. + setLinearDamping(data.linearDamping); + setAngularDamping(data.angularDamping); + + // Set velocities. + setGlobalLinearVel(data.globalLinearVel); + setGlobalAngularVel(data.globalAngularVel); } |
|
From: tylerstreeter <tyl...@us...> - 2005-02-23 04:56:58
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27467/src Modified Files: Defines.h Joint.h SensorData.h Solid.h SolidData.h Log Message: added Solid init function; fixed sample apps Index: SolidData.h =================================================================== RCS file: /cvsroot/opal/opal/src/SolidData.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SolidData.h 23 Feb 2005 03:58:23 -0000 1.3 --- SolidData.h 23 Feb 2005 04:56:49 -0000 1.4 *************** *** 51,59 **** } ! /// Copy constructor. ! SolidData(const SolidData& data) ! { ! (*this) = data; ! } virtual ~SolidData() --- 51,59 ---- } ! ///// Copy constructor. ! //SolidData(const SolidData& data) ! //{ ! // (*this) = data; ! //} virtual ~SolidData() *************** *** 66,87 **** } ! /// Makes a deep copy. ! virtual void OPAL_CALL operator=(const SolidData& data) ! { ! enabled = data.enabled; ! sleeping = data.sleeping; ! isStatic = data.isStatic; ! transform = data.transform; ! globalLinearVel = data.globalLinearVel; ! globalAngularVel = data.globalAngularVel; ! linearDamping = data.linearDamping; ! angularDamping = data.angularDamping; ! shapes.clear(); ! for (unsigned int i=0; i<data.shapes.size(); ++i) ! { ! shapes.push_back(data.shapes[i]); ! } ! } bool enabled; --- 66,89 ---- } ! ///// Makes a deep copy. ! //virtual void OPAL_CALL operator=(const SolidData& data) ! //{ ! // enabled = data.enabled; ! // sleeping = data.sleeping; ! // isStatic = data.isStatic; ! // transform = data.transform; ! // globalLinearVel = data.globalLinearVel; ! // globalAngularVel = data.globalAngularVel; ! // linearDamping = data.linearDamping; ! // angularDamping = data.angularDamping; ! // shapes.clear(); ! // for (unsigned int i=0; i<data.shapes.size(); ++i) ! // { ! // // TODO: need an actual ShapeData allocated here, but it ! // // must be the right type. ! // shapes.push_back(data.shapes[i]); ! // } ! //} bool enabled; Index: SensorData.h =================================================================== RCS file: /cvsroot/opal/opal/src/SensorData.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SensorData.h 23 Feb 2005 03:58:23 -0000 1.1 --- SensorData.h 23 Feb 2005 04:56:49 -0000 1.2 *************** *** 56,60 **** /// Returns the Sensor's type. ! virtual SensorData OPAL_CALL getType()const { return mType; --- 56,60 ---- /// Returns the Sensor's type. ! virtual SensorType OPAL_CALL getType()const { return mType; Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** Defines.h 23 Feb 2005 03:58:23 -0000 1.58 --- Defines.h 23 Feb 2005 04:56:49 -0000 1.59 *************** *** 293,297 **** { const JointType type = HINGE_JOINT; ! const bool enabled = false; const real lowLimit = 0; const real highLimit = 0; --- 293,297 ---- { const JointType type = HINGE_JOINT; ! const bool enabled = true; const real lowLimit = 0; const real highLimit = 0; *************** *** 312,316 **** namespace motor { ! const bool enabled = false; /// Default parameters used in AttractorMotor creation. --- 312,316 ---- namespace motor { ! const bool enabled = true; /// Default parameters used in AttractorMotor creation. Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** Solid.h 23 Feb 2005 03:58:23 -0000 1.75 --- Solid.h 23 Feb 2005 04:56:49 -0000 1.76 *************** *** 229,232 **** --- 229,237 ---- virtual ~Solid(); + /// Initializes the Solid with the given data structure. Calling + /// this more than once will automatically destroy all the old + /// Shapes before adding new ones. + virtual void OPAL_CALL init(const SolidData& data) = 0; + /// Returns all data describing the Solid. virtual const SolidData& OPAL_CALL getSolidData(); Index: Joint.h =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.h,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** Joint.h 23 Feb 2005 03:58:23 -0000 1.54 --- Joint.h 23 Feb 2005 04:56:49 -0000 1.55 *************** *** 70,76 **** // const JointAxis& axis2=JointAxis()) = 0; ! /// Initializes the Joint from a Joint blueprint. Calling this ! /// more than once will automatically detach the Joint from its ! /// old Solids first. virtual void OPAL_CALL init(const JointData& data); --- 70,76 ---- // const JointAxis& axis2=JointAxis()) = 0; ! /// Initializes the Joint with the given data structure. Calling ! /// this more than once will automatically detach the Joint from ! /// its old Solids first. virtual void OPAL_CALL init(const JointData& data); |
|
From: tylerstreeter <tyl...@us...> - 2005-02-23 03:58:38
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10148 Modified Files: todo.txt Log Message: added MotorData and JointData classes Index: todo.txt =================================================================== RCS file: /cvsroot/opal/opal/todo.txt,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** todo.txt 21 Feb 2005 15:54:43 -0000 1.42 --- todo.txt 23 Feb 2005 03:58:24 -0000 1.43 *************** *** 1,52 **** - Objects - - classes - - Simulator - - Solid - - Joint - - Motor - - Sensor - - Blueprint - - Data objects - - dependencies - - Solids -> nothing - - Joints -> Solids - - Motors -> Joints, Solids - - Sensors -> Joints Solids - - SolidData - - enabled - - variable number of ShapeDatas (*actual or references?) - - ShapeData (many different types) - - Shape type - - maybe have a MeshData too to assist Mesh creation? - - JointData - - enabled - - Joint type - - 2 SolidData references - - anchor point - - 3 Joint axes (unneeded axes will be ignored) - - MotorData (many different types) - - enabled - - Motor type - - constant number of SolidData references - - constant number of JointData references - - SensorData (many different types) - - enabled - - 0 or 1 SolidData references - - Blueprint: contains lots of Data objects - - other structs - - Material - - RayHit - - collision event - - Force - - Joint axis - - vector/direction - - limit - - limit enabled - - Joint limit - - low, high value - - hardness - - bounciness - - For Version 0.3.0 ================= --- 1,2 ---- *************** *** 61,66 **** * all objects have an init function that takes a data object - * should simulator create functions take data objects to initialize things automatically? - * look at scons dylib-building problem on os x --- 11,14 ---- *************** *** 80,88 **** * all modes with multiple options (e.g. spring motor, accel sensor) should take bit flags - * all structs have constructors (that use default params) - - * all object constructors: - - instead of setting params from defaults directly, create a BP (which automatically uses the defaults params), then call loadFromBP - * "BP" (blueprint) structs/classes - all parameters use defaults from Defines.h --- 28,31 ---- *************** *** 103,108 **** - BPs can be requested by name/ID - * joint setup: put setSolids, axes, and anchor in a single function - * reenable collision detection for static-static, static-sleeping cases (or have an option) --- 46,49 ---- *************** *** 120,125 **** * Add a boolean to Solid that determines if it generates contacts at all (the docking volume shouldn't collide with anything but should generate collision events still). - * for objects with multiple types (e.g. joints, sensors, motors) should we have multiple create functions that each return different types, or just one create function (which returns a single type ptr), then call init in different ways (or loadFromBP) to create different types? - * change description (on website and sf project page) to highlight the main attractions - cross-platform --- 61,64 ---- *************** *** 192,195 **** --- 131,139 ---- * change the internal_dependsOn functions -> have bidirectional references (dependency lists) so we don't have to search lists for dependencies + - dependencies + - Solids -> nothing + - Joints -> Solids + - Motors -> Joints, Solids + - Sensors -> Joints Solids * Put BlueprintManager stuff into the Simulator itself and remove BlueprintManager? *************** *** 281,284 **** --- 225,252 ---- The main objects in OPAL are: simulators, solids, joints, and motors. Create a simulator, have the simulator create solids for you, add shapes to the solids, and add forces to the solids. Solids can take an initial matrix transform. Shapes added to a solid can take a matrix transform as an offset from the solid's center. A solid can return its transform matrix for drawing purposes (if a solid has multiple shapes, be sure to save their offset matrices for drawing later). Solids can be static, meaning that they don't move around in the simulation. + Objects + - classes + - Simulator + - Solid + - Joint + - Motor + - Sensor + - Blueprint + - Data objects + - SolidData + - ShapeData (many different sub-types) + - Shape type + - JointData + - MotorData (many different sub-types) + - SensorData (many different sub-types) + - Blueprint: contains lots of Data objects + - other structs + - Material + - RayHit + - collision event + - Force + - Joint axis + - Joint limit + Document ======== |
|
From: tylerstreeter <tyl...@us...> - 2005-02-23 03:58:38
|
Update of /cvsroot/opal/opal/vc7 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10148/vc7 Modified Files: opal-ode.vcproj Log Message: added MotorData and JointData classes Index: opal-ode.vcproj =================================================================== RCS file: /cvsroot/opal/opal/vc7/opal-ode.vcproj,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** opal-ode.vcproj 22 Feb 2005 04:28:12 -0000 1.11 --- opal-ode.vcproj 23 Feb 2005 03:58:24 -0000 1.12 *************** *** 159,162 **** --- 159,165 ---- </File> <File + RelativePath="..\src\AttractorMotorData.h"> + </File> + <File RelativePath="..\src\Blueprint.h"> </File> *************** *** 180,186 **** --- 183,195 ---- </File> <File + RelativePath="..\src\GearedMotorData.h"> + </File> + <File RelativePath="..\src\Joint.h"> </File> <File + RelativePath="..\src\JointData.h"> + </File> + <File RelativePath="..\src\MeshShapeData.h"> </File> *************** *** 189,192 **** --- 198,204 ---- </File> <File + RelativePath="..\src\MotorData.h"> + </File> + <File RelativePath="..\src\opal.h"> </File> *************** *** 204,210 **** --- 216,228 ---- </File> <File + RelativePath="..\src\SensorData.h"> + </File> + <File RelativePath="..\src\ServoMotor.h"> </File> <File + RelativePath="..\src\ServoMotorData.h"> + </File> + <File RelativePath="..\src\ShapeData.h"> </File> *************** *** 231,236 **** --- 249,260 ---- </File> <File + RelativePath="..\src\SpringMotorData.h"> + </File> + <File RelativePath="..\src\ThrusterMotor.h"> </File> + <File + RelativePath="..\src\ThrusterMotorData.h"> + </File> </Filter> <Filter |
|
From: tylerstreeter <tyl...@us...> - 2005-02-23 03:58:38
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10148/src/ODE Modified Files: ODEJoint.cpp ODEJoint.h ODESolid.cpp ODESolid.h Log Message: added MotorData and JointData classes Index: ODEJoint.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODEJoint.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** ODEJoint.h 22 Feb 2005 01:25:56 -0000 1.27 --- ODEJoint.h 23 Feb 2005 03:58:23 -0000 1.28 *************** *** 47,51 **** /// data should be stored in JointData. However, there is /// currently no easy way to get this data. ! virtual void OPAL_CALL init(const JointData& jd); virtual real OPAL_CALL getState(int axisNum)const; --- 47,51 ---- /// data should be stored in JointData. However, there is /// currently no easy way to get this data. ! virtual void OPAL_CALL init(const JointData& data); virtual real OPAL_CALL getState(int axisNum)const; Index: ODESolid.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.h,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** ODESolid.h 22 Feb 2005 01:25:57 -0000 1.60 --- ODESolid.h 23 Feb 2005 03:58:23 -0000 1.61 *************** *** 77,81 **** virtual void OPAL_CALL setStatic(bool s); ! virtual void OPAL_CALL addShape(const ShapeData& sd); //virtual void OPAL_CALL addBox(const Vec3r& dimensions, --- 77,81 ---- virtual void OPAL_CALL setStatic(bool s); ! virtual void OPAL_CALL addShape(const ShapeData& data); //virtual void OPAL_CALL addBox(const Vec3r& dimensions, Index: ODESolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** ODESolid.cpp 22 Feb 2005 19:46:40 -0000 1.67 --- ODESolid.cpp 23 Feb 2005 03:58:23 -0000 1.68 *************** *** 372,376 **** } ! void ODESolid::addShape(const ShapeData& sd) { dGeomID newGeomID = NULL; --- 372,376 ---- } ! void ODESolid::addShape(const ShapeData& data) { dGeomID newGeomID = NULL; *************** *** 381,385 **** ShapeData* newShape = NULL; ! if(Matrix44r() == sd.offset) { // No offset transform. --- 381,385 ---- ShapeData* newShape = NULL; ! if(Matrix44r() == data.offset) { // No offset transform. *************** *** 401,414 **** GeomData* newGeomData = new GeomData; ! switch(sd.getType()) { case BOX_SHAPE: { ! 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], --- 401,414 ---- GeomData* newGeomData = new GeomData; ! switch(data.getType()) { case BOX_SHAPE: { ! BoxShapeData& boxData = (BoxShapeData&)data; newGeomID = dCreateBox(spaceID, (dReal)boxData.dimensions[0], (dReal)boxData.dimensions[1], (dReal)boxData.dimensions[2]); ! dMassSetBox(&newMass, (dReal)data.material.density, (dReal)boxData.dimensions[0], (dReal)boxData.dimensions[1], *************** *** 419,426 **** 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); --- 419,426 ---- case SPHERE_SHAPE: { ! SphereShapeData& sphereData = (SphereShapeData&)data; newGeomID = dCreateSphere(spaceID, (dReal)sphereData.radius); ! dMassSetSphere(&newMass, (dReal)data.material.density, (dReal)sphereData.radius); newShape = new SphereShapeData(sphereData); *************** *** 429,433 **** case CAPSULE_SHAPE: { ! CapsuleShapeData& capsuleData = (CapsuleShapeData&)sd; newGeomID = dCreateCCylinder(spaceID, (dReal)capsuleData.radius, (dReal)capsuleData.length); --- 429,433 ---- case CAPSULE_SHAPE: { ! CapsuleShapeData& capsuleData = (CapsuleShapeData&)data; newGeomID = dCreateCCylinder(spaceID, (dReal)capsuleData.radius, (dReal)capsuleData.length); *************** *** 438,442 **** //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); --- 438,442 ---- //Maybe have a default value in the Simulator that the user can //change. ! dMassSetCappedCylinder(&newMass, (dReal)data.material.density, 3, (dReal)capsuleData.radius, (dReal)capsuleData.length); newShape = new CapsuleShapeData(capsuleData); *************** *** 445,449 **** case PLANE_SHAPE: { ! PlaneShapeData& planeData = (PlaneShapeData&)sd; if (!mData.isStatic) { --- 445,449 ---- case PLANE_SHAPE: { ! PlaneShapeData& planeData = (PlaneShapeData&)data; if (!mData.isStatic) { *************** *** 478,482 **** case RAY_SHAPE: { ! RayShapeData& rayData = (RayShapeData&)sd; newGeomID = dCreateRay(spaceID, (dReal)rayData.ray.getLength()); --- 478,482 ---- case RAY_SHAPE: { ! RayShapeData& rayData = (RayShapeData&)data; newGeomID = dCreateRay(spaceID, (dReal)rayData.ray.getLength()); *************** *** 492,496 **** case MESH_SHAPE: { ! MeshShapeData& meshData = (MeshShapeData&)sd; // Setup trimesh data pointer. It is critical that the --- 492,496 ---- case MESH_SHAPE: { ! MeshShapeData& meshData = (MeshShapeData&)data; // Setup trimesh data pointer. It is critical that the *************** *** 506,510 **** // 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); --- 506,510 ---- // TODO: either do more sophisticated mass calculations, // or just enforce that all mesh must be static. ! dMassSetSphere(&newMass, (dReal)data.material.density, 1); newShape = new MeshShapeData(meshData); *************** *** 516,520 **** // This will do nothing if this is a static Solid. ! addMass(newMass, sd.offset); // Store new Shape. --- 516,520 ---- // This will do nothing if this is a static Solid. ! addMass(newMass, data.offset); // Store new Shape. Index: ODEJoint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODEJoint.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** ODEJoint.cpp 22 Feb 2005 01:25:56 -0000 1.23 --- ODEJoint.cpp 23 Feb 2005 03:58:23 -0000 1.24 *************** *** 46,50 **** } ! void ODEJoint::init(const JointData& jd) { if (mInitCalled) --- 46,50 ---- } ! void ODEJoint::init(const JointData& data) { if (mInitCalled) *************** *** 62,69 **** } ! Joint::init(jd); mInitCalled = true; ! switch(jd.type) { case HINGE_JOINT: --- 62,69 ---- } ! Joint::init(data); mInitCalled = true; ! switch(data.getType()) { case HINGE_JOINT: *************** *** 173,179 **** // Note that this handles the cases when either both are being set // to NULL or both are the same Solid. ! if (jd.solid0 == jd.solid1 || ! (jd.solid0 && jd.solid0->isStatic()) || ! (jd.solid1 && jd.solid1->isStatic())) { Joint::setSolids(NULL, NULL); --- 173,179 ---- // Note that this handles the cases when either both are being set // to NULL or both are the same Solid. ! if (data.solid0 == data.solid1 || ! (data.solid0 && data.solid0->isStatic()) || ! (data.solid1 && data.solid1->isStatic())) { Joint::setSolids(NULL, NULL); *************** *** 182,186 **** else { ! Joint::setSolids(jd.solid0, jd.solid1); mData.enabled = true; } --- 182,186 ---- else { ! Joint::setSolids(data.solid0, data.solid1); mData.enabled = true; } *************** *** 190,199 **** // Setup the Joint's anchor. ! setAnchor(jd.anchor); // Setup the Joint's axes. ! setAxis(0, jd.axis[0]); ! setAxis(1, jd.axis[1]); ! setAxis(2, jd.axis[2]); } --- 190,199 ---- // Setup the Joint's anchor. ! setAnchor(data.anchor); // Setup the Joint's axes. ! setAxis(0, data.axis[0]); ! setAxis(1, data.axis[1]); ! setAxis(2, data.axis[2]); } *************** *** 204,208 **** real value = 0; ! switch(mData.type) { case HINGE_JOINT: --- 204,208 ---- real value = 0; ! switch(mData.getType()) { case HINGE_JOINT: *************** *** 257,261 **** real value = 0; ! switch(mData.type) { case HINGE_JOINT: --- 257,261 ---- real value = 0; ! switch(mData.getType()) { case HINGE_JOINT: *************** *** 343,347 **** // ODE's Hinge2 Joint also has a suspension parameter. Use axis 1 // for this since axis 1 doesn't use limits anyway. ! if (1 == axisNum && HINGE_2_JOINT == mData.type) { setJointParam(dParamSuspensionERP, value); --- 343,347 ---- // ODE's Hinge2 Joint also has a suspension parameter. Use axis 1 // for this since axis 1 doesn't use limits anyway. ! if (1 == axisNum && HINGE_2_JOINT == mData.getType()) { setJointParam(dParamSuspensionERP, value); *************** *** 448,452 **** // Set the ODE Joint axis direction vector. ! switch(mData.type) { case HINGE_JOINT: --- 448,452 ---- // Set the ODE Joint axis direction vector. ! switch(mData.getType()) { case HINGE_JOINT: *************** *** 529,533 **** (dReal)anchor[2]}; ! switch(mData.type) { case HINGE_JOINT: --- 529,533 ---- (dReal)anchor[2]}; ! switch(mData.getType()) { case HINGE_JOINT: *************** *** 726,730 **** void ODEJoint::setJointParam(int parameter, dReal value) { ! switch(mData.type) { case HINGE_JOINT: --- 726,730 ---- void ODEJoint::setJointParam(int parameter, dReal value) { ! switch(mData.getType()) { case HINGE_JOINT: *************** *** 845,849 **** // relationship between the Solids or between a Solid and the // static environment. ! if (FIXED_JOINT == mData.type) { dJointSetFixed(mJointID); --- 845,849 ---- // relationship between the Solids or between a Solid and the // static environment. ! if (FIXED_JOINT == mData.getType()) { dJointSetFixed(mJointID); |
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10148/src Modified Files: AttractorMotor.cpp AttractorMotor.h Blueprint.cpp Blueprint.h BlueprintManager.cpp Defines.h GearedMotor.cpp GearedMotor.h Joint.cpp Joint.h Motor.cpp Motor.h ServoMotor.cpp ServoMotor.h ShapeData.h Solid.h SolidData.h SpringMotor.cpp SpringMotor.h ThrusterMotor.cpp ThrusterMotor.h opal.h Added Files: AttractorMotorData.h GearedMotorData.h JointData.h MotorData.h SensorData.h ServoMotorData.h SpringMotorData.h ThrusterMotorData.h Log Message: added MotorData and JointData classes Index: BlueprintManager.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintManager.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** BlueprintManager.cpp 22 Feb 2005 01:25:55 -0000 1.24 --- BlueprintManager.cpp 23 Feb 2005 03:58:23 -0000 1.25 *************** *** 473,481 **** // The JointData automatically gets initialized to default values // in its constructor. ! JointData jd; #ifdef OPAL_USE_XML ! //jd.name = getAttributeString(nodePtr, "name"); std::string type = getAttributeString(nodePtr, "type"); --- 473,481 ---- // The JointData automatically gets initialized to default values // in its constructor. ! JointData data; #ifdef OPAL_USE_XML ! //data.name = getAttributeString(nodePtr, "name"); std::string type = getAttributeString(nodePtr, "type"); *************** *** 483,507 **** if ("hinge" == type) { ! jd.type = HINGE_JOINT; } else if ("universal" == type) { ! jd.type = UNIVERSAL_JOINT; } else if ("ball" == type) { ! jd.type = BALL_JOINT; } else if ("slider" == type) { ! jd.type = SLIDER_JOINT; } else if ("hinge2" == type) { ! jd.type = HINGE_2_JOINT; } else if ("fixed" == type) { ! jd.type = FIXED_JOINT; } else --- 483,507 ---- if ("hinge" == type) { ! data.setType(HINGE_JOINT); } else if ("universal" == type) { ! data.setType(UNIVERSAL_JOINT); } else if ("ball" == type) { ! data.setType(BALL_JOINT); } else if ("slider" == type) { ! data.setType(SLIDER_JOINT); } else if ("hinge2" == type) { ! data.setType(HINGE_2_JOINT); } else if ("fixed" == type) { ! data.setType(FIXED_JOINT); } else *************** *** 510,514 **** Invalid joint type requested" << " in " << filename << std::endl; ! return jd; } --- 510,514 ---- Invalid joint type requested" << " in " << filename << std::endl; ! return data; } *************** *** 518,526 **** if (NULL != paramsNodePtr) { ! //jd.kd = getAttributeReal(paramsNodePtr, "kd"); ! //jd.ks = getAttributeReal(paramsNodePtr, "ks"); ! jd.breakThresh = getAttributeReal(paramsNodePtr, "breakThresh"); ! jd.accumThresh = getAttributeReal(paramsNodePtr, "accumThresh"); std::string breakMode = --- 518,526 ---- if (NULL != paramsNodePtr) { ! //data.kd = getAttributeReal(paramsNodePtr, "kd"); ! //data.ks = getAttributeReal(paramsNodePtr, "ks"); ! data.breakThresh = getAttributeReal(paramsNodePtr, "breakThresh"); ! data.accumThresh = getAttributeReal(paramsNodePtr, "accumThresh"); std::string breakMode = *************** *** 529,541 **** if ("unbreakable" == breakMode) { ! jd.breakMode = UNBREAKABLE; } else if ("threshold" == breakMode) { ! jd.breakMode = THRESHOLD; } else if ("accumulated" == breakMode) { ! jd.breakMode = ACCUMULATED; } else --- 529,541 ---- if ("unbreakable" == breakMode) { ! data.breakMode = UNBREAKABLE; } else if ("threshold" == breakMode) { ! data.breakMode = THRESHOLD; } else if ("accumulated" == breakMode) { ! data.breakMode = ACCUMULATED; } else *************** *** 544,548 **** Invalid joint break mode requested" << " in " << filename << std::endl; ! return jd; } } --- 544,548 ---- Invalid joint break mode requested" << " in " << filename << std::endl; ! return data; } } *************** *** 556,560 **** Anchor element missing" << " in " << filename << std::endl; ! return jd; } else --- 556,560 ---- Anchor element missing" << " in " << filename << std::endl; ! return data; } else *************** *** 563,567 **** real y = getAttributeReal(anchorNodePtr, "y"); real z = getAttributeReal(anchorNodePtr, "z"); ! jd.anchor.set((real)x, (real)y, (real)z); } --- 563,567 ---- real y = getAttributeReal(anchorNodePtr, "y"); real z = getAttributeReal(anchorNodePtr, "z"); ! data.anchor.set((real)x, (real)y, (real)z); } *************** *** 580,584 **** Axis0 element missing" << " in " << filename << std::endl; ! return jd; } else --- 580,584 ---- Axis0 element missing" << " in " << filename << std::endl; ! return data; } else *************** *** 593,597 **** missing from Axis0 element" << " in " << filename << std::endl; ! return jd; } else --- 593,597 ---- missing from Axis0 element" << " in " << filename << std::endl; ! return data; } else *************** *** 600,604 **** real y = getAttributeReal(directionNodePtr, "y"); real z = getAttributeReal(directionNodePtr, "z"); ! jd.axis[0].direction.set(x, y, z); } --- 600,604 ---- real y = getAttributeReal(directionNodePtr, "y"); real z = getAttributeReal(directionNodePtr, "z"); ! data.axis[0].direction.set(x, y, z); } *************** *** 608,614 **** if (NULL != limitsNodePtr) { ! jd.axis[0].limits.low = getAttributeReal(limitsNodePtr, "low"); ! jd.axis[0].limits.high = getAttributeReal(limitsNodePtr, "high"); } --- 608,614 ---- if (NULL != limitsNodePtr) { ! data.axis[0].limits.low = getAttributeReal(limitsNodePtr, "low"); ! data.axis[0].limits.high = getAttributeReal(limitsNodePtr, "high"); } *************** *** 626,630 **** loadJoint: Axis1 element missing" << " in " << filename << std::endl; ! return jd; } else --- 626,630 ---- loadJoint: Axis1 element missing" << " in " << filename << std::endl; ! return data; } else *************** *** 639,643 **** missing from Axis1 element" << " in " << filename << std::endl; ! return jd; } else --- 639,643 ---- missing from Axis1 element" << " in " << filename << std::endl; ! return data; } else *************** *** 646,650 **** real y = getAttributeReal(directionNodePtr, "y"); real z = getAttributeReal(directionNodePtr, "z"); ! jd.axis[1].direction.set(x, y, z); } --- 646,650 ---- real y = getAttributeReal(directionNodePtr, "y"); real z = getAttributeReal(directionNodePtr, "z"); ! data.axis[1].direction.set(x, y, z); } *************** *** 654,660 **** if (NULL != limitsNodePtr) { ! jd.axis[1].limits.low = getAttributeReal(limitsNodePtr, "low"); ! jd.axis[1].limits.high = getAttributeReal(limitsNodePtr, "high"); } --- 654,660 ---- if (NULL != limitsNodePtr) { ! data.axis[1].limits.low = getAttributeReal(limitsNodePtr, "low"); ! data.axis[1].limits.high = getAttributeReal(limitsNodePtr, "high"); } *************** *** 672,676 **** loadJoint: Axis2 element missing" << " in " << filename << std::endl; ! return jd; } else --- 672,676 ---- loadJoint: Axis2 element missing" << " in " << filename << std::endl; ! return data; } else *************** *** 685,689 **** element missing from Axis2 element" << " in " << filename << std::endl; ! return jd; } else --- 685,689 ---- element missing from Axis2 element" << " in " << filename << std::endl; ! return data; } else *************** *** 695,699 **** real z = getAttributeReal(directionNodePtr, "z"); ! jd.axis[2].direction.set(x, y, z); } --- 695,699 ---- real z = getAttributeReal(directionNodePtr, "z"); ! data.axis[2].direction.set(x, y, z); } *************** *** 703,709 **** if (NULL != limitsNodePtr) { ! jd.axis[2].limits.low = getAttributeReal(limitsNodePtr, "low"); ! jd.axis[2].limits.high = getAttributeReal(limitsNodePtr, "high"); } --- 703,709 ---- if (NULL != limitsNodePtr) { ! data.axis[2].limits.low = getAttributeReal(limitsNodePtr, "low"); ! data.axis[2].limits.high = getAttributeReal(limitsNodePtr, "high"); } *************** *** 725,737 **** Solids element missing" << " in " << filename << std::endl; ! return jd; } else { ! //jd.solid0Name = getAttributeString(solidsNodePtr, "name0"); ! //jd.solid1Name = getAttributeString(solidsNodePtr, "name1"); //std::cout << "Warning in opal::BlueprintManager::loadJoint: \ ! // Joint " << jd.name << " refers to the same Solid \ // twice in " << filename << std::endl; } --- 725,737 ---- Solids element missing" << " in " << filename << std::endl; ! return data; } else { ! //data.solid0Name = getAttributeString(solidsNodePtr, "name0"); ! //data.solid1Name = getAttributeString(solidsNodePtr, "name1"); //std::cout << "Warning in opal::BlueprintManager::loadJoint: \ ! // Joint " << data.name << " refers to the same Solid \ // twice in " << filename << std::endl; } *************** *** 739,743 **** #endif ! return jd; } --- 739,743 ---- #endif ! return data; } Index: opal.h =================================================================== RCS file: /cvsroot/opal/opal/src/opal.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** opal.h 22 Feb 2005 04:28:11 -0000 1.15 --- opal.h 23 Feb 2005 03:58:23 -0000 1.16 *************** *** 32,35 **** --- 32,36 ---- #include "Solid.h" #include "SolidData.h" + #include "ShapeData.h" #include "BoxShapeData.h" #include "SphereShapeData.h" *************** *** 39,48 **** --- 40,53 ---- #include "MeshShapeData.h" #include "Motor.h" + #include "MotorData.h" #include "AttractorMotor.h" + #include "AttractorMotorData.h" #include "ServoMotor.h" #include "ThrusterMotor.h" #include "GearedMotor.h" #include "Joint.h" + #include "JointData.h" #include "Sensor.h" + #include "SensorData.h" #include "EventHandler.h" #include "Blueprint.h" *************** *** 57,59 **** #endif - --- 62,63 ---- Index: Motor.h =================================================================== RCS file: /cvsroot/opal/opal/src/Motor.h,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Motor.h 21 Feb 2005 15:54:38 -0000 1.33 --- Motor.h 23 Feb 2005 03:58:23 -0000 1.34 *************** *** 46,50 **** /// functions, and adding Motor instances to the simulation via the /// Simulator class (see Simulator for details). All Motors start out ! /// disabled and must be initialized via init) before they can be /// enabled. class Motor --- 46,50 ---- /// functions, and adding Motor instances to the simulation via the /// Simulator class (see Simulator for details). All Motors start out ! /// disabled and must be initialized via init before they can be /// enabled. class Motor *************** *** 56,64 **** /// Returns true if the Motor is enabled. ! virtual bool OPAL_CALL isEnabled()const; /// Sets whether the Motor has any effect. If the Motor has not /// yet been initialized, this will have no effect. ! virtual void OPAL_CALL setEnabled(bool e); /// Set the user data pointer to some external data. The user data --- 56,64 ---- /// Returns true if the Motor is enabled. ! virtual bool OPAL_CALL isEnabled()const = 0; /// Sets whether the Motor has any effect. If the Motor has not /// yet been initialized, this will have no effect. ! virtual void OPAL_CALL setEnabled(bool e) = 0; /// Set the user data pointer to some external data. The user data *************** *** 92,96 **** /// True if the Motor is enabled. ! bool mEnabled; /// Pointer to user data. This is totally user-managed (i.e. OPAL --- 92,96 ---- /// True if the Motor is enabled. ! //bool mEnabled; /// Pointer to user data. This is totally user-managed (i.e. OPAL Index: ShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/ShapeData.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ShapeData.h 22 Feb 2005 19:46:30 -0000 1.2 --- ShapeData.h 23 Feb 2005 03:58:23 -0000 1.3 *************** *** 33,37 **** namespace opal { ! /// The types of collision shapes currently supported. enum ShapeType { --- 33,37 ---- namespace opal { ! /// The types of Shapes currently available. enum ShapeType { --- NEW FILE: GearedMotorData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_GEARED_MOTOR_DATA_H #define OPAL_GEARED_MOTOR_DATA_H #include "Defines.h" #include "MotorData.h" namespace opal { /// A data structure describing a GearedMotor. class GearedMotorData : public MotorData { public: GearedMotorData() : MotorData() { mType = GEARED_MOTOR; joint = NULL; jointAxisNum = 0; maxTorque = defaults::motor::geared::maxTorque; maxVelocity = defaults::motor::geared::maxVelocity; throttle = 0; } /// Copy constructor. GearedMotorData(const GearedMotorData& data) { (*this) = data; } virtual ~GearedMotorData() { } /// Makes a deep copy. virtual void OPAL_CALL operator=(const GearedMotorData& data) { mType = data.mType; enabled = data.enabled; joint = data.joint; jointAxisNum = data.jointAxisNum; maxTorque = data.maxTorque; maxVelocity = data.maxVelocity; throttle = data.throttle; } /// Pointer to the Joint affected by this Motor. Joint* joint; /// The index of the specific Joint axis affected by this Motor. int jointAxisNum; /// The maximum amount of torque that can be applied to the Joint /// axis. real maxTorque; /// The maximum velocity that can be achieved by the Motor. real maxVelocity; /// The throttle (i.e. the "gas") affects how much of the available /// torque is applied to the Joint axis. real throttle; protected: private: }; } #endif --- NEW FILE: AttractorMotorData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_ATTRACTOR_MOTOR_DATA_H #define OPAL_ATTRACTOR_MOTOR_DATA_H #include "Defines.h" #include "MotorData.h" namespace opal { /// A data structure describing an AttractorMotor. class AttractorMotorData : public MotorData { public: AttractorMotorData() : MotorData() { mType = ATTRACTOR_MOTOR; solid0 = NULL; solid1 = NULL; strength = defaults::motor::attractor::strength; exponent = defaults::motor::attractor::exponent; } /// Copy constructor. AttractorMotorData(const AttractorMotorData& data) { (*this) = data; } virtual ~AttractorMotorData() { } /// Makes a deep copy. virtual void OPAL_CALL operator=(const AttractorMotorData& data) { mType = data.mType; enabled = data.enabled; solid0 = data.solid0; solid1 = data.solid1; strength = data.strength; exponent = data.exponent; } /// Pointer to Solid 0. Solid* solid0; /// Pointer to Solid 1. Solid* solid1; /// Constant used to scale attraction (repulsion if strength < 0). real strength; /// Determines exponential relationship of attraction/repulsion. real exponent; protected: private: }; } #endif Index: SpringMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/SpringMotor.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SpringMotor.h 18 Feb 2005 23:59:37 -0000 1.5 --- SpringMotor.h 23 Feb 2005 03:58:23 -0000 1.6 *************** *** 31,34 **** --- 31,35 ---- #include "Defines.h" #include "Motor.h" + #include "SpringMotorData.h" namespace opal *************** *** 41,58 **** { public: - /// The different SpringMotor modes of operation. - enum Mode - { - /// Makes the Motor work to achieve a desired position. - LINEAR_MODE, - - /// Makes the Motor work to achieve a desired orientation. - ANGULAR_MODE, - - /// Makes the Motor work to achieve a desired position and - /// orientation. - LINEAR_AND_ANGULAR_MODE - }; - SpringMotor(); --- 42,45 ---- *************** *** 63,67 **** /// enable the Motor. Calling this more than once will detach the /// Motor from its Solid and attach it to a new Solid. ! virtual void OPAL_CALL init(Mode m, Solid* s); /// Sets the desired position and orientation. --- 50,64 ---- /// enable the Motor. Calling this more than once will detach the /// Motor from its Solid and attach it to a new Solid. ! //virtual void OPAL_CALL init(Mode m, Solid* s); ! ! /// Initializes the Motor with the given data structure. ! virtual void OPAL_CALL init(const SpringMotorData& data); ! ! /// Returns all data describing the Motor. ! virtual const SpringMotorData& OPAL_CALL getMotorData(); ! ! virtual bool OPAL_CALL isEnabled()const; ! ! virtual void OPAL_CALL setEnabled(bool e); /// Sets the desired position and orientation. *************** *** 104,140 **** protected: ! /// Pointer to the Solid affected by this Motor. ! Solid* mSolid; ! /// The Motor's mode of operation. ! Mode mMode; ! /// The Motor's desired position. This is only used if the ! /// appropriate mode is set. ! Point3r mDesiredPos; ! /// The Motor's desired forward direction, part of the desired ! /// orientation. This is only used if the appropriate mode is set. ! Vec3r mDesiredForward; ! /// The Motor's desired up direction, part of the desired ! /// orientation. This is only used if the appropriate mode is set. ! Vec3r mDesiredUp; ! /// The Motor's desired right direction, part of the desired ! /// orientation. This is only used if the appropriate mode is set. ! Vec3r mDesiredRight; ! /// The damping constant for linear mode. ! real mLinearKd; ! /// The spring constant for linear mode. ! real mLinearKs; ! /// The damping constant for angular mode. ! real mAngularKd; ! /// The spring constant for angular mode. ! real mAngularKs; private: --- 101,140 ---- protected: ! /// Stores data describing the Motor. ! SpringMotorData mData; ! ///// Pointer to the Solid affected by this Motor. ! //Solid* mSolid; ! ///// The Motor's mode of operation. ! //Mode mMode; ! ///// The Motor's desired position. This is only used if the ! ///// appropriate mode is set. ! //Point3r mDesiredPos; ! ///// The Motor's desired forward direction, part of the desired ! ///// orientation. This is only used if the appropriate mode is set. ! //Vec3r mDesiredForward; ! ///// The Motor's desired up direction, part of the desired ! ///// orientation. This is only used if the appropriate mode is set. ! //Vec3r mDesiredUp; ! ///// The Motor's desired right direction, part of the desired ! ///// orientation. This is only used if the appropriate mode is set. ! //Vec3r mDesiredRight; ! ///// The damping constant for linear mode. ! //real mLinearKd; ! ///// The spring constant for linear mode. ! //real mLinearKs; ! ///// The damping constant for angular mode. ! //real mAngularKd; ! ! ///// The spring constant for angular mode. ! //real mAngularKs; private: --- NEW FILE: ServoMotorData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_SERVO_MOTOR_DATA_H #define OPAL_SERVO_MOTOR_DATA_H #include "Defines.h" #include "MotorData.h" namespace opal { /// The different ServoMotor modes of operation. enum ServoMotorMode { /// The ServoMotor tries to achieve a desired position for /// the Joint axis. DESIRED_POS_MODE, /// The ServoMotor tries to achieve a desired velocity for /// the Joint axis. DESIRED_VEL_MODE }; /// A data structure describing a ServoMotor. class ServoMotorData : public MotorData { public: ServoMotorData() : MotorData() { mType = SERVO_MOTOR; joint = NULL; mode = DESIRED_POS_MODE; jointAxisNum = 0; desiredPos = 0; desiredVel = 0; maxForce = defaults::motor::servo::maxForce; restoreSpeed = defaults::motor::servo::restoreSpeed; } /// Copy constructor. ServoMotorData(const ServoMotorData& data) { (*this) = data; } virtual ~ServoMotorData() { } /// Makes a deep copy. virtual void OPAL_CALL operator=(const ServoMotorData& data) { mType = data.mType; enabled = data.enabled; joint = data.joint; mode = data.mode; jointAxisNum = data.jointAxisNum; desiredPos = data.desiredPos; desiredVel = data.desiredVel; maxForce = data.maxForce; restoreSpeed = data.restoreSpeed; } /// Pointer to the Joint affected by this Motor. Joint* joint; /// The Motor's mode of operation. ServoMotorMode mode; /// The index of the Joint axes affected by this Motor. int jointAxisNum; /// The Motor's desired position. This is only used if the /// appropriate mode is set. real desiredPos; /// The Motor's desired position. This is only used if the /// appropriate mode is set. real desiredVel; /// The maximum amount of force that can be used to help the /// Joint axis achieve its desired position or velocity. real maxForce; /// A constant used in desired position mode that scaled how fast /// the Joint axis will achieve its desired position. real restoreSpeed; protected: private: }; } #endif Index: ServoMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/ServoMotor.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ServoMotor.h 18 Feb 2005 23:59:37 -0000 1.19 --- ServoMotor.h 23 Feb 2005 03:58:23 -0000 1.20 *************** *** 32,35 **** --- 32,36 ---- #include "Motor.h" #include "Joint.h" + #include "ServoMotorData.h" namespace opal *************** *** 44,59 **** { public: - /// The different ServoMotor modes of operation. - enum Mode - { - /// The ServoMotor tries to achieve a desired position for - /// the Joint axis. - DESIRED_POS_MODE, - - /// The ServoMotor tries to achieve a desired velocity for - /// the Joint axis. - DESIRED_VEL_MODE - }; - ServoMotor(); --- 45,48 ---- *************** *** 63,67 **** /// enable the Motor. Calling this more than once will detach the /// Motor from its Joint and attach it to a new Joint. ! virtual void OPAL_CALL init(Mode m, Joint* j, int axisNum); virtual void OPAL_CALL setEnabled(bool e); --- 52,64 ---- /// enable the Motor. Calling this more than once will detach the /// Motor from its Joint and attach it to a new Joint. ! //virtual void OPAL_CALL init(Mode m, Joint* j, int axisNum); ! ! /// Initializes the Motor with the given data structure. ! virtual void OPAL_CALL init(const ServoMotorData& data); ! ! /// Returns all data describing the Motor. ! virtual const ServoMotorData& OPAL_CALL getMotorData(); ! ! virtual bool OPAL_CALL isEnabled()const; virtual void OPAL_CALL setEnabled(bool e); *************** *** 104,131 **** protected: ! /// Pointer to the Joint affected by this Motor. ! Joint* mJoint; ! /// The Motor's mode of operation. ! Mode mMode; ! /// The index of the Joint axes affected by this Motor. ! int mJointAxis; ! /// The Motor's desired position. This is only used if the ! /// appropriate mode is set. ! real mDesiredPos; ! ! /// The Motor's desired position. This is only used if the ! /// appropriate mode is set. ! real mDesiredVel; ! /// The maximum amount of force that can be used to help the ! /// Joint axis achieve its desired position or velocity. ! real mMaxForce; ! /// A constant used in desired position mode that scaled how fast ! /// the Joint axis will achieve its desired position. ! real mRestoreSpeed; private: --- 101,131 ---- protected: ! /// Stores data describing the Motor. ! ServoMotorData mData; ! ///// Pointer to the Joint affected by this Motor. ! //Joint* mJoint; ! ///// The Motor's mode of operation. ! //Mode mMode; ! ///// The index of the Joint axes affected by this Motor. ! //int mJointAxis; ! ///// The Motor's desired position. This is only used if the ! ///// appropriate mode is set. ! //real mDesiredPos; ! // ! ///// The Motor's desired position. This is only used if the ! ///// appropriate mode is set. ! //real mDesiredVel; ! ///// The maximum amount of force that can be used to help the ! ///// Joint axis achieve its desired position or velocity. ! //real mMaxForce; ! ! ///// A constant used in desired position mode that scaled how fast ! ///// the Joint axis will achieve its desired position. ! //real mRestoreSpeed; private: Index: ThrusterMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/ThrusterMotor.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ThrusterMotor.h 18 Feb 2005 23:59:37 -0000 1.5 --- ThrusterMotor.h 23 Feb 2005 03:58:23 -0000 1.6 *************** *** 31,34 **** --- 31,35 ---- #include "Defines.h" #include "Motor.h" + #include "ThrusterMotorData.h" namespace opal *************** *** 40,44 **** class ThrusterMotor : public Motor { - public: ThrusterMotor(); --- 41,44 ---- *************** *** 49,53 **** /// Calling this more than once will detach the Motor from its Solid /// and attach it to a new Solid. ! virtual void OPAL_CALL init(Solid* solid); /// Sets the Force applied by this Motor every time step. --- 49,63 ---- /// Calling this more than once will detach the Motor from its Solid /// and attach it to a new Solid. ! //virtual void OPAL_CALL init(Solid* solid); ! ! /// Initializes the Motor with the given data structure. ! virtual void OPAL_CALL init(const ThrusterMotorData& data); ! ! /// Returns all data describing the Motor. ! virtual const ThrusterMotorData& OPAL_CALL getMotorData(); ! ! virtual bool OPAL_CALL isEnabled()const; ! ! virtual void OPAL_CALL setEnabled(bool e); /// Sets the Force applied by this Motor every time step. *************** *** 62,70 **** protected: /// Pointer to the Solid affected by this Motor. ! Solid* mSolid; /// The Force that gets applied to the Solid every time step. ! Force mForce; private: --- 72,83 ---- protected: + /// Stores data describing the Motor. + ThrusterMotorData mData; + /// Pointer to the Solid affected by this Motor. ! //Solid* mSolid; /// The Force that gets applied to the Solid every time step. ! //Force mForce; private: Index: Blueprint.h =================================================================== RCS file: /cvsroot/opal/opal/src/Blueprint.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Blueprint.h 22 Feb 2005 01:25:55 -0000 1.20 --- Blueprint.h 23 Feb 2005 03:58:23 -0000 1.21 *************** *** 50,56 **** virtual const std::string& OPAL_CALL getName()const; ! //virtual void OPAL_CALL addSolid(const SolidDescription& sd); ! //virtual void OPAL_CALL addJoint(const JointData& jd); virtual void OPAL_CALL addSpace(const SpaceDescription& sd); --- 50,56 ---- virtual const std::string& OPAL_CALL getName()const; ! //virtual void OPAL_CALL addSolid(const SolidDescription& data); ! //virtual void OPAL_CALL addJoint(const JointData& data); virtual void OPAL_CALL addSpace(const SpaceDescription& sd); Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** Solid.h 22 Feb 2005 01:25:55 -0000 1.74 --- Solid.h 23 Feb 2005 03:58:23 -0000 1.75 *************** *** 116,120 **** // /// Copy constructor. ! // ShapeData(const ShapeData& sd) // { // (*this) = sd; --- 116,120 ---- // /// Copy constructor. ! // ShapeData(const ShapeData& data) // { // (*this) = sd; *************** *** 122,134 **** // /// Makes a deep copy. ! // void operator=(const ShapeData& sd) // { ! // type = sd.type; ! // offset = sd.offset; ! // material = sd.material; // for (int i=0; i<globals::numShapeDimensions; ++i) // { ! // dimensions[i] = sd.dimensions[i]; // } // } --- 122,134 ---- // /// Makes a deep copy. ! // void operator=(const ShapeData& data) // { ! // type = data.type; ! // offset = data.offset; ! // material = data.material; // for (int i=0; i<globals::numShapeDimensions; ++i) // { ! // dimensions[i] = data.dimensions[i]; // } // } *************** *** 174,180 **** // /// Copy constructor. ! // SolidData(const SolidData& sd) // { ! // (*this) = sd; // } --- 174,180 ---- // /// Copy constructor. ! // SolidData(const SolidData& data) // { ! // (*this) = data; // } *************** *** 187,191 **** // /// Makes a deep copy. ! // void operator=(const SolidData& sd) // { // enabled = sd.enabled; --- 187,191 ---- // /// Makes a deep copy. ! // void operator=(const SolidData& data) // { // enabled = sd.enabled; *************** *** 304,308 **** /// Adds a Shape to this Solid. ! virtual void OPAL_CALL addShape(const ShapeData& sd) = 0; ///// Adds a box Shape to this Solid. --- 304,308 ---- /// Adds a Shape to this Solid. ! virtual void OPAL_CALL addShape(const ShapeData& data) = 0; ///// Adds a box Shape to this Solid. Index: SolidData.h =================================================================== RCS file: /cvsroot/opal/opal/src/SolidData.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SolidData.h 22 Feb 2005 19:46:30 -0000 1.2 --- SolidData.h 23 Feb 2005 03:58:23 -0000 1.3 *************** *** 52,58 **** /// Copy constructor. ! SolidData(const SolidData& sd) { ! (*this) = sd; } --- 52,58 ---- /// Copy constructor. ! SolidData(const SolidData& data) { ! (*this) = data; } *************** *** 67,85 **** /// Makes a deep copy. ! virtual void OPAL_CALL operator=(const SolidData& sd) { ! enabled = sd.enabled; ! sleeping = sd.sleeping; ! isStatic = sd.isStatic; ! transform = sd.transform; ! globalLinearVel = sd.globalLinearVel; ! globalAngularVel = sd.globalAngularVel; ! linearDamping = sd.linearDamping; ! angularDamping = sd.angularDamping; shapes.clear(); ! for (unsigned int i=0; i<sd.shapes.size(); ++i) { ! shapes.push_back(sd.shapes[i]); } } --- 67,85 ---- /// Makes a deep copy. ! virtual void OPAL_CALL operator=(const SolidData& data) { ! enabled = data.enabled; ! sleeping = data.sleeping; ! isStatic = data.isStatic; ! transform = data.transform; ! globalLinearVel = data.globalLinearVel; ! globalAngularVel = data.globalAngularVel; ! linearDamping = data.linearDamping; ! angularDamping = data.angularDamping; shapes.clear(); ! for (unsigned int i=0; i<data.shapes.size(); ++i) { ! shapes.push_back(data.shapes[i]); } } Index: GearedMotor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/GearedMotor.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** GearedMotor.cpp 16 Feb 2005 21:22:39 -0000 1.5 --- GearedMotor.cpp 23 Feb 2005 03:58:23 -0000 1.6 *************** *** 34,42 **** : Motor() { ! mJoint = NULL; ! mJointAxisNum = 0; ! mMaxTorque = defaults::motor::geared::maxTorque; ! mMaxVelInverse = (real)1.0 / defaults::motor::geared::maxVelocity; ! mThrottle = 0; } --- 34,38 ---- : Motor() { ! // "mData" will be initialized in its own constructor. } *************** *** 45,59 **** } ! void GearedMotor::init(Joint* joint, int axisNum) { Motor::init(); ! assert(joint->isRotational(axisNum)); ! mJoint = joint; ! mJointAxisNum = axisNum; } void GearedMotor::internal_update() { ! if (mEnabled) { // Global/local direction makes no difference here since --- 41,82 ---- } ! //void GearedMotor::init(Joint* joint, int axisNum) ! //{ ! // Motor::init(); ! // assert(joint->isRotational(axisNum)); ! // mJoint = joint; ! // mJointAxisNum = axisNum; ! //} ! ! void GearedMotor::init(const GearedMotorData& data) { Motor::init(); ! assert(data.joint->isRotational(data.jointAxisNum)); ! mData = data; ! } ! ! const GearedMotorData& GearedMotor::getMotorData() ! { ! return mData; ! } ! ! bool GearedMotor::isEnabled()const ! { ! return mData.enabled; ! } ! ! void GearedMotor::setEnabled(bool e) ! { ! if (!mInitCalled) ! { ! return; ! } ! ! mData.enabled = e; } void GearedMotor::internal_update() { ! if (mData.enabled) { // Global/local direction makes no difference here since *************** *** 63,70 **** // will be an opposing torque at any velocity. ! real normalizedVel = mJoint->getVelocity(mJointAxisNum) ! * mMaxVelInverse; ! real magnitude = mMaxTorque * (mThrottle - normalizedVel); ! mJoint->addTorque(mJointAxisNum, magnitude, 0, true); } } --- 86,95 ---- // will be an opposing torque at any velocity. ! real normalizedVel = ! mData.joint->getVelocity(mData.jointAxisNum) / ! mData.maxVelocity; ! real magnitude = mData.maxTorque * (mData.throttle - ! normalizedVel); ! mData.joint->addTorque(mData.jointAxisNum, magnitude, 0, true); } } *************** *** 72,81 **** void GearedMotor::setMaxTorque(real max) { ! mMaxTorque = max; } real GearedMotor::getMaxTorque()const { ! return mMaxTorque; } --- 97,106 ---- void GearedMotor::setMaxTorque(real max) { ! mData.maxTorque = max; } real GearedMotor::getMaxTorque()const { ! return mData.maxTorque; } *************** *** 83,92 **** { assert(max != 0); ! mMaxVelInverse = (real)1.0 / max; } real GearedMotor::getMaxVelocity()const { ! return (real)1.0 / mMaxVelInverse; } --- 108,117 ---- { assert(max != 0); ! mData.maxVelocity = max; } real GearedMotor::getMaxVelocity()const { ! return mData.maxVelocity; } *************** *** 94,108 **** { assert(throttle >= -1.0 && throttle <= 1.0); ! mThrottle = throttle; } real GearedMotor::getThrottle()const { ! return mThrottle; } bool GearedMotor::internal_dependsOn(Joint* joint) { ! if (joint == mJoint) { return true; --- 119,133 ---- { assert(throttle >= -1.0 && throttle <= 1.0); ! mData.throttle = throttle; } real GearedMotor::getThrottle()const { ! return mData.throttle; } bool GearedMotor::internal_dependsOn(Joint* joint) { ! if (joint == mData.joint) { return true; --- NEW FILE: SensorData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_SENSOR_DATA_H #define OPAL_SENSOR_DATA_H #include "Defines.h" namespace opal { /// The types of Sensors currently available. enum SensorType { VELOCITY_SENSOR, ACCELERATION_SENSOR }; /// A data structure describing a Sensor. class SensorData { public: SensorData() { // The initial type doesn't matter since the abstract base // class will never be instantiated. mType = VELOCITY_SENSOR; } virtual ~SensorData() { } /// Returns the Sensor's type. virtual SensorData OPAL_CALL getType()const { return mType; } protected: /// The Sensor type. SensorType mType; private: }; } #endif Index: AttractorMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/AttractorMotor.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** AttractorMotor.h 18 Feb 2005 23:59:36 -0000 1.21 --- AttractorMotor.h 23 Feb 2005 03:58:23 -0000 1.22 *************** *** 31,34 **** --- 31,35 ---- #include "Defines.h" #include "Motor.h" + #include "AttractorMotorData.h" namespace opal *************** *** 50,54 **** /// enable the Motor. Calling this more than once will detach the /// Motor from its Solids and attach it to new Solids. ! virtual void OPAL_CALL init(Solid* solid0, Solid* solid1); /// Sets the strength parameter. --- 51,65 ---- /// enable the Motor. Calling this more than once will detach the /// Motor from its Solids and attach it to new Solids. ! //virtual void OPAL_CALL init(Solid* solid0, Solid* solid1); ! ! /// Initializes the Motor with the given data structure. ! virtual void OPAL_CALL init(const AttractorMotorData& data); ! ! /// Returns all data describing the Motor. ! virtual const AttractorMotorData& OPAL_CALL getMotorData(); ! ! virtual bool OPAL_CALL isEnabled()const; ! ! virtual void OPAL_CALL setEnabled(bool e); /// Sets the strength parameter. *************** *** 69,77 **** protected: /// Pointer to Solid 0. ! Solid* mSolid0; /// Pointer to Solid 1. ! Solid* mSolid1; /// Cached copy of Solid 0's mass. --- 80,91 ---- protected: + /// Stores data describing the Motor. + AttractorMotorData mData; + /// Pointer to Solid 0. ! //Solid* mSolid0; /// Pointer to Solid 1. ! //Solid* mSolid1; /// Cached copy of Solid 0's mass. *************** *** 82,86 **** /// Constant used to scale attraction (repulsion if strength < 0). ! real mStrength; /// Cached copy of strength * m0 * m1. --- 96,100 ---- /// Constant used to scale attraction (repulsion if strength < 0). ! //real mStrength; /// Cached copy of strength * m0 * m1. *************** *** 88,92 **** /// Determines exponential relationship of attraction/repulsion. ! real mExponent; private: --- 102,106 ---- /// Determines exponential relationship of attraction/repulsion. ! //real mExponent; private: Index: ThrusterMotor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ThrusterMotor.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ThrusterMotor.cpp 16 Feb 2005 21:22:41 -0000 1.4 --- ThrusterMotor.cpp 23 Feb 2005 03:58:23 -0000 1.5 *************** *** 35,40 **** : Motor() { ! mSolid = NULL; ! // "mForce" is initialized in its own constructor. } --- 35,39 ---- : Motor() { ! // "mData" will be initialized in its own constructor. } *************** *** 43,57 **** } ! void ThrusterMotor::init(Solid* solid) { Motor::init(); ! mSolid = solid; } void ThrusterMotor::internal_update() { ! if (mEnabled) { ! mSolid->addForce(mForce); } } --- 42,82 ---- } ! //void ThrusterMotor::init(Solid* solid) ! //{ ! // Motor::init(); ! // mSolid = solid; ! //} ! ! void ThrusterMotor::init(const ThrusterMotorData& data) { Motor::init(); ! mData = data; ! } ! ! const ThrusterMotorData& ThrusterMotor::getMotorData() ! { ! return mData; ! } ! ! bool ThrusterMotor::isEnabled()const ! { ! return mData.enabled; ! } ! ! void ThrusterMotor::setEnabled(bool e) ! { ! if (!mInitCalled) ! { ! return; ! } ! ! mData.enabled = e; } void ThrusterMotor::internal_update() { ! if (mData.enabled) { ! mData.solid->addForce(mData.force); } } *************** *** 59,73 **** void ThrusterMotor::setForce(const Force& f) { ! mForce = f; } const Force& ThrusterMotor::getForce()const { ! return mForce; } bool ThrusterMotor::internal_dependsOn(Solid* solid) { ! if (solid == mSolid) { return true; --- 84,98 ---- void ThrusterMotor::setForce(const Force& f) { ! mData.force = f; } const Force& ThrusterMotor::getForce()const { ! return mData.force; } bool ThrusterMotor::internal_dependsOn(Solid* solid) { ! if (solid == mData.solid) { return true; Index: Blueprint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Blueprint.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Blueprint.cpp 22 Feb 2005 01:25:55 -0000 1.12 --- Blueprint.cpp 23 Feb 2005 03:58:23 -0000 1.13 *************** *** 65,79 **** //} ! //void Blueprint::addJoint(const JointData& jd) //{ ! // if (jointExists(jd.name)) // { // std::cout << "Warning in opal::Blueprint::addJoint: Joint " << ! // jd.name << " already exists in Blueprint " << mName // << "; ignoring Joint" << std::endl; // } // else // { ! // mJointMap[jd.name] = jd; // } //} --- 65,79 ---- //} ! //void Blueprint::addJoint(const JointData& data) //{ ! // if (jointExists(data.name)) // { // std::cout << "Warning in opal::Blueprint::addJoint: Joint " << ! // data.name << " already exists in Blueprint " << mName // << "; ignoring Joint" << std::endl; // } // else // { ! // mJointMap[data.name] = data; // } //} Index: GearedMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/GearedMotor.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** GearedMotor.h 18 Feb 2005 23:59:37 -0000 1.5 --- GearedMotor.h 23 Feb 2005 03:58:23 -0000 1.6 *************** *** 31,34 **** --- 31,35 ---- #include "Defines.h" #include "Motor.h" + #include "GearedMotorData.h" namespace opal *************** *** 55,59 **** /// than once will detach the Motor from its Joint and attach it /// to a new Joint. ! virtual void OPAL_CALL init(Joint* joint, int axisNum); /// Sets the max torque parameter. --- 56,70 ---- /// than once will detach the Motor from its Joint and attach it /// to a new Joint. ! //virtual void OPAL_CALL init(Joint* joint, int axisNum); ! ! /// Initializes the Motor with the given data structure. ! virtual void OPAL_CALL init(const GearedMotorData& data); ! ! /// Returns all data describing the Motor. ! virtual const GearedMotorData& OPAL_CALL getMotorData(); ! ! virtual bool OPAL_CALL isEnabled()const; ! ! virtual void OPAL_CALL setEnabled(bool e); /// Sets the max torque parameter. *************** *** 81,101 **** protected: ! /// Pointer to the Joint affected by this Motor. ! Joint* mJoint; ! /// The index of the specific Joint axis affected by this Motor. ! int mJointAxisNum; ! /// The maximum amount of torque that can be applied to the Joint ! /// axis. ! real mMaxTorque; ! /// The inverse of the maximum velocity that can be achieved by ! /// the Motor. The inverse is cached for faster computations. ! real mMaxVelInverse; ! /// The throttle (i.e. the "gas") affects how much of the available ! /// torque is applied to the Joint axis. ! real mThrottle; private: --- 92,115 ---- protected: ! /// Stores data describing the Motor. ! GearedMotorData mData; ! ///// Pointer to the Joint affected by this Motor. ! //Joint* mJoint; ! ///// The index of the specific Joint axis affected by this Motor. ! //int mJointAxisNum; ! ///// The maximum amount of torque that can be applied to the Joint ! ///// axis. ! //real mMaxTorque; ! ///// The inverse of the maximum velocity that can be achieved by ! ///// the Motor. The inverse is cached for faster computations. ! //real mMaxVelInverse; ! ! ///// The throttle (i.e. the "gas") affects how much of the available ! ///// torque is applied to the Joint axis. ! //real mThrottle; private: Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** Defines.h 22 Feb 2005 01:25:55 -0000 1.57 --- Defines.h 23 Feb 2005 03:58:23 -0000 1.58 *************** *** 102,111 **** ForceType type; ! /// Specifies how long to apply to force. real timeLeft; /// This is mainly used internally by OPAL. It specifies that /// the force will be applied across a single time step. If this ! /// parameter is true, 'timeLeft' will be ignored. bool singleStep; --- 102,112 ---- ForceType type; ! /// Specifies how long to apply to force. This will be ignored ! /// if "singleStep" is true. real timeLeft; /// This is mainly used internally by OPAL. It specifies that /// the force will be applied across a single time step. If this ! /// parameter is true, "timeLeft" will be ignored. bool singleStep; *************** *** 178,187 **** enum JointBreakMode { UNBREAKABLE, ! THRESHOLD, //breaks when force/torque exceeds a threshold ! ACCUMULATED //breaks when enough damage is accumulated }; ! /// The types of Joints currently supported. enum JointType { --- 179,193 ---- enum JointBreakMode { + /// Joint can never break. UNBREAKABLE, ! ! /// Joint breaks when force/torque exceeds a threshold. ! THRESHOLD, ! ! /// Joint breaks when enough damage is accumulated. ! ACCUMULATED }; ! /// The types of Joints currently available. enum JointType { *************** *** 287,290 **** --- 293,297 ---- { const JointType type = HINGE_JOINT; + const bool enabled = false; const real lowLimit = 0; const real highLimit = 0; *************** *** 305,308 **** --- 312,317 ---- namespace motor { + const bool enabled = false; + /// Default parameters used in AttractorMotor creation. namespace attractor Index: Joint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Joint.cpp 22 Feb 2005 01:25:55 -0000 1.19 --- Joint.cpp 23 Feb 2005 03:58:23 -0000 1.20 *************** *** 47,53 **** } ! void Joint::init(const JointData& jd) { ! mData = jd; } --- 47,53 ---- } ! void Joint::init(const JointData& data) { ! mData = data; } *************** *** 59,63 **** JointType Joint::getType()const { ! return mData.type; } --- 59,63 ---- JointType Joint::getType()const { ! return mData.getType(); } --- NEW FILE: SpringMotorData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_SPRING_MOTOR_DATA_H #define OPAL_SPRING_MOTOR_DATA_H #include "Defines.h" #include "MotorData.h" namespace opal { /// The different SpringMotor modes of operation. enum SpringMotorMode { /// Makes the Motor work to achieve a desired position. LINEAR_MODE, /// Makes the Motor work to achieve a desired orientation. ANGULAR_MODE, /// Makes the Motor work to achieve a desired position and /// orientation. LINEAR_AND_ANGULAR_MODE }; /// A data structure describing a SpringMotor. class SpringMotorData : public MotorData { public: SpringMotorData() : MotorData() { mType = SPRING_MOTOR; solid = NULL; mode = LINEAR_MODE; // "desiredPos" is initialized in its own constructor. // "desiredForward" is initialized in its own constructor. // "desiredUp" is initialized in its own constructor. // "desiredRight" is initialized in its own constructor. linearKd = defaults::motor::spring::linearKd; linearKs = defaults::motor::spring::linearKs; angularKd = defaults::motor::spring::angularKd; angularKs = defaults::motor::spring::angularKs; } /// Copy constructor. SpringMotorData(const SpringMotorData& data) { (*this) = data; } virtual ~SpringMotorData() { } /// Makes a deep copy. virtual void OPAL_CALL operator=(const SpringMotorData& data) { mType = data.mType; enabled = data.enabled; solid = data.solid; mode = data.mode; desiredPos = data.desiredPos; desiredForward = data.desiredForward; desiredUp = data.desiredUp; desiredRight = data.desiredRight; linearKd = data.linearKd; linearKs = data.linearKs; angularKd = data.angularKd; angularKs = data.angularKs; } /// Pointer to the Solid affected by this Motor. Solid* solid; /// The Motor's mode of operation. SpringMotorMode mode; /// The Motor's desired position. This is only used if the /// appropriate mode is set. Point3r desiredPos; /// The Motor's desired forward direction, part of the desired /// orientation. This is only used if the appropriate mode is set. Vec3r desiredForward; /// The Motor's desired up direction, part of the desired /// orientation. This is only used if the appropriate mode is set. Vec3r desiredUp; /// The Motor's desired right direction, part of the desired /// orientation. This is only used if the appropriate mode is set. Vec3r desiredRight; /// The damping constant for linear mode. real linearKd; /// The spring constant for linear mode. real linearKs; /// The damping constant for angular mode. real angularKd; /// The spring constant for angular mode. real angularKs; protected: private: }; } #endif --- NEW FILE: MotorData.h... [truncated message content] |
|
From: tylerstreeter <tyl...@us...> - 2005-02-22 19:48:19
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30562/src Modified Files: BoxShapeData.h CapsuleShapeData.h MeshShapeData.h PlaneShapeData.h RayShapeData.h ShapeData.h SolidData.h SphereShapeData.h Log Message: made Data object types a private member; updated samples with new changes Index: SolidData.h =================================================================== RCS file: /cvsroot/opal/opal/src/SolidData.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SolidData.h 22 Feb 2005 01:25:55 -0000 1.1 --- SolidData.h 22 Feb 2005 19:46:30 -0000 1.2 *************** *** 44,49 **** isStatic = defaults::solid::isStatic; // Leave the transform as an identity matrix. ! globalLinearVel = 0; ! globalAngularVel = 0; linearDamping = defaults::linearDamping; angularDamping = defaults::angularDamping; --- 44,49 ---- isStatic = defaults::solid::isStatic; // Leave the transform as an identity matrix. ! // "globalLinearVel" is already initialized in its constructor. ! // "globalAngularVel" is already initialized in its constructor. linearDamping = defaults::linearDamping; angularDamping = defaults::angularDamping; Index: SphereShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/SphereShapeData.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SphereShapeData.h 22 Feb 2005 01:25:55 -0000 1.1 --- SphereShapeData.h 22 Feb 2005 19:46:40 -0000 1.2 *************** *** 41,45 **** : ShapeData() { ! type = SPHERE_SHAPE; radius = 0; } --- 41,45 ---- : ShapeData() { ! mType = SPHERE_SHAPE; radius = 0; } *************** *** 58,62 **** virtual void OPAL_CALL operator=(const SphereShapeData& data) { ! type = data.type; offset = data.offset; material = data.material; --- 58,62 ---- virtual void OPAL_CALL operator=(const SphereShapeData& data) { ! mType = data.mType; offset = data.offset; material = data.material; Index: ShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/ShapeData.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ShapeData.h 22 Feb 2005 01:25:55 -0000 1.1 --- ShapeData.h 22 Feb 2005 19:46:30 -0000 1.2 *************** *** 51,55 **** ShapeData() { ! type = SPHERE_SHAPE; // Leave the offset as an identity matrix. material = defaults::material; --- 51,57 ---- ShapeData() { ! // The initial type doesn't matter since the abstract base ! // class will never be instantiated. ! mType = SPHERE_SHAPE; // Leave the offset as an identity matrix. material = defaults::material; *************** *** 60,65 **** } ! /// The Shape type. ! ShapeType type; /// The offset transform from a Solid's transform. --- 62,70 ---- } ! /// Returns the Shape's type. ! virtual ShapeType OPAL_CALL getType()const ! { ! return mType; ! } /// The offset transform from a Solid's transform. *************** *** 70,73 **** --- 75,80 ---- protected: + /// The Shape type. + ShapeType mType; private: Index: RayShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/RayShapeData.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RayShapeData.h 22 Feb 2005 04:28:11 -0000 1.1 --- RayShapeData.h 22 Feb 2005 19:46:30 -0000 1.2 *************** *** 41,45 **** : ShapeData() { ! type = RAY_SHAPE; // "ray" is already initialized from its constructor. } --- 41,45 ---- : ShapeData() { ! mType = RAY_SHAPE; // "ray" is already initialized from its constructor. } *************** *** 58,62 **** virtual void OPAL_CALL operator=(const RayShapeData& data) { ! type = data.type; offset = data.offset; material = data.material; --- 58,62 ---- virtual void OPAL_CALL operator=(const RayShapeData& data) { ! mType = data.mType; offset = data.offset; material = data.material; Index: PlaneShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/PlaneShapeData.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PlaneShapeData.h 22 Feb 2005 04:28:11 -0000 1.1 --- PlaneShapeData.h 22 Feb 2005 19:46:30 -0000 1.2 *************** *** 41,45 **** : ShapeData() { ! type = PLANE_SHAPE; for (int i=0; i<4; ++i) --- 41,45 ---- : ShapeData() { ! mType = PLANE_SHAPE; for (int i=0; i<4; ++i) *************** *** 62,66 **** virtual void OPAL_CALL operator=(const PlaneShapeData& data) { ! type = data.type; offset = data.offset; material = data.material; --- 62,66 ---- virtual void OPAL_CALL operator=(const PlaneShapeData& data) { ! mType = data.mType; offset = data.offset; material = data.material; Index: CapsuleShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/CapsuleShapeData.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CapsuleShapeData.h 22 Feb 2005 01:25:55 -0000 1.1 --- CapsuleShapeData.h 22 Feb 2005 19:46:29 -0000 1.2 *************** *** 41,45 **** : ShapeData() { ! type = CAPSULE_SHAPE; radius = 0; length = 0; --- 41,45 ---- : ShapeData() { ! mType = CAPSULE_SHAPE; radius = 0; length = 0; *************** *** 59,63 **** virtual void OPAL_CALL operator=(const CapsuleShapeData& data) { ! type = data.type; offset = data.offset; material = data.material; --- 59,63 ---- virtual void OPAL_CALL operator=(const CapsuleShapeData& data) { ! mType = data.mType; offset = data.offset; material = data.material; Index: BoxShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/BoxShapeData.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BoxShapeData.h 22 Feb 2005 01:25:55 -0000 1.1 --- BoxShapeData.h 22 Feb 2005 19:46:29 -0000 1.2 *************** *** 41,45 **** : ShapeData() { ! type = BOX_SHAPE; // "dimensions" is already initialized from its constructor. } --- 41,45 ---- : ShapeData() { ! mType = BOX_SHAPE; // "dimensions" is already initialized from its constructor. } *************** *** 58,62 **** virtual void OPAL_CALL operator=(const BoxShapeData& data) { ! type = data.type; offset = data.offset; material = data.material; --- 58,62 ---- virtual void OPAL_CALL operator=(const BoxShapeData& data) { ! mType = data.mType; offset = data.offset; material = data.material; Index: MeshShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/MeshShapeData.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MeshShapeData.h 22 Feb 2005 04:28:11 -0000 1.1 --- MeshShapeData.h 22 Feb 2005 19:46:29 -0000 1.2 *************** *** 45,49 **** : ShapeData() { ! type = MESH_SHAPE; vertexArray[0] = NULL; numVertices = 0; --- 45,49 ---- : ShapeData() { ! mType = MESH_SHAPE; vertexArray[0] = NULL; numVertices = 0; *************** *** 65,69 **** virtual void OPAL_CALL operator=(const MeshShapeData& data) { ! type = data.type; offset = data.offset; material = data.material; --- 65,69 ---- virtual void OPAL_CALL operator=(const MeshShapeData& data) { ! mType = data.mType; offset = data.offset; material = data.material; |
|
From: tylerstreeter <tyl...@us...> - 2005-02-22 19:47:45
|
Update of /cvsroot/opal/opal/samples/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30562/samples/src Modified Files: BoxObject.cpp CarObject.cpp SphereObject.cpp Log Message: made Data object types a private member; updated samples with new changes Index: CarObject.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/src/CarObject.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** CarObject.cpp 19 Feb 2005 20:54:35 -0000 1.19 --- CarObject.cpp 22 Feb 2005 19:46:26 -0000 1.20 *************** *** 10,22 **** //opal::Space* space = sim->createSpace(); mBody = sim->createSolid(); mBody->setTransform(transform); //mBody->internal_updateEngineTransform(); ! //calculate body dimensions ! mBodyDimensions.set((opal::real)(2.5 * size), (opal::real)(0.3 * size), (opal::real)(4.0 * size)); ! mBody->addBox(mBodyDimensions, opal::Matrix44r(), ! opal::globals::metalMaterial); //calculate wheel radius --- 10,27 ---- //opal::Space* space = sim->createSpace(); + // Create a Solid for the car body. mBody = sim->createSolid(); mBody->setTransform(transform); //mBody->internal_updateEngineTransform(); ! // Calculate body dimensions. ! mBodyDimensions.set((opal::real)(2.5 * size), (opal::real)(0.4 * size), (opal::real)(4.0 * size)); ! ! // Add a box Shape to the car body Solid. ! opal::BoxShapeData boxData; ! boxData.material = opal::globals::metalMaterial; ! boxData.dimensions = mBodyDimensions; ! mBody->addShape(boxData); //calculate wheel radius *************** *** 53,56 **** --- 58,66 ---- jd.axis[1] = wheelAxis; + // Setup a SphereData object to reuse for the wheels. + opal::SphereShapeData wheelData; + wheelData.material = opal::globals::rubberMaterial; + wheelData.radius = mWheelRadius; + // Add front left wheel Solid. opal::Matrix44r M = transform; *************** *** 58,63 **** mFLWheel = sim->createSolid(); mFLWheel->setTransform(M); ! mFLWheel->addSphere(mWheelRadius, opal::Matrix44r(), ! opal::globals::rubberMaterial); // Add front left Joint. --- 68,72 ---- mFLWheel = sim->createSolid(); mFLWheel->setTransform(M); ! mFLWheel->addShape(wheelData); // Add front left Joint. *************** *** 73,78 **** mFRWheel = sim->createSolid(); mFRWheel->setTransform(M); ! mFRWheel->addSphere(mWheelRadius, opal::Matrix44r(), ! opal::globals::rubberMaterial); // Add front right Joint. --- 82,86 ---- mFRWheel = sim->createSolid(); mFRWheel->setTransform(M); ! mFRWheel->addShape(wheelData); // Add front right Joint. *************** *** 88,93 **** mRLWheel = sim->createSolid(); mRLWheel->setTransform(M); ! mRLWheel->addSphere(mWheelRadius, opal::Matrix44r(), ! opal::globals::rubberMaterial); // Add rear left Joint. --- 96,100 ---- mRLWheel = sim->createSolid(); mRLWheel->setTransform(M); ! mRLWheel->addShape(wheelData); // Add rear left Joint. *************** *** 104,109 **** mRRWheel = sim->createSolid(); mRRWheel->setTransform(M); ! mRRWheel->addSphere(mWheelRadius, opal::Matrix44r(), ! opal::globals::rubberMaterial); // Add rear right Joint. --- 111,115 ---- mRRWheel = sim->createSolid(); mRRWheel->setTransform(M); ! mRRWheel->addShape(wheelData); // Add rear right Joint. *************** *** 130,138 **** mFLMotor->init(mFLJoint, 1); mFLMotor->setMaxTorque(15); ! mFLMotor->setMaxVelocity(4000); mFRMotor = sim->createGearedMotor(); mFRMotor->init(mFRJoint, 1); mFRMotor->setMaxTorque(15); ! mFRMotor->setMaxVelocity(4000); //mBody->setTransform(transform); --- 136,144 ---- mFLMotor->init(mFLJoint, 1); mFLMotor->setMaxTorque(15); ! mFLMotor->setMaxVelocity(5000); mFRMotor = sim->createGearedMotor(); mFRMotor->init(mFRJoint, 1); mFRMotor->setMaxTorque(15); ! mFRMotor->setMaxVelocity(5000); //mBody->setTransform(transform); Index: BoxObject.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/src/BoxObject.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** BoxObject.cpp 19 Feb 2005 20:54:35 -0000 1.6 --- BoxObject.cpp 22 Feb 2005 19:46:23 -0000 1.7 *************** *** 7,14 **** mSim = sim; mDimensions = size; mSolid = sim->createSolid(); mSolid->setStatic(isStatic); mSolid->setTransform(transform); ! mSolid->addBox(size, opal::Matrix44r(), material); } --- 7,21 ---- mSim = sim; mDimensions = size; + + // Create and setup the Solid. mSolid = sim->createSolid(); mSolid->setStatic(isStatic); mSolid->setTransform(transform); ! ! // Add a sphere Shape to the Solid. ! opal::BoxShapeData boxData; ! boxData.material = material; ! boxData.dimensions = size; ! mSolid->addShape(boxData); } Index: SphereObject.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/src/SphereObject.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SphereObject.cpp 19 Feb 2005 20:54:35 -0000 1.5 --- SphereObject.cpp 22 Feb 2005 19:46:29 -0000 1.6 *************** *** 7,14 **** mSim = sim; mRadius = radius; mSolid = sim->createSolid(); mSolid->setStatic(isStatic); mSolid->setTransform(transform); ! mSolid->addSphere(radius, opal::Matrix44r(), material); } --- 7,21 ---- mSim = sim; mRadius = radius; + + // Create and setup the Solid. mSolid = sim->createSolid(); mSolid->setStatic(isStatic); mSolid->setTransform(transform); ! ! // Add a sphere Shape to the Solid. ! opal::SphereShapeData sphereData; ! sphereData.material = material; ! sphereData.radius = radius; ! mSolid->addShape(sphereData); } |
|
From: tylerstreeter <tyl...@us...> - 2005-02-22 19:47:44
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30562/src/ODE Modified Files: ODESolid.cpp Log Message: made Data object types a private member; updated samples with new changes Index: ODESolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** ODESolid.cpp 22 Feb 2005 04:28:11 -0000 1.66 --- ODESolid.cpp 22 Feb 2005 19:46:40 -0000 1.67 *************** *** 247,251 **** // Setup mass. ! switch(shapeData->type) { case BOX_SHAPE: --- 247,251 ---- // Setup mass. ! switch(shapeData->getType()) { case BOX_SHAPE: *************** *** 401,405 **** GeomData* newGeomData = new GeomData; ! switch(sd.type) { case BOX_SHAPE: --- 401,405 ---- GeomData* newGeomData = new GeomData; ! switch(sd.getType()) { case BOX_SHAPE: |
|
From: tylerstreeter <tyl...@us...> - 2005-02-22 19:47:03
|
Update of /cvsroot/opal/opal/samples/simple_objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30562/samples/simple_objects Modified Files: main.cpp Log Message: made Data object types a private member; updated samples with new changes Index: main.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/simple_objects/main.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** main.cpp 12 Feb 2005 22:31:43 -0000 1.18 --- main.cpp 22 Feb 2005 19:46:19 -0000 1.19 *************** *** 77,83 **** gTimer.Reset(); gGround = gSimulator->createSolid(); gGround->setStatic(true); ! gGround->addPlane(gGroundParams, gGroundMaterial); std::cout << "==============================================" << std::endl; --- 77,92 ---- gTimer.Reset(); + // Create and setup a Solid for the ground. gGround = gSimulator->createSolid(); gGround->setStatic(true); ! ! // Add a plane Shape to the Solid. ! opal::PlaneShapeData planeData; ! planeData.material = gGroundMaterial; ! planeData.abcd[0] = gGroundParams[0]; ! planeData.abcd[1] = gGroundParams[1]; ! planeData.abcd[2] = gGroundParams[2]; ! planeData.abcd[3] = gGroundParams[3]; ! gGround->addShape(planeData); std::cout << "==============================================" << std::endl; *************** *** 85,90 **** std::cout << "==============================================" << std::endl; std::cout << "Press 1-9 to create various objects" << std::endl; ! std::cout << "Press 'm' to cycle through object materials" << std::endl; ! std::cout << "Press 'g' to cycle through ground materials" << std::endl; std::cout << "Press 'p' to pause" << std::endl; std::cout << "Press 'q' to quit" << std::endl; --- 94,99 ---- std::cout << "==============================================" << std::endl; std::cout << "Press 1-9 to create various objects" << std::endl; ! //std::cout << "Press 'm' to cycle through object materials" << std::endl; ! //std::cout << "Press 'g' to cycle through ground materials" << std::endl; std::cout << "Press 'p' to pause" << std::endl; std::cout << "Press 'q' to quit" << std::endl; *************** *** 92,97 **** std::cout << std::endl; ! std::cout << "Current object material is wood" << std::endl; ! std::cout << "Current ground material is wood" << std::endl; InitSDL(); --- 101,106 ---- std::cout << std::endl; ! //std::cout << "Current object material is wood" << std::endl; ! //std::cout << "Current ground material is wood" << std::endl; InitSDL(); *************** *** 317,388 **** gPaused = !gPaused; break; ! case SDLK_m: ! if (METAL == gObjectMaterialType) ! { ! std::cout << "New object material is wood" << std::endl; ! gObjectMaterialType = WOOD; ! gObjectMaterial = opal::globals::woodMaterial; ! } ! else if (WOOD == gObjectMaterialType) ! { ! std::cout << "New object material is rubber" << std::endl; ! gObjectMaterialType = RUBBER; ! gObjectMaterial = opal::globals::rubberMaterial; ! } ! else if (RUBBER == gObjectMaterialType) ! { ! std::cout << "New object material is ice" << std::endl; ! gObjectMaterialType = ICE; ! gObjectMaterial = opal::globals::iceMaterial; ! } ! else if (ICE == gObjectMaterialType) ! { ! std::cout << "New object material is metal" << std::endl; ! gObjectMaterialType = METAL; ! gObjectMaterial = opal::globals::metalMaterial; ! } ! break; ! case SDLK_g: ! if (METAL == gGroundMaterialType) ! { ! std::cout << "New ground material is wood" << std::endl; ! gGroundMaterialType = WOOD; ! gGroundMaterial = opal::globals::woodMaterial; ! gSimulator->destroySolid(gGround); ! gGround = gSimulator->createSolid(); ! gGround->setStatic(true); ! gGround->addPlane(gGroundParams, gGroundMaterial); ! } ! else if (WOOD == gGroundMaterialType) ! { ! std::cout << "New ground material is rubber" << std::endl; ! gGroundMaterialType = RUBBER; ! gGroundMaterial = opal::globals::rubberMaterial; ! gSimulator->destroySolid(gGround); ! gGround = gSimulator->createSolid(); ! gGround->setStatic(true); ! gGround->addPlane(gGroundParams, gGroundMaterial); ! } ! else if (RUBBER == gGroundMaterialType) ! { ! std::cout << "New ground material is ice" << std::endl; ! gGroundMaterialType = ICE; ! gGroundMaterial = opal::globals::iceMaterial; ! gSimulator->destroySolid(gGround); ! gGround = gSimulator->createSolid(); ! gGround->setStatic(true); ! gGround->addPlane(gGroundParams, gGroundMaterial); ! } ! else if (ICE == gGroundMaterialType) ! { ! std::cout << "New ground material is metal" << std::endl; ! gGroundMaterialType = METAL; ! gGroundMaterial = opal::globals::metalMaterial; ! gSimulator->destroySolid(gGround); ! gGround = gSimulator->createSolid(); ! gGround->setStatic(true); ! gGround->addPlane(gGroundParams, gGroundMaterial); ! } ! break; case SDLK_1: { --- 326,397 ---- gPaused = !gPaused; break; ! //case SDLK_m: ! // if (METAL == gObjectMaterialType) ! // { ! // std::cout << "New object material is wood" << std::endl; ! // gObjectMaterialType = WOOD; ! // gObjectMaterial = opal::globals::woodMaterial; ! // } ! // else if (WOOD == gObjectMaterialType) ! // { ! // std::cout << "New object material is rubber" << std::endl; ! // gObjectMaterialType = RUBBER; ! // gObjectMaterial = opal::globals::rubberMaterial; ! // } ! // else if (RUBBER == gObjectMaterialType) ! // { ! // std::cout << "New object material is ice" << std::endl; ! // gObjectMaterialType = ICE; ! // gObjectMaterial = opal::globals::iceMaterial; ! // } ! // else if (ICE == gObjectMaterialType) ! // { ! // std::cout << "New object material is metal" << std::endl; ! // gObjectMaterialType = METAL; ! // gObjectMaterial = opal::globals::metalMaterial; ! // } ! // break; ! //case SDLK_g: ! // if (METAL == gGroundMaterialType) ! // { ! // std::cout << "New ground material is wood" << std::endl; ! // gGroundMaterialType = WOOD; ! // gGroundMaterial = opal::globals::woodMaterial; ! // gSimulator->destroySolid(gGround); ! // gGround = gSimulator->createSolid(); ! // gGround->setStatic(true); ! // gGround->addPlane(gGroundParams, gGroundMaterial); ! // } ! // else if (WOOD == gGroundMaterialType) ! // { ! // std::cout << "New ground material is rubber" << std::endl; ! // gGroundMaterialType = RUBBER; ! // gGroundMaterial = opal::globals::rubberMaterial; ! // gSimulator->destroySolid(gGround); ! // gGround = gSimulator->createSolid(); ! // gGround->setStatic(true); ! // gGround->addPlane(gGroundParams, gGroundMaterial); ! // } ! // else if (RUBBER == gGroundMaterialType) ! // { ! // std::cout << "New ground material is ice" << std::endl; ! // gGroundMaterialType = ICE; ! // gGroundMaterial = opal::globals::iceMaterial; ! // gSimulator->destroySolid(gGround); ! // gGround = gSimulator->createSolid(); ! // gGround->setStatic(true); ! // gGround->addPlane(gGroundParams, gGroundMaterial); ! // } ! // else if (ICE == gGroundMaterialType) ! // { ! // std::cout << "New ground material is metal" << std::endl; ! // gGroundMaterialType = METAL; ! // gGroundMaterial = opal::globals::metalMaterial; ! // gSimulator->destroySolid(gGround); ! // gGround = gSimulator->createSolid(); ! // gGround->setStatic(true); ! // gGround->addPlane(gGroundParams, gGroundMaterial); ! // } ! // break; case SDLK_1: { |
|
From: tylerstreeter <tyl...@us...> - 2005-02-22 19:47:02
|
Update of /cvsroot/opal/opal/samples/car In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30562/samples/car Modified Files: main.cpp Log Message: made Data object types a private member; updated samples with new changes Index: main.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/car/main.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** main.cpp 12 Feb 2005 22:31:43 -0000 1.20 --- main.cpp 22 Feb 2005 19:46:18 -0000 1.21 *************** *** 75,81 **** //gSimulator->setDefaultAngularDamping(80.0); gGround = gSimulator->createSolid(); gGround->setStatic(true); ! gGround->addPlane(gGroundParams); //create ramp --- 75,89 ---- //gSimulator->setDefaultAngularDamping(80.0); + // Create and setup a Solid for the ground. gGround = gSimulator->createSolid(); gGround->setStatic(true); ! ! // Add a plane Shape to the Solid. ! opal::PlaneShapeData planeData; ! planeData.abcd[0] = gGroundParams[0]; ! planeData.abcd[1] = gGroundParams[1]; ! planeData.abcd[2] = gGroundParams[2]; ! planeData.abcd[3] = gGroundParams[3]; ! gGround->addShape(planeData); //create ramp |
|
From: tylerstreeter <tyl...@us...> - 2005-02-22 04:28:22
|
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 ---- |
|
From: tylerstreeter <tyl...@us...> - 2005-02-22 04:28:22
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32471/src Modified Files: Rayr.h SConscript opal.h Added Files: MeshShapeData.h PlaneShapeData.h RayShapeData.h Log Message: added more ShapeData classes Index: opal.h =================================================================== RCS file: /cvsroot/opal/opal/src/opal.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** opal.h 22 Feb 2005 01:25:55 -0000 1.14 --- opal.h 22 Feb 2005 04:28:11 -0000 1.15 *************** *** 35,38 **** --- 35,41 ---- #include "SphereShapeData.h" #include "CapsuleShapeData.h" + #include "PlaneShapeData.h" + #include "RayShapeData.h" + #include "MeshShapeData.h" #include "Motor.h" #include "AttractorMotor.h" --- NEW FILE: PlaneShapeData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_PLANE_SHAPE_DATA_H #define OPAL_PLANE_SHAPE_DATA_H #include "Defines.h" #include "ShapeData.h" namespace opal { /// A data structure describing a plane Shape. class PlaneShapeData : public ShapeData { public: PlaneShapeData() : ShapeData() { type = PLANE_SHAPE; for (int i=0; i<4; ++i) { abcd[i] = 0; } } /// Copy constructor. PlaneShapeData(const PlaneShapeData& data) { (*this) = data; } virtual ~PlaneShapeData() { } /// Makes a deep copy. virtual void OPAL_CALL operator=(const PlaneShapeData& data) { type = data.type; offset = data.offset; material = data.material; for (int i=0; i<4; ++i) { abcd[i] = data.abcd[i]; } } /// Parameters used to define the plane equation: /// a*x + b*y + c*z = d. real abcd[4]; protected: private: }; } #endif Index: Rayr.h =================================================================== RCS file: /cvsroot/opal/opal/src/Rayr.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Rayr.h 20 Feb 2005 06:26:47 -0000 1.5 --- Rayr.h 22 Feb 2005 04:28:11 -0000 1.6 *************** *** 80,83 **** --- 80,88 ---- } + real getLength()const + { + return mDir.length(); + } + void setOrigin( const Point3r & p ) { --- NEW FILE: RayShapeData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_RAY_SHAPE_DATA_H #define OPAL_RAY_SHAPE_DATA_H #include "Defines.h" #include "ShapeData.h" namespace opal { /// A data structure describing a ray Shape. class RayShapeData : public ShapeData { public: RayShapeData() : ShapeData() { type = RAY_SHAPE; // "ray" is already initialized from its constructor. } /// Copy constructor. RayShapeData(const RayShapeData& data) { (*this) = data; } virtual ~RayShapeData() { } /// Makes a deep copy. virtual void OPAL_CALL operator=(const RayShapeData& data) { type = data.type; offset = data.offset; material = data.material; ray = data.ray; } /// The ray data. Rayr ray; protected: private: }; } #endif Index: SConscript =================================================================== RCS file: /cvsroot/opal/opal/src/SConscript,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SConscript 16 Feb 2005 21:22:40 -0000 1.8 --- SConscript 22 Feb 2005 04:28:11 -0000 1.9 *************** *** 7,10 **** --- 7,12 ---- Blueprint.h BlueprintManager.h + BoxShapeData.h + CapsuleShapeData.h Defines.h EventHandler.h *************** *** 12,28 **** --- 14,36 ---- Joint.h Matrix44r.h + MeshShapeData.h Motor.h opal.h OpalMath.h + PlaneShapeData.h Point3r.h Portability.h Quaternion.h Rayr.h + RayShapeData.h Sensor.h ServoMotor.h + ShapeData.h Simulator.h Singleton.h Solid.h + SolidData.h Space.h + SphereShapeData.h SpringMotor.h ThrusterMotor.h --- NEW FILE: MeshShapeData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_MESH_SHAPE_DATA_H #define OPAL_MESH_SHAPE_DATA_H #include "Defines.h" #include "ShapeData.h" namespace opal { /// A data structure describing a mesh Shape. The data pointers /// for the vertex and face arrays must remain valid; no mesh data /// is stored anywhere within OPAL. It is critical that the size of /// the data type used in these arrays (i.e. OPAL real) matches the /// size of the data type expected by the underlying physics engine. class MeshShapeData : public ShapeData { public: MeshShapeData() : ShapeData() { type = MESH_SHAPE; vertexArray[0] = NULL; numVertices = 0; faceArray = NULL; numFaces = 0; } /// Copy constructor. MeshShapeData(const MeshShapeData& data) { (*this) = data; } virtual ~MeshShapeData() { } /// Makes a shallow copy, simply copying data pointers. virtual void OPAL_CALL operator=(const MeshShapeData& data) { type = data.type; offset = data.offset; material = data.material; vertexArray[0] = data.vertexArray[0]; numVertices = data.numVertices; faceArray = data.faceArray; numFaces = data.numFaces; } /// Pointer to a 2-dimensional array of vertices. For example, /// access the ith vertex like this: /// vertexArray[i][0] = 3.0; // x /// vertexArray[i][1] = 2.0; // y /// vertexArray[i][2] = 5.0; // z real* vertexArray[3]; /// The number of vertices in the mesh. int numVertices; /// Pointer to an array of indices into the vertex array. The size /// of this array = 3 * the number of faces since each face will /// need 3 different indices, one for each vertex. int* faceArray; /// The number of faces/triangles in the mesh. int numFaces; protected: private: }; } #endif |
|
From: tylerstreeter <tyl...@us...> - 2005-02-22 04:28:22
|
Update of /cvsroot/opal/opal/vc7 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32471/vc7 Modified Files: opal-ode.vcproj Log Message: added more ShapeData classes Index: opal-ode.vcproj =================================================================== RCS file: /cvsroot/opal/opal/vc7/opal-ode.vcproj,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** opal-ode.vcproj 22 Feb 2005 01:25:57 -0000 1.10 --- opal-ode.vcproj 22 Feb 2005 04:28:12 -0000 1.11 *************** *** 183,186 **** --- 183,189 ---- </File> <File + RelativePath="..\src\MeshShapeData.h"> + </File> + <File RelativePath="..\src\Motor.h"> </File> *************** *** 189,195 **** --- 192,204 ---- </File> <File + RelativePath="..\src\PlaneShapeData.h"> + </File> + <File RelativePath="..\src\Portability.h"> </File> <File + RelativePath="..\src\RayShapeData.h"> + </File> + <File RelativePath="..\src\Sensor.h"> </File> |
|
From: tylerstreeter <tyl...@us...> - 2005-02-22 01:26:08
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17286/src/ODE Modified Files: ODEJoint.cpp ODEJoint.h ODESimulator.cpp ODESimulator.h ODESolid.cpp ODESolid.h Log Message: added new Data classes Index: ODESimulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.cpp,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** ODESimulator.cpp 19 Feb 2005 20:54:37 -0000 1.77 --- ODESimulator.cpp 22 Feb 2005 01:25:56 -0000 1.78 *************** *** 27,31 **** #include "ODESimulator.h" ! #include <ode/config.h> namespace opal --- 27,32 ---- #include "ODESimulator.h" ! #include "../ShapeData.h" ! //#include <ode/config.h> namespace opal *************** *** 74,78 **** dWorldSetContactSurfaceLayer(mWorldID, defaults::ode::surfaceLayer); ! setAccuracy(defaults::accuracy); setSleepiness(defaults::sleepiness); mCollisionCount = 0; --- 75,79 ---- dWorldSetContactSurfaceLayer(mWorldID, defaults::ode::surfaceLayer); ! setSolverAccuracy(defaults::solverAccuracy); setSleepiness(defaults::sleepiness); mCollisionCount = 0; *************** *** 383,388 **** for(int i=0; i<numContacts; ++i) { ! const Material* m0 = &(geomData0->shape.material); ! const Material* m1 = &(geomData1->shape.material); tempContact.surface.mode = dContactBounce | --- 384,389 ---- for(int i=0; i<numContacts; ++i) { ! const Material* m0 = &(geomData0->shape->material); ! const Material* m1 = &(geomData1->shape->material); tempContact.surface.mode = dContactBounce | *************** *** 817,842 **** } ! void ODESimulator::setAccuracy(AccuracyLevel level) { switch(level) { ! case ACCURACY_VERY_LOW: mSolverType = SOLVER_QUICKSTEP; dWorldSetQuickStepNumIterations(mWorldID, 5); break; ! case ACCURACY_LOW: mSolverType = SOLVER_QUICKSTEP; dWorldSetQuickStepNumIterations(mWorldID, 10); break; ! case ACCURACY_MEDIUM: mSolverType = SOLVER_QUICKSTEP; // 20 is the default in ODE dWorldSetQuickStepNumIterations(mWorldID, 20); break; ! case ACCURACY_HIGH: mSolverType = SOLVER_QUICKSTEP; dWorldSetQuickStepNumIterations(mWorldID, 40); break; ! case ACCURACY_VERY_HIGH: mSolverType = SOLVER_WORLDSTEP; break; --- 818,845 ---- } ! void ODESimulator::setSolverAccuracy(SolverAccuracyLevel level) { + Simulator::setSolverAccuracy(level); + switch(level) { ! case SOLVER_ACCURACY_VERY_LOW: mSolverType = SOLVER_QUICKSTEP; dWorldSetQuickStepNumIterations(mWorldID, 5); break; ! case SOLVER_ACCURACY_LOW: mSolverType = SOLVER_QUICKSTEP; dWorldSetQuickStepNumIterations(mWorldID, 10); break; ! case SOLVER_ACCURACY_MEDIUM: mSolverType = SOLVER_QUICKSTEP; // 20 is the default in ODE dWorldSetQuickStepNumIterations(mWorldID, 20); break; ! case SOLVER_ACCURACY_HIGH: mSolverType = SOLVER_QUICKSTEP; dWorldSetQuickStepNumIterations(mWorldID, 40); break; ! case SOLVER_ACCURACY_VERY_HIGH: mSolverType = SOLVER_WORLDSTEP; break; *************** *** 845,850 **** break; } - - Simulator::setAccuracy(level); } --- 848,851 ---- Index: ODESolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** ODESolid.cpp 19 Feb 2005 20:54:37 -0000 1.64 --- ODESolid.cpp 22 Feb 2005 01:25:57 -0000 1.65 *************** *** 28,31 **** --- 28,34 ---- #include "ODESolid.h" #include "ODESpace.h" + #include "../BoxShapeData.h" + #include "../SphereShapeData.h" + #include "../CapsuleShapeData.h" namespace opal *************** *** 38,42 **** [...1234 lines suppressed...] ! dMassRotate(&newMass, R); ! dMassTranslate(&newMass, offset[12], offset[13], offset[14]); ! ! // If this mass is for the first Shape, just set the Solid's mass ! // equal to the new one. ODE bodies start with an initial mass ! // already setup, but we want to ignore that, not add to it. ! if (0 == mGeomDataList.size()) ! { ! dBodySetMass(mBodyID, &newMass); ! } ! else ! { ! // Add new mass to the Solid's existing mass. First get the ! // existing mass struct from ODE. ! dMass totalMass; ! dBodyGetMass(mBodyID, &totalMass); ! dMassAdd(&totalMass, &newMass); ! dBodySetMass(mBodyID, &totalMass); } } Index: ODESimulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.h,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** ODESimulator.h 18 Feb 2005 23:59:38 -0000 1.53 --- ODESimulator.h 22 Feb 2005 01:25:56 -0000 1.54 *************** *** 88,92 **** virtual void OPAL_CALL setSleepiness(real value); ! virtual void OPAL_CALL setAccuracy(AccuracyLevel level); virtual void OPAL_CALL internal_stepPhysics(); --- 88,92 ---- virtual void OPAL_CALL setSleepiness(real value); ! virtual void OPAL_CALL setSolverAccuracy(SolverAccuracyLevel level); virtual void OPAL_CALL internal_stepPhysics(); Index: ODEJoint.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODEJoint.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** ODEJoint.h 19 Feb 2005 20:54:37 -0000 1.26 --- ODEJoint.h 22 Feb 2005 01:25:56 -0000 1.27 *************** *** 44,47 **** --- 44,50 ---- virtual ~ODEJoint(); + /// Note: For a perfect save/restore in ODE, the "warm starting" + /// data should be stored in JointData. However, there is + /// currently no easy way to get this data. virtual void OPAL_CALL init(const JointData& jd); Index: ODESolid.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.h,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** ODESolid.h 19 Feb 2005 20:54:37 -0000 1.59 --- ODESolid.h 22 Feb 2005 01:25:57 -0000 1.60 *************** *** 38,42 **** /// A data structure used within ODESolids to store data describing /// ODE geoms. - // TODO: replace this with ShapeData? struct GeomData { --- 38,41 ---- *************** *** 44,47 **** --- 43,47 ---- { solid = NULL; + shape = NULL; geomID = 0; spaceID = 0; *************** *** 50,55 **** } - ShapeDescription shape; Solid* solid; dGeomID geomID; dSpaceID spaceID; --- 50,55 ---- } Solid* solid; + ShapeData* shape; dGeomID geomID; dSpaceID spaceID; *************** *** 58,62 **** }; ! /// The ODE implementation of the Solid class. class ODESolid : public Solid { --- 58,63 ---- }; ! /// The ODE implementation of the Solid class. Each ODE geom's user ! /// data pointer points to its corresponding ShapeData object. class ODESolid : public Solid { *************** *** 76,107 **** virtual void OPAL_CALL setStatic(bool s); ! virtual void OPAL_CALL addBox(const Vec3r& dimensions, ! const Matrix44r& offset = Matrix44r(), ! const Material& m = defaults::material); ! ! virtual void OPAL_CALL addSphere(real radius, ! const Matrix44r& offset = Matrix44r(), ! const Material& m = defaults::material); ! virtual void OPAL_CALL addPlane(real abcd[4], ! const Material& m = defaults::material); ! //note: normal cylinders are not yet part of standard ODE ! //virtual void addCylinder(real radius, real length, // const Matrix44r& offset = Matrix44r(), // const Material& m = defaults::material); ! virtual void OPAL_CALL addCapsule(real radius, real length, ! const Matrix44r& offset = Matrix44r(), ! const Material& m = defaults::material); ! virtual void OPAL_CALL addRay(const Point3r& origin, const Vec3r& dir, ! real length, const Matrix44r& offset = Matrix44r(), ! const Material& m = defaults::material); ! ! virtual void OPAL_CALL addMesh(const real* vertexArray[3], ! int numVertices, const int* faceArray, int numFaces, ! const Matrix44r& offset = Matrix44r(), ! const Material& m = defaults::material); virtual void OPAL_CALL setLocalLinearVel(const Vec3r& vel); --- 77,110 ---- virtual void OPAL_CALL setStatic(bool s); ! virtual void OPAL_CALL addShape(const ShapeData& sd); ! //virtual void OPAL_CALL addBox(const Vec3r& dimensions, ! // const Matrix44r& offset = Matrix44r(), ! // const Material& m = defaults::material); ! //virtual void OPAL_CALL addSphere(real radius, // const Matrix44r& offset = Matrix44r(), // const Material& m = defaults::material); ! //virtual void OPAL_CALL addPlane(real abcd[4], ! // const Material& m = defaults::material); ! ////note: normal cylinders are not yet part of standard ODE ! ////virtual void addCylinder(real radius, real length, ! //// const Matrix44r& offset = Matrix44r(), ! //// const Material& m = defaults::material); ! ! //virtual void OPAL_CALL addCapsule(real radius, real length, ! // const Matrix44r& offset = Matrix44r(), ! // const Material& m = defaults::material); ! ! //virtual void OPAL_CALL addRay(const Point3r& origin, const Vec3r& dir, ! // real length, const Matrix44r& offset = Matrix44r(), ! // const Material& m = defaults::material); ! // ! //virtual void OPAL_CALL addMesh(const real* vertexArray[3], ! // int numVertices, const int* faceArray, int numFaces, ! // const Matrix44r& offset = Matrix44r(), ! // const Material& m = defaults::material); virtual void OPAL_CALL setLocalLinearVel(const Vec3r& vel); *************** *** 152,160 **** protected: ! //void addNewGeom(dGeomID geomID, dGeomID transformID, ! // const Matrix44r& offset, const Material& material, ShapeType type); ! ! /// Adds a new geom data object to the internal list. ! void addNewGeom(GeomData* newGeom); virtual void applyForce(const Force& f); --- 155,161 ---- protected: ! /// Adds a new GeomData object to the internal list and sets up the ! /// ODE geom. ! void setupNewGeom(GeomData* newGeom); virtual void applyForce(const Force& f); *************** *** 162,166 **** /// Adds the given mass to this Solid's existing mass. The offset is /// relative to the Solid's center. This must be called before ! /// addNewGeom is called. void addMass(dMass& newMass, const Matrix44r& offset); --- 163,167 ---- /// Adds the given mass to this Solid's existing mass. The offset is /// relative to the Solid's center. This must be called before ! /// setupNewGeom is called. void addMass(dMass& newMass, const Matrix44r& offset); Index: ODEJoint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODEJoint.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ODEJoint.cpp 19 Feb 2005 20:54:37 -0000 1.22 --- ODEJoint.cpp 22 Feb 2005 01:25:56 -0000 1.23 *************** *** 647,651 **** } ! if (NULL == mSolid0 && NULL == mSolid1) { return; --- 647,651 ---- } ! if (NULL == mData.solid0 && NULL == mData.solid1) { return; *************** *** 658,662 **** { // Enable the joint. ! attachODEBodies((ODESolid*)mSolid0, (ODESolid*)mSolid1); } else --- 658,663 ---- { // Enable the joint. ! attachODEBodies((ODESolid*)mData.solid0, ! (ODESolid*)mData.solid1); } else |
|
From: tylerstreeter <tyl...@us...> - 2005-02-22 01:26:08
|
Update of /cvsroot/opal/opal/vc7 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17286/vc7 Modified Files: opal-ode.vcproj Log Message: added new Data classes Index: opal-ode.vcproj =================================================================== RCS file: /cvsroot/opal/opal/vc7/opal-ode.vcproj,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** opal-ode.vcproj 16 Feb 2005 05:06:48 -0000 1.9 --- opal-ode.vcproj 22 Feb 2005 01:25:57 -0000 1.10 *************** *** 165,168 **** --- 165,174 ---- </File> <File + RelativePath="..\src\BoxShapeData.h"> + </File> + <File + RelativePath="..\src\CapsuleShapeData.h"> + </File> + <File RelativePath="..\src\Defines.h"> </File> *************** *** 192,195 **** --- 198,204 ---- </File> <File + RelativePath="..\src\ShapeData.h"> + </File> + <File RelativePath="..\src\Simulator.h"> </File> *************** *** 201,207 **** --- 210,222 ---- </File> <File + RelativePath="..\src\SolidData.h"> + </File> + <File RelativePath="..\src\Space.h"> </File> <File + RelativePath="..\src\SphereShapeData.h"> + </File> + <File RelativePath="..\src\SpringMotor.h"> </File> |
|
From: tylerstreeter <tyl...@us...> - 2005-02-22 01:26:06
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17286/src Modified Files: Blueprint.cpp Blueprint.h BlueprintManager.cpp BlueprintManager.h Defines.h Joint.cpp Joint.h Simulator.cpp Simulator.h Solid.cpp Solid.h opal.h Added Files: BoxShapeData.h CapsuleShapeData.h ShapeData.h SolidData.h SphereShapeData.h Log Message: added new Data classes --- NEW FILE: SolidData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_SOLID_DATA_H #define OPAL_SOLID_DATA_H #include "Defines.h" #include "ShapeData.h" namespace opal { /// A data structure describing a Solid. class SolidData { public: SolidData() { enabled = defaults::solid::enabled; sleeping = defaults::solid::sleeping; isStatic = defaults::solid::isStatic; // Leave the transform as an identity matrix. globalLinearVel = 0; globalAngularVel = 0; linearDamping = defaults::linearDamping; angularDamping = defaults::angularDamping; // The Shape list doesn't need to be initialized. } /// Copy constructor. SolidData(const SolidData& sd) { (*this) = sd; } virtual ~SolidData() { while (!shapes.empty()) { delete shapes.back(); shapes.pop_back(); } } /// Makes a deep copy. virtual void OPAL_CALL operator=(const SolidData& sd) { enabled = sd.enabled; sleeping = sd.sleeping; isStatic = sd.isStatic; transform = sd.transform; globalLinearVel = sd.globalLinearVel; globalAngularVel = sd.globalAngularVel; linearDamping = sd.linearDamping; angularDamping = sd.angularDamping; shapes.clear(); for (unsigned int i=0; i<sd.shapes.size(); ++i) { shapes.push_back(sd.shapes[i]); } } bool enabled; bool sleeping; bool isStatic; Matrix44r transform; Vec3r globalLinearVel; Vec3r globalAngularVel; real linearDamping; real angularDamping; std::vector<ShapeData*> shapes; protected: private: }; } #endif --- NEW FILE: SphereShapeData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_SPHERE_SHAPE_DATA_H #define OPAL_SPHERE_SHAPE_DATA_H #include "Defines.h" #include "ShapeData.h" namespace opal { /// A data structure describing a sphere Shape. class SphereShapeData : public ShapeData { public: SphereShapeData() : ShapeData() { type = SPHERE_SHAPE; radius = 0; } /// Copy constructor. SphereShapeData(const SphereShapeData& data) { (*this) = data; } virtual ~SphereShapeData() { } /// Makes a deep copy. virtual void OPAL_CALL operator=(const SphereShapeData& data) { type = data.type; offset = data.offset; material = data.material; radius = data.radius; } /// The sphere's radius. real radius; protected: private: }; } #endif --- NEW FILE: ShapeData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_SHAPE_DATA_H #define OPAL_SHAPE_DATA_H #include "Defines.h" namespace opal { /// The types of collision shapes currently supported. enum ShapeType { BOX_SHAPE, SPHERE_SHAPE, CAPSULE_SHAPE, PLANE_SHAPE, RAY_SHAPE, MESH_SHAPE }; /// A data structure describing a Shape. Note that there is no other /// class associated with Shapes besides this one. class ShapeData { public: ShapeData() { type = SPHERE_SHAPE; // Leave the offset as an identity matrix. material = defaults::material; } virtual ~ShapeData() { } /// The Shape type. ShapeType type; /// The offset transform from a Solid's transform. Matrix44r offset; /// The Shape's material. Material material; protected: private: }; } #endif Index: Blueprint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Blueprint.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Blueprint.cpp 19 Feb 2005 20:54:36 -0000 1.11 --- Blueprint.cpp 22 Feb 2005 01:25:55 -0000 1.12 *************** *** 51,83 **** } ! void Blueprint::addSolid(const SolidDescription& sd) ! { ! if (solidExists(sd.name)) ! { ! std::cout << "Warning in opal::Blueprint::addSolid: Solid " << sd.name ! << " already exists in Blueprint " << mName ! << "; ignoring Solid" << std::endl; ! } ! else ! { ! mSolidMap[sd.name] = sd; ! } ! } ! ! void Blueprint::addJoint(const JointData& jd) ! { ! // TODO: fix this! ! //if (jointExists(jd.name)) ! //{ ! // std::cout << "Warning in opal::Blueprint::addJoint: Joint " << ! // jd.name << " already exists in Blueprint " << mName ! // << "; ignoring Joint" << std::endl; ! //} ! //else ! //{ ! // mJointMap[jd.name] = jd; ! //} ! } void Blueprint::addSpace(const SpaceDescription& sd) --- 51,81 ---- } ! //void Blueprint::addSolid(const SolidDescription& sd) ! //{ ! // if (solidExists(sd.name)) ! // { ! // std::cout << "Warning in opal::Blueprint::addSolid: Solid " << sd.name ! // << " already exists in Blueprint " << mName ! // << "; ignoring Solid" << std::endl; ! // } ! // else ! // { ! // mSolidMap[sd.name] = sd; ! // } ! //} ! //void Blueprint::addJoint(const JointData& jd) ! //{ ! // if (jointExists(jd.name)) ! // { ! // std::cout << "Warning in opal::Blueprint::addJoint: Joint " << ! // jd.name << " already exists in Blueprint " << mName ! // << "; ignoring Joint" << std::endl; ! // } ! // else ! // { ! // mJointMap[jd.name] = jd; ! // } ! //} void Blueprint::addSpace(const SpaceDescription& sd) *************** *** 96,100 **** } ! const std::map<std::string, SolidDescription>& Blueprint::getSolidMap()const { return mSolidMap; --- 94,98 ---- } ! const std::map<std::string, SolidData>& Blueprint::getSolidMap()const { return mSolidMap; --- NEW FILE: CapsuleShapeData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_CAPSULE_SHAPE_DATA_H #define OPAL_CAPSULE_SHAPE_DATA_H #include "Defines.h" #include "ShapeData.h" namespace opal { /// A data structure describing a capsule Shape. class CapsuleShapeData : public ShapeData { public: CapsuleShapeData() : ShapeData() { type = CAPSULE_SHAPE; radius = 0; length = 0; } /// Copy constructor. CapsuleShapeData(const CapsuleShapeData& data) { (*this) = data; } virtual ~CapsuleShapeData() { } /// Makes a deep copy. virtual void OPAL_CALL operator=(const CapsuleShapeData& data) { type = data.type; offset = data.offset; material = data.material; radius = data.radius; length = data.length; } /// The capsule's radius. real radius; /// The capsule's length. real length; protected: private: }; } #endif --- NEW FILE: BoxShapeData.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_BOX_SHAPE_DATA_H #define OPAL_BOX_SHAPE_DATA_H #include "Defines.h" #include "ShapeData.h" namespace opal { /// A data structure describing a box Shape. class BoxShapeData : public ShapeData { public: BoxShapeData() : ShapeData() { type = BOX_SHAPE; // "dimensions" is already initialized from its constructor. } /// Copy constructor. BoxShapeData(const BoxShapeData& data) { (*this) = data; } virtual ~BoxShapeData() { } /// Makes a deep copy. virtual void OPAL_CALL operator=(const BoxShapeData& data) { type = data.type; offset = data.offset; material = data.material; dimensions = data.dimensions; } /// The box's dimensions. Vec3r dimensions; protected: private: }; } #endif Index: opal.h =================================================================== RCS file: /cvsroot/opal/opal/src/opal.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** opal.h 18 Feb 2005 23:59:37 -0000 1.13 --- opal.h 22 Feb 2005 01:25:55 -0000 1.14 *************** *** 31,34 **** --- 31,38 ---- #include "Simulator.h" #include "Solid.h" + #include "SolidData.h" + #include "BoxShapeData.h" + #include "SphereShapeData.h" + #include "CapsuleShapeData.h" #include "Motor.h" #include "AttractorMotor.h" Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** Simulator.h 21 Feb 2005 15:54:40 -0000 1.72 --- Simulator.h 22 Feb 2005 01:25:55 -0000 1.73 *************** *** 62,65 **** --- 62,107 ---- }; + /// Contains maps of string names to object pointers for Solids, Joints, + /// Motors, and Sensors. + struct BlueprintInstance + { + ~BlueprintInstance() + { + solidMap.clear(); + jointMap.clear(); + } + + /// Convenience function for finding a Solid pointer by name. + /// Returns NULL if the pointer is not found. + Solid* getSolid(const std::string& name) + { + if (solidMap.end() == solidMap.find(name)) + { + return NULL; + } + else + { + return solidMap[name]; + } + } + + /// Convenience function for finding a Joint pointer by name. + /// Returns NULL if the pointer is not found. + Joint* getJoint(const std::string& name) + { + if (jointMap.end() == jointMap.find(name)) + { + return NULL; + } + else + { + return jointMap[name]; + } + } + + std::map<std::string, Solid*> solidMap; + std::map<std::string, Joint*> jointMap; + }; + /// A Simulator is an environment that contains simulated objects. /// It performs collision detection and physical simulation. It is *************** *** 111,118 **** /// Sets the accuracy level used by the physics engine's constraint /// solver. ! virtual void OPAL_CALL setAccuracy(AccuracyLevel level); /// Returns the accuracy level. ! virtual AccuracyLevel OPAL_CALL getAccuracy()const; //virtual void OPAL_CALL setDefaultLinearDamping(real ld); --- 153,160 ---- /// Sets the accuracy level used by the physics engine's constraint /// solver. ! virtual void OPAL_CALL setSolverAccuracy(SolverAccuracyLevel level); /// Returns the accuracy level. ! virtual SolverAccuracyLevel OPAL_CALL getSolverAccuracy()const; //virtual void OPAL_CALL setDefaultLinearDamping(real ld); *************** *** 269,273 **** /// The accuracy level used internally by the physics engine's /// constraint solver. ! AccuracyLevel mAccuracyLevel; /// Pointer to user data. This is totally user-managed (i.e. OPAL --- 311,315 ---- /// The accuracy level used internally by the physics engine's /// constraint solver. ! SolverAccuracyLevel mSolverAccuracyLevel; /// Pointer to user data. This is totally user-managed (i.e. OPAL Index: Solid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Solid.cpp 20 Feb 2005 07:12:58 -0000 1.21 --- Solid.cpp 22 Feb 2005 01:25:55 -0000 1.22 *************** *** 32,45 **** Solid::Solid() { ! mStatic = defaults::staticSolids; mEventHandler = NULL; setUserData(NULL); ! mEnabled = true; //mPrevGlobalLinearVel.set(0.0, 0.0, 0.0); //mPrevGlobalAngularVel.set(0.0, 0.0, 0.0); //mGlobalLinearAccel.set(0.0, 0.0, 0.0); //mGlobalAngularAccel.set(0.0, 0.0, 0.0); ! setLinearDamping(defaults::linearDamping); ! setAngularDamping(defaults::linearDamping); } --- 32,45 ---- Solid::Solid() { ! //mStatic = defaults::solid::isStatic; mEventHandler = NULL; setUserData(NULL); ! //mEnabled = defaults::solid::enabled; //mPrevGlobalLinearVel.set(0.0, 0.0, 0.0); //mPrevGlobalAngularVel.set(0.0, 0.0, 0.0); //mGlobalLinearAccel.set(0.0, 0.0, 0.0); //mGlobalAngularAccel.set(0.0, 0.0, 0.0); ! //setLinearDamping(defaults::linearDamping); ! //setAngularDamping(defaults::linearDamping); } *************** *** 49,60 **** } bool Solid::isEnabled()const { ! return mEnabled; } void Solid::setEnabled(bool e) { ! mEnabled = e; } --- 49,68 ---- } + const SolidData& Solid::getSolidData() + { + // The sleeping parameter needs to be updated here because it + // doesn't get updated automatically. + mData.sleeping = isSleeping(); + return mData; + } + bool Solid::isEnabled()const { ! return mData.enabled; } void Solid::setEnabled(bool e) { ! mData.enabled = e; } *************** *** 83,87 **** bool Solid::isStatic() { ! return mStatic; } --- 91,95 ---- bool Solid::isStatic() { ! return mData.isStatic; } *************** *** 89,98 **** { assert(ld >= 0.0); ! mLinearDamping = ld; } real Solid::getLinearDamping()const { ! return mLinearDamping; } --- 97,106 ---- { assert(ld >= 0.0); ! mData.linearDamping = ld; } real Solid::getLinearDamping()const { ! return mData.linearDamping; } *************** *** 100,109 **** { assert(ad >= 0.0); ! mAngularDamping = ad; } real Solid::getAngularDamping()const { ! return mAngularDamping; } --- 108,117 ---- { assert(ad >= 0.0); ! mData.angularDamping = ad; } real Solid::getAngularDamping()const { ! return mData.angularDamping; } *************** *** 120,124 **** void Solid::setTransform(const Matrix44r& transform) { ! mTransform = transform; internal_updateEngineTransform(); } --- 128,132 ---- void Solid::setTransform(const Matrix44r& transform) { ! mData.transform = transform; internal_updateEngineTransform(); } *************** *** 126,135 **** const Matrix44r& Solid::getTransform()const { ! return mTransform; } void Solid::setPosition(real x, real y, real z) { ! mTransform.setPosition(x, y, z); internal_updateEngineTransform(); } --- 134,143 ---- const Matrix44r& Solid::getTransform()const { ! return mData.transform; } void Solid::setPosition(real x, real y, real z) { ! mData.transform.setPosition(x, y, z); internal_updateEngineTransform(); } *************** *** 142,156 **** Point3r Solid::getPosition()const { ! return mTransform.getPosition(); } Vec3r Solid::getEulerXYZ()const { ! return mTransform.getEulerXYZ(); } Quaternion Solid::getQuaternion()const { ! return mTransform.getQuaternion(); } --- 150,164 ---- Point3r Solid::getPosition()const { ! return mData.transform.getPosition(); } Vec3r Solid::getEulerXYZ()const { ! return mData.transform.getEulerXYZ(); } Quaternion Solid::getQuaternion()const { ! return mData.transform.getQuaternion(); } *************** *** 177,181 **** void Solid::addForce(const Force& f) { ! if (mEnabled && !mStatic && f.vec.lengthSquared() > 0.0000001f ) { mForceList.push_back(f); --- 185,190 ---- void Solid::addForce(const Force& f) { ! if (mData.enabled && !mData.isStatic && ! f.vec.lengthSquared() > 0.0000001f ) { mForceList.push_back(f); *************** *** 279,283 **** void Solid::internal_applyForces(real stepSize) { ! if (mStatic) { return; --- 288,292 ---- void Solid::internal_applyForces(real stepSize) { ! if (mData.isStatic) { return; *************** *** 356,373 **** //} ! BodyState Solid::getState()const ! { ! BodyState s; ! s.transform = getTransform(); ! s.globalAngularVel = getGlobalAngularVel(); ! s.globalLinearVel = getGlobalLinearVel(); ! return s; ! } ! void Solid::setState(const BodyState & s) ! { ! setTransform(s.transform); ! setGlobalAngularVel(s.globalAngularVel); ! setGlobalLinearVel(s.globalLinearVel); ! } } --- 365,382 ---- //} ! //BodyState Solid::getState()const ! //{ ! // BodyState s; ! // s.transform = getTransform(); ! // s.globalAngularVel = getGlobalAngularVel(); ! // s.globalLinearVel = getGlobalLinearVel(); ! // return s; ! //} ! //void Solid::setState(const BodyState & s) ! //{ ! // setTransform(s.transform); ! // setGlobalAngularVel(s.globalAngularVel); ! // setGlobalLinearVel(s.globalLinearVel); ! //} } Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** Defines.h 21 Feb 2005 15:54:35 -0000 1.56 --- Defines.h 22 Feb 2005 01:25:55 -0000 1.57 *************** *** 162,174 **** }; ! /// Accuracy levels determine how the physics engine constraint solver ! /// is used (e.g. the number of iterations in an iterative solver). ! enum AccuracyLevel { ! ACCURACY_VERY_LOW, ! ACCURACY_LOW, ! ACCURACY_MEDIUM, ! ACCURACY_HIGH, ! ACCURACY_VERY_HIGH }; --- 162,175 ---- }; ! /// Solver accuracy levels determine how the physics engine constraint ! /// solver is used (e.g. the number of iterations in an iterative ! /// solver). ! enum SolverAccuracyLevel { ! SOLVER_ACCURACY_VERY_LOW, ! SOLVER_ACCURACY_LOW, ! SOLVER_ACCURACY_MEDIUM, ! SOLVER_ACCURACY_HIGH, ! SOLVER_ACCURACY_VERY_HIGH }; *************** *** 222,236 **** }; - /// The types of collision shapes currently supported. - enum ShapeType - { - BOX_SHAPE, - SPHERE_SHAPE, - CAPSULE_SHAPE, - PLANE_SHAPE, - RAY_SHAPE, - MESH_SHAPE - }; - /// A namespace containing globally useful parameters. namespace globals --- 223,226 ---- *************** *** 267,272 **** const Material iceMaterial(iceHardness, iceFriction, iceBounciness, iceDensity); - - const int numShapeDimensions=7; } --- 257,260 ---- *************** *** 276,284 **** const real stepSize = (real)0.0167; // ~60 Hz physics rate const Vec3r gravity(0, 0, 0); - const bool staticSolids = false; const real sleepiness = (real)0.5; const real bounceThreshold = (real)1.0; const Material material(opal::globals::woodMaterial); ! const AccuracyLevel accuracy = ACCURACY_MEDIUM; //const bool allowPartialFrames=true; //const int maxStepsPerFrame=10; --- 264,271 ---- const real stepSize = (real)0.0167; // ~60 Hz physics rate const Vec3r gravity(0, 0, 0); const real sleepiness = (real)0.5; const real bounceThreshold = (real)1.0; const Material material(opal::globals::woodMaterial); ! const SolverAccuracyLevel solverAccuracy = SOLVER_ACCURACY_MEDIUM; //const bool allowPartialFrames=true; //const int maxStepsPerFrame=10; *************** *** 288,291 **** --- 275,286 ---- const real maxAngularVel = (real)1000.0; + /// Default parameters used in Solid creation. + namespace solid + { + const bool enabled = true; + const bool sleeping = true; + const bool isStatic = false; + } + /// Default parameters used in Joint creation. namespace joint *************** *** 368,409 **** } - /// TODO: replace with ShapeData - struct ShapeDescription - { - ShapeDescription() - { - for (int i=0; i<globals::numShapeDimensions; ++i) - { - dimensions[i] = 0; - } - type = BOX_SHAPE; - offset.makeIdentity(); - material = defaults::material; - } - - // TODO: this needs an operator= - - // dimensions for all shape types are stored in "dimensions"; for - // boxes, elements 0, 1, 2 are dimensions; for spheres, element 0 is - // radius; for planes, elements 0, 1, 2, 3 are the plane normal and - // distance from the origin (i.e. they define the plane equation - // ax + by + cz = d); for capped cylinders, elements 0 and 1 are - // radius and length; for rays, elements 0, 1, 2 are the ray origin, - // 3, 4, 5 are direction, and 6 is length - real dimensions[globals::numShapeDimensions]; - ShapeType type; - Matrix44r offset; - Material material; - }; - // Structs used for Blueprints... /// Data structure for storing user-defined properties loaded from XML /// files. ! struct UserProperty ! { ! std::string name; ! std::string value; ! }; /// TODO: replace with SpaceData? --- 363,375 ---- } // Structs used for Blueprints... /// Data structure for storing user-defined properties loaded from XML /// files. ! //struct UserProperty ! //{ ! // std::string name; ! // std::string value; ! //}; /// TODO: replace with SpaceData? *************** *** 415,419 **** } ! // TODO: this needs an operator= bool containsSolid(const std::string& name) --- 381,385 ---- } ! // TODO: this needs an operator= and copy constructor bool containsSolid(const std::string& name) *************** *** 434,539 **** std::vector<std::string> solidNameList; }; - - /// TODO: replace with SolidData struct - struct BodyState - { - Matrix44r transform; - Vec3r globalLinearVel; - Vec3r globalAngularVel; - }; - - /// TODO: replace with SolidData - struct SolidDescription - { - ~SolidDescription() - { - shapeList.clear(); - userProperties.clear(); - } - - // TODO: this needs an operator= - - std::string name; - Matrix44r transform; - bool isStatic; - real linearDamping; - real angularDamping; - std::vector<ShapeDescription> shapeList; - std::vector<UserProperty> userProperties; - }; - - /// TODO: expand this to include all Solid data - struct SolidData - { - ~SolidData() - { - userProperties.clear(); - } - - // TODO: this needs an operator= - - std::string getUserProperty(std::string name) - { - std::map<std::string, std::string>::iterator iter = - userProperties.find(name); - if (userProperties.end() != iter) - { - return (*iter).second; - } - else - { - return ""; - } - } - - Solid* solidPtr; - std::map<std::string, std::string> userProperties; - }; - - /// For giving users lists of pointers to Solids and Joints created from - /// blueprints; pointers can be accessed by individual names. - struct NamedObjectCollection - { - ~NamedObjectCollection() - { - solidMap.clear(); - jointMap.clear(); - } - - // TODO: this needs an operator= - - SolidData getSolid(std::string name) - { - if (solidMap.end() == solidMap.find(name)) - { - //std::cout << "Error in opal::NamedObjectCollection::getSolid: Invalid solid requested: " - // << name << std::endl; - SolidData sd; - sd.solidPtr = NULL; - return sd; - } - else - { - return solidMap[name]; - } - } - - Joint* getJoint(std::string name) - { - if (jointMap.end() == jointMap.find(name)) - { - //std::cout << "Error in opal::NamedObjectCollection::getJoint: Invalid joint requested: " - // << name << std::endl; - return NULL; - } - else - { - return jointMap[name]; - } - } - - std::map<std::string, SolidData> solidMap; - std::map<std::string, Joint*> jointMap; - }; } --- 400,403 ---- Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** Solid.h 19 Feb 2005 20:54:36 -0000 1.73 --- Solid.h 22 Feb 2005 01:25:55 -0000 1.74 *************** *** 31,34 **** --- 31,35 ---- #include "Defines.h" #include "EventHandler.h" + #include "SolidData.h" namespace opal *************** *** 36,39 **** --- 37,218 ---- class Simulator; class Space; + class ShapeData; + + /// TODO: replace with SolidData struct + //struct BodyState + //{ + // Matrix44r transform; + // Vec3r globalLinearVel; + // Vec3r globalAngularVel; + //}; + + ///// TODO: replace with SolidData + //struct SolidDescription + //{ + // ~SolidDescription() + // { + // shapeList.clear(); + // userProperties.clear(); + // } + + // std::string name; + // Matrix44r transform; + // bool isStatic; + // real linearDamping; + // real angularDamping; + // std::vector<ShapeDescription> shapeList; + // std::vector<UserProperty> userProperties; + //}; + + // Old data structure... + //struct SolidData + //{ + // ~SolidData() + // { + // userProperties.clear(); + // } + + // std::string getUserProperty(std::string name) + // { + // std::map<std::string, std::string>::iterator iter = + // userProperties.find(name); + // if (userProperties.end() != iter) + // { + // return (*iter).second; + // } + // else + // { + // return ""; + // } + // } + + // Solid* solidPtr; + // std::map<std::string, std::string> userProperties; + //} + + //namespace globals + //{ + // /// The number of floats needed to describe the dimensions of + // /// any Shape. + // const int numShapeDimensions=7; + //} + + ///// A data structure containing all essential parameters that describe + ///// a Shape. Note that there is no class associated with Shapes, just + ///// this data structure. + //struct ShapeData + //{ + // ShapeData() + // { + // type = SPHERE_SHAPE; + // // Leave the offset as an identity matrix. + // material = defaults::material; + + // for (int i=0; i<globals::numShapeDimensions; ++i) + // { + // dimensions[i] = 0; + // } + // } + + // /// Copy constructor. + // ShapeData(const ShapeData& sd) + // { + // (*this) = sd; + // } + + // /// Makes a deep copy. + // void operator=(const ShapeData& sd) + // { + // type = sd.type; + // offset = sd.offset; + // material = sd.material; + + // for (int i=0; i<globals::numShapeDimensions; ++i) + // { + // dimensions[i] = sd.dimensions[i]; + // } + // } + + // /// The Shape type. + // ShapeType type; + + // /// The offset transform from a Solid's transform. + // Matrix44r offset; + + // /// The Shape's material. + // Material material; + + // /// Dimensions for all Shape types are stored in the "dimensions" + // /// array. + // /// Boxes: elements 0, 1, 2 are the box dimensions. + // /// Spheres: element 0 is radius. + // /// Planes: elements 0, 1, 2, 3 are the plane normal and + // /// distance from the origin (i.e. they define the plane equation + // /// ax + by + cz = d). + // /// Capped cylinders: elements 0 and 1 are radius and length. + // /// Rays: elements 0, 1, 2 are the origin, 3, 4, 5 are direction, + // /// and 6 is length. + // real dimensions[globals::numShapeDimensions]; + //}; + + ///// A data structure containing all essential parameters that describe + ///// a Solid. + //struct SolidData + //{ + // SolidData() + // { + // enabled = defaults::solid::enabled; + // sleeping = defaults::solid::sleeping; + // isStatic = defaults::solid::isStatic; + // // Leave the transform as an identity matrix. + // globalLinearVel = 0; + // globalAngularVel = 0; + // linearDamping = defaults::linearDamping; + // angularDamping = defaults::angularDamping; + // // The Shape list doesn't need to be initialized. + // } + + // /// Copy constructor. + // SolidData(const SolidData& sd) + // { + // (*this) = sd; + // } + + // /// This is necessary because SolidData uses a dynamically-allocated + // /// list of Shapes. + // ~SolidData() + // { + // shapes.clear(); + // } + + // /// Makes a deep copy. + // void operator=(const SolidData& sd) + // { + // enabled = sd.enabled; + // sleeping = sd.sleeping; + // isStatic = sd.isStatic; + // transform = sd.transform; + // globalLinearVel = sd.globalLinearVel; + // globalAngularVel = sd.globalAngularVel; + // linearDamping = sd.linearDamping; + // angularDamping = sd.angularDamping; + + // shapes.clear(); + // for (unsigned int i=0; i<sd.shapes.size(); ++i) + // { + // shapes.push_back(sd.shapes[i]); + // } + // } + + // bool enabled; + // bool sleeping; + // bool isStatic; + // Matrix44r transform; + // Vec3r globalLinearVel; + // Vec3r globalAngularVel; + // real linearDamping; + // real angularDamping; + // std::vector<ShapeData> shapes; + //}; /// Solids are the physical objects in the simulation. Solids can be *************** *** 50,53 **** --- 229,235 ---- virtual ~Solid(); + /// Returns all data describing the Solid. + virtual const SolidData& OPAL_CALL getSolidData(); + /// Returns true if the Solid is enabled. virtual bool OPAL_CALL isEnabled()const; *************** *** 121,170 **** virtual Quaternion OPAL_CALL getQuaternion()const; ! /// Adds a box Shape to this Solid. ! virtual void OPAL_CALL addBox(const Vec3r& dimensions, ! const Matrix44r& offset = Matrix44r(), ! const Material& m = defaults::material) = 0; ! /// Adds a sphere Shape to this Solid. ! virtual void OPAL_CALL addSphere(real radius, ! const Matrix44r& offset = Matrix44r(), ! const Material& m = defaults::material) = 0; ! /// Adds a plane Shape to this Solid. abcd are used to define ! /// the plane equation a*x + b*y + c*z = d. ! virtual void OPAL_CALL addPlane(real abcd[4], ! const Material& m = defaults::material) = 0; ! // alternate plane definition method; uses a point on the plane and ! // the plane normal ! //void addPlane(const Point3r& point, const Vec3r& normal, ! // const Material& m = defaults::material); ! //note: normal cylinders are not yet part of standard ODE ! //virtual void addCylinder(real radius, real length, // const Matrix44r& offset = Matrix44r(), // const Material& m = defaults::material) = 0; ! /// Adds a capsule Shape to this Solid. ! virtual void OPAL_CALL addCapsule(real radius, real length, ! const Matrix44r& offset = Matrix44r(), ! const Material& m = defaults::material) = 0; ! ! /// Adds a ray Shape to this Solid. ! virtual void OPAL_CALL addRay(const Point3r& origin, ! const Vec3r& dir, real length, ! const Matrix44r& offset = Matrix44r(), ! const Material& m = defaults::material) = 0; ! /// The data pointers passed in here must remain valid because no data ! /// is stored within the Solid. It is critical that the size of the ! /// data type used in these arrays (i.e. OPAL real) matches the size ! /// of the data type expected by the underlying physics engine. ! virtual void OPAL_CALL addMesh(const real* vertexArray[3], ! int numVertices, const int* faceArray, int numFaces, ! const Matrix44r& offset = Matrix44r(), ! const Material& m = defaults::material) = 0; ! //virtual void addCHull(); /// Applies a force/torque to this Solid. If the Solid is disabled, --- 303,355 ---- virtual Quaternion OPAL_CALL getQuaternion()const; ! /// Adds a Shape to this Solid. ! virtual void OPAL_CALL addShape(const ShapeData& sd) = 0; ! ///// Adds a box Shape to this Solid. ! //virtual void OPAL_CALL addBox(const Vec3r& dimensions, ! // const Matrix44r& offset = Matrix44r(), ! // const Material& m = defaults::material) = 0; ! ///// Adds a sphere Shape to this Solid. ! //virtual void OPAL_CALL addSphere(real radius, ! // const Matrix44r& offset = Matrix44r(), ! // const Material& m = defaults::material) = 0; ! ///// Adds a plane Shape to this Solid. abcd are used to define ! ///// the plane equation a*x + b*y + c*z = d. ! //virtual void OPAL_CALL addPlane(real abcd[4], ! // const Material& m = defaults::material) = 0; ! //// alternate plane definition method; uses a point on the plane and ! //// the plane normal ! ////void addPlane(const Point3r& point, const Vec3r& normal, ! //// const Material& m = defaults::material); ! ! ////note: normal cylinders are not yet part of standard ODE ! ////virtual void addCylinder(real radius, real length, ! //// const Matrix44r& offset = Matrix44r(), ! //// const Material& m = defaults::material) = 0; ! ! ///// Adds a capsule Shape to this Solid. ! //virtual void OPAL_CALL addCapsule(real radius, real length, // const Matrix44r& offset = Matrix44r(), // const Material& m = defaults::material) = 0; ! ///// Adds a ray Shape to this Solid. ! //virtual void OPAL_CALL addRay(const Point3r& origin, ! // const Vec3r& dir, real length, ! // const Matrix44r& offset = Matrix44r(), ! // const Material& m = defaults::material) = 0; ! ///// The data pointers passed in here must remain valid because no data ! ///// is stored within the Solid. It is critical that the size of the ! ///// data type used in these arrays (i.e. OPAL real) matches the size ! ///// of the data type expected by the underlying physics engine. ! //virtual void OPAL_CALL addMesh(const real* vertexArray[3], ! // int numVertices, const int* faceArray, int numFaces, ! // const Matrix44r& offset = Matrix44r(), ! // const Material& m = defaults::material) = 0; ! ////virtual void addCHull(); /// Applies a force/torque to this Solid. If the Solid is disabled, *************** *** 250,257 **** // TODO: replace with SolidData functions? ! virtual BodyState OPAL_CALL getState()const; // TODO: replace with SolidData functions? ! virtual void OPAL_CALL setState(const BodyState & s); /// Update the OPAL transform using the physics engine transform. --- 435,442 ---- // TODO: replace with SolidData functions? ! //virtual BodyState OPAL_CALL getState()const; // TODO: replace with SolidData functions? ! //virtual void OPAL_CALL setState(const BodyState & s); /// Update the OPAL transform using the physics engine transform. *************** *** 274,285 **** std::vector<Force> mForceList; /// This Solids's transform corresponding to its center of mass. ! Matrix44r mTransform; /// True if this Solid is enabled. ! bool mEnabled; /// True if this Solid is static. ! bool mStatic; /// Pointer to this Solid's event handler. --- 459,473 ---- std::vector<Force> mForceList; + /// Stores data describing the Solid. + SolidData mData; + /// This Solids's transform corresponding to its center of mass. ! //Matrix44r mTransform; /// True if this Solid is enabled. ! //bool mEnabled; /// True if this Solid is static. ! //bool mStatic; /// Pointer to this Solid's event handler. *************** *** 296,303 **** /// The amount of linear damping used by this Solid. ! real mLinearDamping; /// The amount of angular damping used by this Solid. ! real mAngularDamping; private: --- 484,491 ---- /// The amount of linear damping used by this Solid. ! //real mLinearDamping; /// The amount of angular damping used by this Solid. ! //real mAngularDamping; private: Index: BlueprintManager.h =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintManager.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** BlueprintManager.h 19 Feb 2005 20:54:36 -0000 1.13 --- BlueprintManager.h 22 Feb 2005 01:25:55 -0000 1.14 *************** *** 46,50 **** virtual ~BlueprintManager(); ! virtual void OPAL_CALL loadFile(const std::string& filename); virtual void OPAL_CALL addBlueprint(Blueprint* bp); --- 46,50 ---- virtual ~BlueprintManager(); ! //virtual void OPAL_CALL loadFile(const std::string& filename); virtual void OPAL_CALL addBlueprint(Blueprint* bp); *************** *** 56,61 **** private: ! SolidDescription loadSolid(const TiXmlNode* nodePtr, ! const std::string& filename); JointData loadJoint(const TiXmlNode* nodePtr, --- 56,61 ---- private: ! //SolidData loadSolid(const TiXmlNode* nodePtr, ! // const std::string& filename); JointData loadJoint(const TiXmlNode* nodePtr, *************** *** 65,70 **** const std::string& filename); ! ShapeDescription loadShape(const TiXmlNode* nodePtr, ! const std::string& filename); // helper function; returns false if the attribute doesn't exist --- 65,70 ---- const std::string& filename); ! //ShapeData loadShape(const TiXmlNode* nodePtr, ! // const std::string& filename); // helper function; returns false if the attribute doesn't exist Index: Joint.h =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.h,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** Joint.h 21 Feb 2005 15:54:38 -0000 1.52 --- Joint.h 22 Feb 2005 01:25:55 -0000 1.53 *************** *** 105,127 **** JointData(const JointData& jd) { ! type = jd.type; ! enabled = jd.enabled; ! //name = jd.name; ! solid0 = jd.solid0; ! solid1 = jd.solid1; ! anchor = jd.anchor; ! ! for (int i=0; i<3; ++i) ! { ! axis[i] = jd.axis[i]; ! } ! ! breakMode = jd.breakMode; ! breakThresh = jd.breakThresh; ! accumThresh = jd.accumThresh; ! accumDamage = jd.accumDamage; } ! /// This is necessary because JointDatas contain an array. void operator=(const JointData& jd) { --- 105,112 ---- JointData(const JointData& jd) { ! (*this) = jd; } ! /// Makes a deep copy. void operator=(const JointData& jd) { *************** *** 221,225 **** /// Returns all data describing the Joint. ! virtual const JointData& getJointData(); /// Returns the Joint type. --- 206,210 ---- /// Returns all data describing the Joint. ! virtual const JointData& OPAL_CALL getJointData(); /// Returns the Joint type. *************** *** 377,388 **** void updateDamage(real currentStress); ! /// Stores most data describing the Joint. JointData mData; ! /// A pointer to Solid0. ! Solid* mSolid0; ! /// A pointer to Solid1. ! Solid* mSolid1; /// A pointer to the Joint's event handler. --- 362,373 ---- void updateDamage(real currentStress); ! /// Stores data describing the Joint. JointData mData; ! ///// A pointer to Solid0. ! //Solid* mSolid0; ! ///// A pointer to Solid1. ! //Solid* mSolid1; /// A pointer to the Joint's event handler. Index: BlueprintManager.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintManager.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** BlueprintManager.cpp 19 Feb 2005 20:54:36 -0000 1.23 --- BlueprintManager.cpp 22 Feb 2005 01:25:55 -0000 1.24 *************** *** 82,264 **** } ! void BlueprintManager::loadFile(const std::string& filename) ! { ! #ifdef OPAL_USE_XML ! ! // the XML file will contain one or more OpalBlueprint elements; ! // each OpalBlueprint element contains one or more Solid elements ! // and zero or more Joint elements; an OpalBlueprint can contain ! // zero or more Space elements containing Solid elements; note ! // that in many case (e.g. offsets, materials) the default values ! // will automatically be used if no elements are specified ! ! TiXmlDocument file; ! if (false == file.LoadFile(filename.c_str())) ! { ! std::cout << "Error in opal::BlueprintManager::loadFile: \ ! Failed to load XML file: " ! << filename << std::endl; ! return; ! } ! ! TiXmlElement* rootElement = file.RootElement(); ! if (NULL == rootElement) ! { ! std::cout << "Error in opal::BlueprintManager::loadFile: \ ! Missing root element in XML file: " ! << filename << std::endl; ! return; ! } ! ! // loop over blueprints ! TiXmlNode* blueprintNodePtr = NULL; ! while (blueprintNodePtr = rootElement->IterateChildren( ! "OpalBlueprint", blueprintNodePtr)) ! { ! Blueprint* bp = new Blueprint(); ! ! bp->setName(getAttributeString(blueprintNodePtr, "name")); ! ! // loop over spaces; TODO: should we support hierarchical ! // spaces in XML files? ! TiXmlNode* spaceNodePtr = NULL; ! while (spaceNodePtr = blueprintNodePtr->IterateChildren( ! "Space", spaceNodePtr)) ! { ! SpaceDescription newSpace; ! ! // loop over solids within this space ! TiXmlNode* solidNodePtr = NULL; ! while (solidNodePtr = spaceNodePtr->IterateChildren( ! "Solid", solidNodePtr)) ! { ! SolidDescription newSolid = loadSolid(solidNodePtr, ! filename); ! bp->addSolid(newSolid); ! newSpace.solidNameList.push_back(newSolid.name); ! } ! ! if (0 == newSpace.solidNameList.size()) ! { ! std::cout << "Warning in opal::BlueprintManager::\ ! loadFile: Empty space will be ignored" ! << " in " << filename << std::endl; ! } ! else ! { ! bp->addSpace(newSpace); ! } ! } ! ! // loop over solids (those not in spaces) ! TiXmlNode* solidNodePtr = NULL; ! while (solidNodePtr = blueprintNodePtr->IterateChildren( ! "Solid", solidNodePtr)) ! { ! SolidDescription newSolid = loadSolid(solidNodePtr, ! filename); ! bp->addSolid(newSolid); ! } ! ! // loop over joints ! TiXmlNode* jointNodePtr = NULL; ! while (jointNodePtr = blueprintNodePtr->IterateChildren( ! "Joint", jointNodePtr)) ! { ! JointData newJoint = loadJoint(jointNodePtr, ! filename); ! bp->addJoint(newJoint); ! } ! ! addBlueprint(bp); ! } ! #endif ! } ! ! SolidDescription BlueprintManager::loadSolid(const TiXmlNode* nodePtr, ! const std::string& filename) ! { ! SolidDescription sd; ! ! #ifdef OPAL_USE_XML ! ! sd.name = getAttributeString(nodePtr, "name"); ! ! // specify default parameters in case they aren't given in the file ! sd.isStatic = defaults::staticSolids; ! sd.linearDamping = defaults::linearDamping; ! sd.angularDamping = defaults::angularDamping; ! ! // load Params elements ! TiXmlNode* paramsNodePtr = ! const_cast<TiXmlNode*>(nodePtr)->FirstChild("Params"); ! if (NULL != paramsNodePtr) ! { ! // loop over Params ! TiXmlNode* paramNodePtr = NULL; ! ! while (paramNodePtr = paramsNodePtr->IterateChildren("Param", ! paramNodePtr)) ! { ! TiXmlAttribute* a = ! paramNodePtr->ToElement()->FirstAttribute(); ! std::string name = a->Name(); ! std::string value = a->Value(); ! ! if (name == "static") ! { ! if (value == "true") ! { ! sd.isStatic = true; ! } ! // default static value is specified above ! } ! else if (name == "lineardamping") ! { ! sd.linearDamping = getAttributeReal(paramNodePtr, ! "lineardamping"); ! } ! else if (name == "angulardamping") ! { ! sd.angularDamping = getAttributeReal(paramNodePtr, ! "value"); ! } ! else ! { ! // this is a user-defined property ! UserProperty prop; ! prop.name = name; ! prop.value = value; ! sd.userProperties.push_back(prop); ! } ! } ! } ! ! // load Offset element ! TiXmlNode* offsetNodePtr = ! const_cast<TiXmlNode*>(nodePtr)->FirstChild("Offset"); ! if (NULL != offsetNodePtr) ! { ! sd.transform = loadOffset(offsetNodePtr, filename); ! } ! else ! { ! // offset will remain as an identity matrix ! sd.transform.makeIdentity(); ! } ! ! // loop over shapes ! TiXmlNode* shapeNodePtr = NULL; ! while (shapeNodePtr = const_cast<TiXmlNode*> ! (nodePtr)->IterateChildren("Shape", shapeNodePtr)) ! { ! ShapeDescription shape = loadShape(shapeNodePtr, filename); ! sd.shapeList.push_back(shape); ! } ! ! #endif ! ! return sd; ! } Matrix44r BlueprintManager::loadOffset(const TiXmlNode* nodePtr, --- 82,264 ---- } ! // void BlueprintManager::loadFile(const std::string& filename) ! // { ! //#ifdef OPAL_USE_XML ! // ! // // the XML file will contain one or more OpalBlueprint elements; ! // // each OpalBlueprint element contains one or more Solid elements ! // // and zero or more Joint elements; an OpalBlueprint can contain ! // // zero or more Space elements containing Solid elements; note ! // // that in many case (e.g. offsets, materials) the default values ! // // will automatically be used if no elements are specified ! // ! // TiXmlDocument file; ! // if (false == file.LoadFile(filename.c_str())) ! // { ! // std::cout << "Error in opal::BlueprintManager::loadFile: \ ! // Failed to load XML file: " ! // << filename << std::endl; ! // return; ! // } ! // ! // TiXmlElement* rootElement = file.RootElement(); ! // if (NULL == rootElement) ! // { ! // std::cout << "Error in opal::BlueprintManager::loadFile: \ ! // Missing root element in XML file: " ! // << filename << std::endl; ! // return; ! // } ! // ! // // loop over blueprints ! // TiXmlNode* blueprintNodePtr = NULL; ! // while (blueprintNodePtr = rootElement->IterateChildren( ! // "OpalBlueprint", blueprintNodePtr)) ! // { ! // Blueprint* bp = new Blueprint(); ! // ! // bp->setName(getAttributeString(blueprintNodePtr, "name")); ! // ! // // loop over spaces; TODO: should we support hierarchical ! // // spaces in XML files? ! // TiXmlNode* spaceNodePtr = NULL; ! // while (spaceNodePtr = blueprintNodePtr->IterateChildren( ! // "Space", spaceNodePtr)) ! // { ! // SpaceDescription newSpace; ! // ! // // loop over solids within this space ! // TiXmlNode* solidNodePtr = NULL; ! // while (solidNodePtr = spaceNodePtr->IterateChildren( ! // "Solid", solidNodePtr)) ! // { ! // SolidData newSolid = loadSolid(solidNodePtr, ! // filename); ! // bp->addSolid(newSolid); ! // newSpace.solidNameList.push_back(newSolid.name); ! // } ! // ! // if (0 == newSpace.solidNameList.size()) ! // { ! // std::cout << "Warning in opal::BlueprintManager::\ ! // loadFile: Empty space will be ignored" ! // << " in " << filename << std::endl; ! // } ! // else ! // { ! // bp->addSpace(newSpace); ! // } ! // } ! // ! // // loop over solids (those not in spaces) ! // TiXmlNode* solidNodePtr = NULL; ! // while (solidNodePtr = blueprintNodePtr->IterateChildren( ! // "Solid", solidNodePtr)) ! // { ! // SolidData newSolid = loadSolid(solidNodePtr, ! // filename); ! // bp->addSolid(newSolid); ! // } ! // ! // // loop over joints ! // TiXmlNode* jointNodePtr = NULL; ! // while (jointNodePtr = blueprintNodePtr->IterateChildren( ! // "Joint", jointNodePtr)) ! // { ! // JointData newJoint = loadJoint(jointNodePtr, ! // filename); ! // bp->addJoint(newJoint); ! // } ! // ! // addBlueprint(bp); ! // } ! //#endif ! // } ! // ! // SolidData BlueprintManager::loadSolid(const TiXmlNode* nodePtr, ! // const std::string& filename) ! // { ! // SolidData sd; ! // ! //#ifdef OPAL_USE_XML ! // ! // sd.name = getAttributeString(nodePtr, "name"); ! // ! // // specify default parameters in case they aren't given in the file ! // sd.isStatic = defaults::staticSolids; ! // sd.linearDamping = defaults::linearDamping; ! // sd.angularDamping = defaults::angularDamping; ! // ! // // load Params elements ! // TiXmlNode* paramsNodePtr = ! // const_cast<TiXmlNode*>(nodePtr)->FirstChild("Params"); ! // if (NULL != paramsNodePtr) ! // { ! // // loop over Params ! // TiXmlNode* paramNodePtr = NULL; ! // ! // while (paramNodePtr = paramsNodePtr->IterateChildren("Param", ! // paramNodePtr)) ! // { ! // TiXmlAttribute* a = ! // paramNodePtr->ToElement()->FirstAttribute(); ! // std::string name = a->Name(); ! // std::string value = a->Value(); ! // ! // if (name == "static") ! // { ! // if (value == "true") ! // { ! // sd.isStatic = true; ! // } ! // // default static value is specified above ! // } ! // else if (name == "lineardamping") ! // { ! // sd.linearDamping = getAttributeReal(paramNodePtr, ! // "lineardamping"); ! // } ! // else if (name == "angulardamping") ! // { ! // sd.angularDamping = getAttributeReal(paramNodePtr, ! // "value"); ! // } ! // else ! // { ! // // this is a user-defined property ! // UserProperty prop; ! // prop.name = name; ! // prop.value = value; ! // sd.userProperties.push_back(prop); ! // } ! // } ! // } ! // ! // // load Offset element ! // TiXmlNode* offsetNodePtr = ! // const_cast<TiXmlNode*>(nodePtr)->FirstChild("Offset"); ! // if (NULL != offsetNodePtr) ! // { ! // sd.transform = loadOffset(offsetNodePtr, filename); ! // } ! // else ! // { ! // // offset will remain as an identity matrix ! // sd.transform.makeIdentity(); ! // } ! // ! // // loop over shapes ! // TiXmlNode* shapeNodePtr = NULL; ! // while (shapeNodePtr = const_cast<TiXmlNode*> ! // (nodePtr)->IterateChildren("Shape", shapeNodePtr)) ! // { ! // ShapeDescription shape = loadShape(shapeNodePtr, filename); ! // sd.shapeList.push_back(shape); ! // } ! // ! //#endif ! // ! // return sd; ! // } Matrix44r BlueprintManager::loadOffset(const TiXmlNode* nodePtr, *************** *** 337,470 **** } ! ShapeDescription BlueprintManager::loadShape(const TiXmlNode* nodePtr, ! const std::string& filename) ! { ! ShapeDescription shape; ! ! #ifdef OPAL_USE_XML ! ! std::string type = getAttributeString(nodePtr, "type"); ! ! // load dimensions; note that dimension attributes are different ! // for each shape type ! TiXmlNode* dimensionsNodePtr = const_cast<TiXmlNode*> ! (nodePtr)->FirstChild("Dimensions"); ! ! if ("box" == type) ! { ! shape.type = BOX_SHAPE; ! shape.dimensions[0] = getAttributeReal(dimensionsNodePtr, "x"); ! shape.dimensions[1] = getAttributeReal(dimensionsNodePtr, "y"); ! shape.dimensions[2] = getAttributeReal(dimensionsNodePtr, "z"); ! shape.dimensions[3] = 0; ! shape.dimensions[4] = 0; ! shape.dimensions[5] = 0; ! shape.dimensions[6] = 0; ! } ! else if ("sphere" == type) ! { ! shape.type = SPHERE_SHAPE; ! shape.dimensions[0] = getAttributeReal(dimensionsNodePtr, ! "radius"); ! shape.dimensions[1] = 0; ! shape.dimensions[2] = 0; ! shape.dimensions[3] = 0; ! shape.dimensions[4] = 0; ! shape.dimensions[5] = 0; ! shape.dimensions[6] = 0; ! } ! else if ("capsule" == type) ! { ! shape.type = CAPSULE_SHAPE; ! shape.dimensions[0] = getAttributeReal(dimensionsNodePtr, ! "radius"); ! shape.dimensions[1] = getAttributeReal(dimensionsNodePtr, ! "length"); ! shape.dimensions[2] = 0; ! shape.dimensions[3] = 0; ! shape.dimensions[4] = 0; ! shape.dimensions[5] = 0; ! shape.dimensions[6] = 0; ! } ! else if ("plane" == type) ! { ! shape.type = PLANE_SHAPE; ! //shape.dimensions[0] = ge... [truncated message content] |
|
From: tylerstreeter <tyl...@us...> - 2005-02-21 15:56:20
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13377/src Modified Files: Blueprint.h Defines.h Joint.cpp Joint.h Motor.cpp Motor.h Sensor.cpp Sensor.h Simulator.cpp Simulator.h Log Message: added userdata pointers to Joints, Motors, Sensors, and Simulators Index: Sensor.h =================================================================== RCS file: /cvsroot/opal/opal/src/Sensor.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Sensor.h 19 Feb 2005 20:54:36 -0000 1.5 --- Sensor.h 21 Feb 2005 15:54:39 -0000 1.6 *************** *** 52,55 **** --- 52,63 ---- virtual void OPAL_CALL setEnabled(bool e); + /// Set the user data pointer to some external data. The user data + /// is totally user-managed + /// (i.e. it is not destroyed when the Sensor is destroyed). + virtual void OPAL_CALL setUserData(void* data); + + /// Returns the user data pointer (NULL if it has not been set). + virtual void* OPAL_CALL getUserData(); + /// Called regularly to update the Sensor. This does nothing if the /// Sensor is disabled. *************** *** 63,66 **** --- 71,78 ---- bool mEnabled; + /// Pointer to user data. This is totally user-managed (i.e. OPAL + /// will never delete it). + void* mUserData; + /// True if the Sensor has been initialized. bool mInitCalled; Index: Sensor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Sensor.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Sensor.cpp 19 Feb 2005 20:54:36 -0000 1.2 --- Sensor.cpp 21 Feb 2005 15:54:38 -0000 1.3 *************** *** 34,37 **** --- 34,38 ---- mEnabled = false; mInitCalled = false; + setUserData(NULL); } *************** *** 55,58 **** --- 56,69 ---- } + void Sensor::setUserData(void* data) + { + mUserData = data; + } + + void* Sensor::getUserData() + { + return mUserData; + } + bool Sensor::internal_dependsOn(Solid* solid) { Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** Defines.h 19 Feb 2005 20:54:36 -0000 1.55 --- Defines.h 21 Feb 2005 15:54:35 -0000 1.56 *************** *** 119,131 **** }; - /// TODO: replace with SolidData struct - struct BodyState - { - Matrix44r transform; - Vec3r globalLinearVel; - Vec3r globalAngularVel; - }; - - /// Data structure describing material properties. These properties /// determine the collision response when two Solids collide. --- 119,122 ---- *************** *** 416,439 **** }; - /// TODO: replace with SolidData - struct SolidDescription - { - ~SolidDescription() - { - shapeList.clear(); - userProperties.clear(); - } - - // TODO: this needs an operator= - - std::string name; - Matrix44r transform; - bool isStatic; - real linearDamping; - real angularDamping; - std::vector<ShapeDescription> shapeList; - std::vector<UserProperty> userProperties; - }; - /// TODO: replace with SpaceData? struct SpaceDescription --- 407,410 ---- *************** *** 464,467 **** --- 435,466 ---- }; + /// TODO: replace with SolidData struct + struct BodyState + { + Matrix44r transform; + Vec3r globalLinearVel; + Vec3r globalAngularVel; + }; + + /// TODO: replace with SolidData + struct SolidDescription + { + ~SolidDescription() + { + shapeList.clear(); + userProperties.clear(); + } + + // TODO: this needs an operator= + + std::string name; + Matrix44r transform; + bool isStatic; + real linearDamping; + real angularDamping; + std::vector<ShapeDescription> shapeList; + std::vector<UserProperty> userProperties; + }; + /// TODO: expand this to include all Solid data struct SolidData Index: Joint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Joint.cpp 19 Feb 2005 20:54:36 -0000 1.17 --- Joint.cpp 21 Feb 2005 15:54:37 -0000 1.18 *************** *** 37,40 **** --- 37,41 ---- mSolid1 = NULL; mEventHandler = NULL; + setUserData(NULL); mInitCalled = false; mNumAxes = 0; *************** *** 283,286 **** --- 284,297 ---- } + void Joint::setUserData(void* data) + { + mUserData = data; + } + + void* Joint::getUserData() + { + return mUserData; + } + bool Joint::internal_dependsOn(Solid* solid) { Index: Joint.h =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.h,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** Joint.h 20 Feb 2005 06:28:34 -0000 1.51 --- Joint.h 21 Feb 2005 15:54:38 -0000 1.52 *************** *** 102,105 **** --- 102,106 ---- } + /// Copy constructor. JointData(const JointData& jd) { *************** *** 123,127 **** /// This is necessary because JointDatas contain an array. ! void operator= (const JointData& jd) { type = jd.type; --- 124,128 ---- /// This is necessary because JointDatas contain an array. ! void operator=(const JointData& jd) { type = jd.type; *************** *** 328,331 **** --- 329,340 ---- virtual bool OPAL_CALL isRotational(int axisNum); + /// Set the user data pointer to some external data. The user data + /// is totally user-managed + /// (i.e. it is not destroyed when the Joint is destroyed). + virtual void OPAL_CALL setUserData(void* data); + + /// Returns the user data pointer (NULL if it has not been set). + virtual void* OPAL_CALL getUserData(); + /// Various things could be updated here, including damage values. /// If the Joint breaks during this update, it will automatically *************** *** 380,383 **** --- 389,396 ---- EventHandler* mEventHandler; + /// Pointer to user data. This is totally user-managed (i.e. OPAL + /// will never delete it). + void* mUserData; + /// This is set to true when the Joint is initialized. bool mInitCalled; Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Simulator.cpp 19 Feb 2005 20:54:36 -0000 1.32 --- Simulator.cpp 21 Feb 2005 15:54:39 -0000 1.33 *************** *** 39,42 **** --- 39,43 ---- setMaxLinearVel(defaults::maxLinearVel); setMaxAngularVel(defaults::maxAngularVel); + setUserData(NULL); } *************** *** 452,455 **** --- 453,466 ---- //} + void Simulator::setUserData(void* data) + { + mUserData = data; + } + + void* Simulator::getUserData() + { + return mUserData; + } + void Simulator::destroySolid(Solid* s) { Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** Simulator.h 18 Feb 2005 23:59:37 -0000 1.71 --- Simulator.h 21 Feb 2005 15:54:40 -0000 1.72 *************** *** 140,143 **** --- 140,151 ---- virtual real OPAL_CALL getMaxAngularVel()const; + /// Set the user data pointer to some external data. The user data + /// is totally user-managed + /// (i.e. it is not destroyed when the Simulator is destroyed). + virtual void OPAL_CALL setUserData(void* data); + + /// Returns the user data pointer (NULL if it has not been set). + virtual void* OPAL_CALL getUserData(); + // SOLIDS *************** *** 263,266 **** --- 271,278 ---- AccuracyLevel mAccuracyLevel; + /// Pointer to user data. This is totally user-managed (i.e. OPAL + /// will never delete it). + void* mUserData; + //real mDefaultLinearDamping; //real mDefaultAngularDamping; Index: Blueprint.h =================================================================== RCS file: /cvsroot/opal/opal/src/Blueprint.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Blueprint.h 19 Feb 2005 20:54:36 -0000 1.18 --- Blueprint.h 21 Feb 2005 15:54:33 -0000 1.19 *************** *** 34,38 **** namespace opal { ! /// Blueprints are for storing a descriptions of groups of Solids, /// Joints, Motors, and/or Sensors. --- 34,38 ---- namespace opal { ! /// Blueprints are useful for saving and loading systems of Solids, /// Joints, Motors, and/or Sensors. Index: Motor.h =================================================================== RCS file: /cvsroot/opal/opal/src/Motor.h,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Motor.h 19 Feb 2005 20:54:36 -0000 1.32 --- Motor.h 21 Feb 2005 15:54:38 -0000 1.33 *************** *** 62,65 **** --- 62,73 ---- virtual void OPAL_CALL setEnabled(bool e); + /// Set the user data pointer to some external data. The user data + /// is totally user-managed + /// (i.e. it is not destroyed when the Motor is destroyed). + virtual void OPAL_CALL setUserData(void* data); + + /// Returns the user data pointer (NULL if it has not been set). + virtual void* OPAL_CALL getUserData(); + /// Called regularly to update the Motor. This does nothing if the /// Motor is disabled. *************** *** 86,89 **** --- 94,101 ---- bool mEnabled; + /// Pointer to user data. This is totally user-managed (i.e. OPAL + /// will never delete it). + void* mUserData; + /// True if this is a custom Motor. This is used to ensure that /// custom Motors are not destroyed by OPAL. Index: Motor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Motor.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Motor.cpp 19 Feb 2005 20:54:36 -0000 1.11 --- Motor.cpp 21 Feb 2005 15:54:38 -0000 1.12 *************** *** 35,38 **** --- 35,39 ---- mIsCustom = false; mInitCalled = false; + setUserData(NULL); } *************** *** 62,65 **** --- 63,76 ---- } + void Motor::setUserData(void* data) + { + mUserData = data; + } + + void* Motor::getUserData() + { + return mUserData; + } + bool Motor::internal_dependsOn(Solid* solid) { |