opal-commits Mailing List for Open Physics Abstraction Layer (Page 16)
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-04-12 06:47:23
|
Update of /cvsroot/opal/opal/samples/playpen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4177/samples/playpen Modified Files: main.cpp Log Message: added a rotational stability fix for ODESolids Index: main.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/playpen/main.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** main.cpp 6 Apr 2005 04:48:43 -0000 1.7 --- main.cpp 12 Apr 2005 06:46:42 -0000 1.8 *************** *** 200,203 **** --- 200,213 ---- } + if(mInputDevice->isKeyDown(KC_F)) + { + opal::Solid* s = getPhysicalEntity("object0")->getSolid(); + opal::Force f; + f.singleStep = true; + f.type = opal::GLOBAL_TORQUE; + f.vec.set(100, 0, 0); + s->addForce(f); + } + // Create various types of objects when the number keys are // pressed. |
|
From: tylerstreeter <tyl...@us...> - 2005-04-12 06:47:11
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4177/src/ODE Modified Files: ODESimulator.cpp ODESimulator.h ODESolid.cpp ODESolid.h Log Message: added a rotational stability fix for ODESolids Index: ODESimulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.h,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** ODESimulator.h 29 Mar 2005 03:05:47 -0000 1.69 --- ODESimulator.h 12 Apr 2005 06:46:44 -0000 1.70 *************** *** 90,95 **** virtual void OPAL_CALL setSolverAccuracy(SolverAccuracyLevel level); - virtual void OPAL_CALL internal_stepPhysics(); - virtual dWorldID OPAL_CALL internal_getWorldID()const; --- 90,93 ---- *************** *** 116,119 **** --- 114,119 ---- protected: + virtual void stepPhysics(); + /// The ODE world ID used by this Simulator. dWorldID mWorldID; Index: ODESolid.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.h,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** ODESolid.h 6 Apr 2005 04:48:45 -0000 1.68 --- ODESolid.h 12 Apr 2005 06:46:45 -0000 1.69 *************** *** 143,146 **** --- 143,156 ---- const std::vector<GeomData*>* OPAL_CALL internal_getGeomDataList()const; + /// Fix angular velocities for freely-spinning bodies that have + /// gained angular velocity through explicit integrator inaccuracy. + /// This usually only happens for long, thin objects. + void OPAL_CALL internal_doAngularVelFix(); + + /// Sets whether this object is freely-spinning (i.e. no recent + /// physical contacts, no user-generated forces, no user-defined + /// velocity changes). + void OPAL_CALL internal_setFreelySpinning(bool fs); + protected: /// Adds a new GeomData object to the internal list and sets up the *************** *** 158,161 **** --- 168,174 ---- void addMass(dMass& newMass, const Matrix44r& offset); + /// Returns true if the given mass has a non-symmetric inertia tensor. + bool isInertiaNonSymmetric(const dMass& mass)const; + /// The ODE body ID. dBodyID mBodyID; *************** *** 178,181 **** --- 191,205 ---- bool mIsPlaceable; + /// True if the ODESolid has a non-symmetric inertia tensor. + bool mNonSymmetricInertia; + + /// Used to improve ODE's angular velocity calculations for objects + /// with non-symmetric inertia tensors. + bool mIsFreelySpinning; + + /// Used to improve ODE's angular velocity calculations for objects + /// with non-symmetric inertia tensors. + real mPrevAngVelMagSquared; + private: }; Index: ODESimulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.cpp,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** ODESimulator.cpp 9 Apr 2005 06:23:58 -0000 1.97 --- ODESimulator.cpp 12 Apr 2005 06:46:44 -0000 1.98 *************** *** 126,130 **** } ! void ODESimulator::internal_stepPhysics() { // Apply linear and angular damping; if using the "add opposing --- 126,130 ---- } ! void ODESimulator::stepPhysics() { // Apply linear and angular damping; if using the "add opposing *************** *** 253,257 **** } ! //Do collision detection; add contacts to contact joint group dSpaceCollide(mRootSpaceID, this, &ode_hidden::internal_collisionCallback); --- 253,257 ---- } ! // Do collision detection; add contacts to the contact joint group. dSpaceCollide(mRootSpaceID, this, &ode_hidden::internal_collisionCallback); *************** *** 267,272 **** } ! //Remove all joints from the contact group. dJointGroupEmpty(mContactJointGroupID); } --- 267,283 ---- } ! // Remove all joints from the contact group. dJointGroupEmpty(mContactJointGroupID); + + // Fix angular velocities for freely-spinning bodies that have + // gained angular velocity through explicit integrator inaccuracy. + for (iter = mSolidList.begin(); iter != mSolidList.end(); ++iter) + { + ODESolid* s = (ODESolid*)(*iter); + if (!s->isSleeping() && !s->isStatic()) + { + s->internal_doAngularVelFix(); + } + } } *************** *** 510,513 **** --- 521,528 ---- if (makeContacts) { + // Invalidate the "freely-spinning" parameters. + ((ODESolid*)solid0)->internal_setFreelySpinning(false); + ((ODESolid*)solid1)->internal_setFreelySpinning(false); + for(int i=0; i<numContacts; ++i) { Index: ODESolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v retrieving revision 1.83 retrieving revision 1.84 diff -C2 -d -r1.83 -r1.84 *** ODESolid.cpp 10 Apr 2005 23:09:19 -0000 1.83 --- ODESolid.cpp 12 Apr 2005 06:46:44 -0000 1.84 *************** *** 43,46 **** --- 43,49 ---- mIsPlaceable = true; mCollisionCount = 0; + mNonSymmetricInertia = false; + mIsFreelySpinning = true; + mPrevAngVelMagSquared = 0; if (!mData.isStatic) *************** *** 480,483 **** --- 483,489 ---- dMassTranslate(&m, offset[0], offset[1], offset[2]); dBodySetMass(mBodyID, &m); + + // Update this since the mass changed. + mNonSymmetricInertia = isInertiaNonSymmetric(m); } } *************** *** 650,653 **** --- 656,662 ---- dBodyVectorToWorld(mBodyID, vel[0], vel[1], vel[2], worldVel); dBodySetLinearVel(mBodyID, worldVel[0], worldVel[1], worldVel[2]); + + // Invalidate the "freely-spinning" parameter. + internal_setFreelySpinning(false); } } *************** *** 698,701 **** --- 707,713 ---- degToRad(worldVel[2])); dBodySetAngularVel(mBodyID, velRad[0], velRad[1], velRad[2]); + + // Invalidate the "freely-spinning" parameter. + internal_setFreelySpinning(false); } } *************** *** 724,727 **** --- 736,742 ---- { dBodySetLinearVel(mBodyID, vel[0], vel[1], vel[2]); + + // Invalidate the "freely-spinning" parameter. + internal_setFreelySpinning(false); } } *************** *** 761,764 **** --- 776,782 ---- Vec3r velRad(degToRad(vel[0]), degToRad(vel[1]), degToRad(vel[2])); dBodySetAngularVel(mBodyID, velRad[0], velRad[1], velRad[2]); + + // Invalidate the "freely-spinning" parameter. + internal_setFreelySpinning(false); } } *************** *** 972,975 **** --- 990,996 ---- break; } + + // Invalidate the "freely-spinning" parameter. + internal_setFreelySpinning(false); } *************** *** 1005,1008 **** --- 1026,1034 ---- dBodySetMass(mBodyID, &totalMass); } + + // Update this since the mass changed. + dMass m; + dBodyGetMass(mBodyID, &m); + mNonSymmetricInertia = isInertiaNonSymmetric(m); } *************** *** 1011,1013 **** --- 1037,1090 ---- return &mGeomDataList; } + + void ODESolid::internal_doAngularVelFix() + { + if (mNonSymmetricInertia) + { + Vec3r vel = getGlobalAngularVel(); + real currentAngVelMagSquared = vel.lengthSquared(); + + if (mIsFreelySpinning) + { + // If the current angular velocity magnitude is greater than + // that of the previous step, scale it by that of the previous + // step; otherwise, update the previous value to that of the + // current step. This ensures that angular velocity never + // increases for freely-spinning objects. + + if (currentAngVelMagSquared > mPrevAngVelMagSquared) + { + real currentAngVelMag = sqrt(currentAngVelMagSquared); + vel = vel / currentAngVelMag; + // Vel is now a unit vector. Next, scale this vector + // by the previous angular velocity magnitude. + real prevAngVelMag = sqrt(mPrevAngVelMagSquared); + setGlobalAngularVel(vel * prevAngVelMag); + } + } + + mPrevAngVelMagSquared = currentAngVelMagSquared; + } + + // Reset the "freely-spinning" parameter for the next time step. + internal_setFreelySpinning(true); + } + + void ODESolid::internal_setFreelySpinning(bool fs) + { + mIsFreelySpinning = fs; + } + + bool ODESolid::isInertiaNonSymmetric(const dMass& mass)const + { + if (opal::abs(mass.I[0] - mass.I[5]) > globals::OPAL_EPSILON + || opal::abs(mass.I[5] - mass.I[10]) > globals::OPAL_EPSILON) + { + return true; + } + else + { + return false; + } + } } |
|
From: tylerstreeter <tyl...@us...> - 2005-04-12 06:46:54
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4177/src Modified Files: Defines.h Matrix44r.h OpalMath.h Point3r.h Quaternion.h Rayr.h Simulator.cpp Simulator.h Solid.h SpringMotor.cpp Vec3r.h Log Message: added a rotational stability fix for ODESolids Index: Vec3r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Vec3r.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Vec3r.h 30 Mar 2005 23:26:23 -0000 1.14 --- Vec3r.h 12 Apr 2005 06:46:44 -0000 1.15 *************** *** 62,65 **** --- 62,68 ---- inline bool areCollinear(const Vec3r& u, const Vec3r& v); + /// Basic printing helper function. + inline std::ostream& operator<<(std::ostream& o, const Vec3r& v); + class Vec3r { *************** *** 122,125 **** --- 125,129 ---- inline real & operator[](unsigned int i) { + assert(i < 3); return mData[i]; } *************** *** 127,130 **** --- 131,135 ---- inline const real & operator[](unsigned int i)const { + assert(i < 3); return mData[i]; } *************** *** 296,300 **** { real value = 1 - dot(u, v); ! if (fabs(value) < globals::OPAL_EPSILON) { return true; --- 301,305 ---- { real value = 1 - dot(u, v); ! if (opal::abs(value) < globals::OPAL_EPSILON) { return true; *************** *** 305,308 **** --- 310,318 ---- } } + + inline std::ostream& operator<<(std::ostream& o, const Vec3r& v) + { + return o << "[" << v[0] << " " << v[1] << " " << v[2] << "]"; + } } Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** Simulator.cpp 9 Apr 2005 06:23:58 -0000 1.58 --- Simulator.cpp 12 Apr 2005 06:46:43 -0000 1.59 *************** *** 49,54 **** mTimeBuffer = 0; setStepSize(defaults::stepSize); ! setMaxLinearVel(defaults::maxLinearVel); ! setMaxAngularVel(defaults::maxAngularVel); setUserData(NULL); setPostStepEventHandler(NULL); --- 49,54 ---- mTimeBuffer = 0; setStepSize(defaults::stepSize); ! //setMaxLinearVel(defaults::maxLinearVel); ! //setMaxAngularVel(defaults::maxAngularVel); setUserData(NULL); setPostStepEventHandler(NULL); *************** *** 121,179 **** solidIter != mSolidList.end(); ++solidIter) { ! Solid* solid = *solidIter; ! ! solid->internal_applyForces(mStepSize); ! ! // Limit velocities and forces of moving Solids to ! // limit numerical inaccuracy from explicit integration ! // (mostly from quickly-spinning long, thin objects). ! if (!solid->isSleeping() && !solid->isStatic()) ! { ! bool velChanged = false; ! Vec3r linearVel = solid->getGlobalLinearVel(); ! if (linearVel[0] > mMaxLinearVel) ! { ! linearVel[0] = mMaxLinearVel; ! velChanged = true; ! } ! if (linearVel[1] > mMaxLinearVel) ! { ! linearVel[1] = mMaxLinearVel; ! velChanged = true; ! } ! if (linearVel[2] > mMaxLinearVel) ! { ! linearVel[2] = mMaxLinearVel; ! velChanged = true; ! } ! if (velChanged) ! { ! solid->setGlobalLinearVel(linearVel); ! solid->zeroForces(); ! } ! ! velChanged = false; ! Vec3r angularVel = solid->getGlobalAngularVel(); ! if (angularVel[0] > mMaxAngularVel) ! { ! angularVel[0] = mMaxAngularVel; ! velChanged = true; ! } ! if (angularVel[1] > mMaxAngularVel) ! { ! angularVel[1] = mMaxAngularVel; ! velChanged = true; ! } ! if (angularVel[2] > mMaxAngularVel) ! { ! angularVel[2] = mMaxAngularVel; ! velChanged = true; ! } ! if (velChanged) ! { ! solid->setGlobalAngularVel(angularVel); ! solid->zeroForces(); ! } ! } } --- 121,125 ---- solidIter != mSolidList.end(); ++solidIter) { ! (*solidIter)->internal_applyForces(mStepSize); } *************** *** 193,197 **** // Now do physics engine-specific stuff; collision events will // be sent from here. ! internal_stepPhysics(); // Loop over Solids again to handle a few more things... --- 139,143 ---- // Now do physics engine-specific stuff; collision events will // be sent from here. ! stepPhysics(); // Loop over Solids again to handle a few more things... *************** *** 278,286 **** bool useScale = false; ! Matrix44r scaleMat; if (1 != scale) { useScale = true; ! scaleMat.makeScale(scale); } --- 224,232 ---- bool useScale = false; ! //Matrix44r scaleMat; if (1 != scale) { useScale = true; ! //scaleMat.makeScale(scale); } *************** *** 596,620 **** } ! void Simulator::setMaxLinearVel(real max) ! { ! assert(max >= 0.0); ! mMaxLinearVel = max; ! } ! real Simulator::getMaxLinearVel()const ! { ! return mMaxLinearVel; ! } ! void Simulator::setMaxAngularVel(real max) ! { ! assert(max >= 0.0); ! mMaxAngularVel = max; ! } ! real Simulator::getMaxAngularVel()const ! { ! return mMaxAngularVel; ! } //void Simulator::setDefaultLinearDamping(real ld) --- 542,566 ---- } ! //void Simulator::setMaxLinearVel(real max) ! //{ ! // assert(max >= 0.0); ! // mMaxLinearVel = max; ! //} ! //real Simulator::getMaxLinearVel()const ! //{ ! // return mMaxLinearVel; ! //} ! //void Simulator::setMaxAngularVel(real max) ! //{ ! // assert(max >= 0.0); ! // mMaxAngularVel = max; ! //} ! //real Simulator::getMaxAngularVel()const ! //{ ! // return mMaxAngularVel; ! //} //void Simulator::setDefaultLinearDamping(real ld) Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** Simulator.h 9 Apr 2005 06:23:58 -0000 1.96 --- Simulator.h 12 Apr 2005 06:46:43 -0000 1.97 *************** *** 133,149 **** /// Sets the maximum linear velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! virtual void OPAL_CALL setMaxLinearVel(real max); /// Returns the maximum linear velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! virtual real OPAL_CALL getMaxLinearVel()const; /// Sets the maximum angular velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! virtual void OPAL_CALL setMaxAngularVel(real max); /// Returns the maximum angular velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! virtual real OPAL_CALL getMaxAngularVel()const; /// Set the user data pointer to some external data. The user data --- 133,149 ---- /// Sets the maximum linear velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! //virtual void OPAL_CALL setMaxLinearVel(real max); /// Returns the maximum linear velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! //virtual real OPAL_CALL getMaxLinearVel()const; /// Sets the maximum angular velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! //virtual void OPAL_CALL setMaxAngularVel(real max); /// Returns the maximum angular velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! //virtual real OPAL_CALL getMaxAngularVel()const; /// Set the user data pointer to some external data. The user data *************** *** 278,286 **** virtual Space* OPAL_CALL createSpace() = 0; - /// This function is physics engine-specific. It handles collision - /// detection and steps the simulation ahead by a constant step - /// size. - virtual void OPAL_CALL internal_stepPhysics() = 0; - /// Helper function used for ray casting. Immediately fires a ray /// into the scene and returns intersections results. Uses the --- 278,281 ---- *************** *** 300,303 **** --- 295,303 ---- virtual ~Simulator(); + /// This function is physics engine-specific. It handles collision + /// detection and steps the simulation ahead by a constant step + /// size. + virtual void stepPhysics() = 0; + /// Adds a Solid to the internal list of Solids. void addSolid(Solid* s); *************** *** 350,358 **** /// A limit on Solid motion to protect against simulation explosions /// due to numerical inaccuracy. ! real mMaxLinearVel; /// A limit on Solid motion to protect against simulation explosions /// due to numerical inaccuracy. ! real mMaxAngularVel; /// An internal list of all Solids. --- 350,358 ---- /// A limit on Solid motion to protect against simulation explosions /// due to numerical inaccuracy. ! //real mMaxLinearVel; /// A limit on Solid motion to protect against simulation explosions /// due to numerical inaccuracy. ! //real mMaxAngularVel; /// An internal list of all Solids. Index: OpalMath.h =================================================================== RCS file: /cvsroot/opal/opal/src/OpalMath.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** OpalMath.h 29 Mar 2005 03:05:46 -0000 1.9 --- OpalMath.h 12 Apr 2005 06:46:43 -0000 1.10 *************** *** 54,57 **** --- 54,62 ---- return (r2d * rad); } + + inline real abs(real value) + { + return fabs(value); + } } Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** Defines.h 9 Apr 2005 06:23:58 -0000 1.73 --- Defines.h 12 Apr 2005 06:46:43 -0000 1.74 *************** *** 281,286 **** //const bool allowPartialFrames=true; //const int maxStepsPerFrame=10; ! const real maxLinearVel = (real)10000.0; ! const real maxAngularVel = (real)1000.0; const bool staticSleepingContactsEnabled = false; --- 281,286 ---- //const bool allowPartialFrames=true; //const int maxStepsPerFrame=10; ! //const real maxLinearVel = (real)10000.0; ! //const real maxAngularVel = (real)1000.0; const bool staticSleepingContactsEnabled = false; *************** *** 308,313 **** const real capsuleLength = 1; const real planeABCD[4] = {0, 1, 0, 0}; - //const Point3r rayOrigin = Point3r(0, 0, 0); - //const Vec3r rayDir = Vec3r(0, 0, -1); } --- 308,311 ---- Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** Solid.h 6 Apr 2005 04:48:44 -0000 1.87 --- Solid.h 12 Apr 2005 06:46:44 -0000 1.88 *************** *** 247,250 **** --- 247,251 ---- void* mUserData; + /// Data used for private: }; Index: Quaternion.h =================================================================== RCS file: /cvsroot/opal/opal/src/Quaternion.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Quaternion.h 7 Feb 2005 02:08:22 -0000 1.7 --- Quaternion.h 12 Apr 2005 06:46:43 -0000 1.8 *************** *** 38,41 **** --- 38,42 ---- inline Quaternion operator*(const Quaternion& q, real scalar); inline Quaternion operator*(real scalar, const Quaternion& q); + inline std::ostream& operator<<(std::ostream& o, const Point3r& p); class Quaternion *************** *** 139,142 **** --- 140,144 ---- inline real & operator[](unsigned int i) { + assert(i < 4); return mData[i]; } *************** *** 144,147 **** --- 146,150 ---- inline const real & operator[](unsigned int i)const { + assert(i < 4); return mData[i]; } *************** *** 171,174 **** --- 174,183 ---- scalar * q[3]); } + + inline std::ostream& operator<<(std::ostream& o, const Quaternion& q) + { + return o << "[" << q[0] << " " << q[1] << " " << q[2] << " " + << q[3] << "]"; + } } Index: SpringMotor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/SpringMotor.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SpringMotor.cpp 4 Apr 2005 13:09:12 -0000 1.13 --- SpringMotor.cpp 12 Apr 2005 06:46:44 -0000 1.14 *************** *** 197,202 **** // Convert the global point to a local point offset from the Solid's // transform. ! Matrix44r inv; ! fastInverse(inv, mData.solid->getTransform()); mData.attachOffset = inv * p; } --- 197,202 ---- // Convert the global point to a local point offset from the Solid's // transform. ! Matrix44r inv = mData.solid->getTransform(); ! inv.fastInvert(); mData.attachOffset = inv * p; } Index: Point3r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Point3r.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Point3r.h 7 Feb 2005 02:08:22 -0000 1.11 --- Point3r.h 12 Apr 2005 06:46:43 -0000 1.12 *************** *** 94,97 **** --- 94,98 ---- inline real & operator[](unsigned int i) { + assert(i < 3); return mData[i]; } *************** *** 99,102 **** --- 100,104 ---- inline const real & operator[](unsigned int i)const { + assert(i < 3); return mData[i]; } *************** *** 183,186 **** --- 185,193 ---- return p * -1; } + + inline std::ostream& operator<<(std::ostream& o, const Point3r& p) + { + return o << "[" << p[0] << " " << p[1] << " " << p[2] << "]"; + } } Index: Rayr.h =================================================================== RCS file: /cvsroot/opal/opal/src/Rayr.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Rayr.h 22 Feb 2005 04:28:11 -0000 1.6 --- Rayr.h 12 Apr 2005 06:46:43 -0000 1.7 *************** *** 33,36 **** --- 33,39 ---- namespace opal { + class Rayr; + inline std::ostream& operator<<(std::ostream& o, const Rayr& r); + class Rayr { *************** *** 101,104 **** --- 104,116 ---- } }; + + inline std::ostream& operator<<(std::ostream& o, const Rayr& r) + { + Point3r origin = r.getOrigin(); + Vec3r dir = r.getDir(); + return o << "Origin: [" << origin[0] << " " << origin[1] << " " + << origin[2] << "] Direction: [" << dir[0] << " " << dir[1] + << " " << dir[2] << "]"; + } } Index: Matrix44r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Matrix44r.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Matrix44r.h 29 Mar 2005 03:05:46 -0000 1.30 --- Matrix44r.h 12 Apr 2005 06:46:43 -0000 1.31 *************** *** 48,51 **** --- 48,52 ---- inline bool inverse(Matrix44r & dest, const Matrix44r & src); inline void fastInverse(Matrix44r & dest, const Matrix44r & src); + inline std::ostream& operator<<(std::ostream& o, const Matrix44r& m); class Matrix44r *************** *** 514,518 **** fastInverse for affine transforms" << std::endl; real det = src.determinant(); ! if(abs(det < globals::OPAL_EPSILON)) return false; dest = ((real)1.0 / det) * src; return true; --- 515,519 ---- fastInverse for affine transforms" << std::endl; real det = src.determinant(); ! if(opal::abs(det < globals::OPAL_EPSILON)) return false; dest = ((real)1.0 / det) * src; return true; *************** *** 542,549 **** result(2, 2)).lengthSquared(); ! // TODO: write opal::abs. ! if(fabs(l0) > globals::OPAL_EPSILON) l0 = 1.0f / l0; ! if(fabs(l1) > globals::OPAL_EPSILON) l1 = 1.0f / l1; ! if(fabs(l2) > globals::OPAL_EPSILON) l2 = 1.0f / l2; // apply the inverse scale to the 3x3 --- 543,549 ---- result(2, 2)).lengthSquared(); ! if(opal::abs(l0) > globals::OPAL_EPSILON) l0 = 1.0f / l0; ! if(opal::abs(l1) > globals::OPAL_EPSILON) l1 = 1.0f / l1; ! if(opal::abs(l2) > globals::OPAL_EPSILON) l2 = 1.0f / l2; // apply the inverse scale to the 3x3 *************** *** 570,574 **** // invert scale. ! const real tw = (fabs(src(3, 3)) > globals::OPAL_EPSILON) ? 1.0f / src(3, 3) : 0.0f; --- 570,574 ---- // invert scale. ! const real tw = (opal::abs(src(3, 3)) > globals::OPAL_EPSILON) ? 1.0f / src(3, 3) : 0.0f; *************** *** 653,656 **** --- 653,669 ---- return ray; } + + inline std::ostream& operator<<(std::ostream& o, const Matrix44r& m) + { + return o + << "[" << m[0] << " " << m[1] << " " << m[2] << " " << m[3] + << "]" << std::endl + << "[" << m[4] << " " << m[5] << " " << m[6] << " " << m[7] + << "]" << std::endl + << "[" << m[8] << " " << m[9] << " " << m[10] << " " << m[11] + << "]" << std::endl + << "[" << m[12] << " " << m[13] << " " << m[14] << " " << m[15] + << "]"; + } } |
|
From: tylerstreeter <tyl...@us...> - 2005-04-10 23:09:47
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24043/src Modified Files: Solid.cpp Log Message: minor fix to sleep parameter set function Index: Solid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.cpp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Solid.cpp 3 Apr 2005 00:11:44 -0000 1.32 --- Solid.cpp 10 Apr 2005 23:09:21 -0000 1.33 *************** *** 188,191 **** --- 188,192 ---- } + // If there are Forces to apply and the Solid is asleep, wake it up. if(!mForceList.empty() && isSleeping()) { |
|
From: tylerstreeter <tyl...@us...> - 2005-04-10 23:09:47
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24043/src/ODE Modified Files: ODESolid.cpp Log Message: minor fix to sleep parameter set function Index: ODESolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v retrieving revision 1.82 retrieving revision 1.83 diff -C2 -d -r1.82 -r1.83 *** ODESolid.cpp 6 Apr 2005 04:48:45 -0000 1.82 --- ODESolid.cpp 10 Apr 2005 23:09:19 -0000 1.83 *************** *** 393,400 **** --- 393,402 ---- if (sleeping) { + mData.sleeping = true; dBodyDisable(mBodyID); } else { + mData.sleeping = false; dBodyEnable(mBodyID); } *************** *** 408,411 **** --- 410,415 ---- } + // The ODE body may fall asleep at unknown times, so we need to + // get the data straight from ODE. if (dBodyIsEnabled(mBodyID)) { |
|
From: tylerstreeter <tyl...@us...> - 2005-04-09 06:24:08
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31248/src Modified Files: CollisionEventHandler.cpp CollisionEventHandler.h Defines.h EventHandler.h Simulator.cpp Simulator.h Log Message: made changes to collision detection "early out" cases to make things faster Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** Defines.h 6 Apr 2005 04:48:44 -0000 1.72 --- Defines.h 9 Apr 2005 06:23:58 -0000 1.73 *************** *** 283,286 **** --- 283,287 ---- const real maxLinearVel = (real)10000.0; const real maxAngularVel = (real)1000.0; + const bool staticSleepingContactsEnabled = false; /// All groups make contacts with all other groups by default. Index: CollisionEventHandler.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/CollisionEventHandler.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CollisionEventHandler.cpp 8 Mar 2005 16:10:23 -0000 1.1 --- CollisionEventHandler.cpp 9 Apr 2005 06:23:58 -0000 1.2 *************** *** 47,55 **** void CollisionEventHandler::internal_handlePendingCollisionEvents() { ! std::vector<CollisionEvent>::iterator iter; ! for (iter = mPendingCollisionEvents.begin(); ! iter != mPendingCollisionEvents.end(); ++iter) { ! handleCollisionEvent(*iter); } } --- 47,54 ---- void CollisionEventHandler::internal_handlePendingCollisionEvents() { ! while (!mPendingCollisionEvents.empty()) { ! handleCollisionEvent(mPendingCollisionEvents.back()); ! mPendingCollisionEvents.pop_back(); } } Index: EventHandler.h =================================================================== RCS file: /cvsroot/opal/opal/src/EventHandler.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** EventHandler.h 8 Mar 2005 16:10:23 -0000 1.21 --- EventHandler.h 9 Apr 2005 06:23:58 -0000 1.22 *************** *** 34,38 **** { /// Base class for various other event handling classes. EventHandlers ! /// are listeners that respond to particular events. class EventHandler { --- 34,39 ---- { /// Base class for various other event handling classes. EventHandlers ! /// are listeners that respond to particular events. It is perfectly ! /// safe to destroy objects when events are handled. class EventHandler { Index: CollisionEventHandler.h =================================================================== RCS file: /cvsroot/opal/opal/src/CollisionEventHandler.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CollisionEventHandler.h 8 Apr 2005 20:46:00 -0000 1.3 --- CollisionEventHandler.h 9 Apr 2005 06:23:58 -0000 1.4 *************** *** 80,84 **** /// Called once for each pending CollisionEvent. This is always ! /// called at the end of a time step, so CollisionEvents always /// get handled right away. OPAL_DECL virtual void OPAL_CALL handleCollisionEvent( --- 80,84 ---- /// Called once for each pending CollisionEvent. This is always ! /// called at the end of every time step so CollisionEvents /// get handled right away. OPAL_DECL virtual void OPAL_CALL handleCollisionEvent( Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** Simulator.cpp 8 Apr 2005 20:46:00 -0000 1.57 --- Simulator.cpp 9 Apr 2005 06:23:58 -0000 1.58 *************** *** 55,58 **** --- 55,60 ---- mIsSolidDestructionSafe = true; mIsJointDestructionSafe = true; + mStaticSleepingContactsEnabled = + defaults::staticSleepingContactsEnabled; int i=0; *************** *** 724,727 **** --- 726,739 ---- } + void Simulator::setStaticSleepingContactsEnabled(bool enable) + { + mStaticSleepingContactsEnabled = enable; + } + + bool Simulator::areStaticSleepingContactsEnabled() + { + return mStaticSleepingContactsEnabled; + } + unsigned long int Simulator::internal_getContactGroupFlags( unsigned int groupNum)const Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** Simulator.h 8 Apr 2005 20:46:00 -0000 1.95 --- Simulator.h 9 Apr 2005 06:23:58 -0000 1.96 *************** *** 67,75 **** virtual void OPAL_CALL destroy() = 0; ! /// This function takes the amount of time to simulate and advances ! /// the simulation ahead by that much. Internally, it steps through /// the simulation iteratively using a fixed step size. "Leftover" /// time will be saved until the next time this is called. The ! /// function returns true if at least one time step has been taken. virtual bool OPAL_CALL simulate(real dt); --- 67,94 ---- virtual void OPAL_CALL destroy() = 0; ! /// This function performs collision detection and simulates ! /// everything ahead by the given dt. Internally, it steps through /// the simulation iteratively using a fixed step size. "Leftover" /// time will be saved until the next time this is called. The ! /// function returns true if at least one time step has been taken. ! /// During collision detection, the following cases are ignored ! /// when deciding whether to collide two Solids (both for physical ! /// contact generation and collision event handling): ! /// 1. Two static Solids, each without a CollisionEventHandler. ! /// 2. Two Shapes that are part of the same Solid. ! /// 3. Two sleeping Solids. ! /// 4. Two Solids connected by a fixed Joint. ! /// 5. Two Solids connected by a Joint with contacts disabled. ! /// 6. Solid0 is static, Solid1 is sleeping, ! /// static-to-sleeping contacts are ignored by the ! /// Simulator, and neither Solid has a ! /// CollisionEventHandler. ! /// 7. Solid1 is static, Solid0 is sleeping, ! /// static-to-sleeping contacts are ignored by the ! /// Simulator, and neither Solid has a ! /// CollisionEventHandler. ! /// 8. The two Solids' contact groups do not generate ! /// contacts when they collide, and neither Solid has a ! /// CollisionEventHandler. virtual bool OPAL_CALL simulate(real dt); *************** *** 139,147 **** /// last argument is true, the two groups will generate physical /// points when they collide. Otherwise, they will pass through ! /// each other. Keep in mind that the following cases are already ! /// ignored when performing collision detection: two sleeping ! /// Solids don't collide; two Solids connected by a fixed Joint ! /// don't collide; two Solids connected by a Joint with its ! /// contacts enabled property set to false don't collide. /// Note that contact groups do not affect collision events; two /// colliding objects might not generate contacts and still --- 158,164 ---- /// last argument is true, the two groups will generate physical /// points when they collide. Otherwise, they will pass through ! /// each other. Keep in mind that certain cases are already ! /// ignored when performing collision detection; see comments ! /// on Simulator::simulate for more details. /// Note that contact groups do not affect collision events; two /// colliding objects might not generate contacts and still *************** *** 163,166 **** --- 180,193 ---- unsigned int group1); + /// Sets whether contacts should be generated between static Solids + /// and sleeping Solids. Usually this isn't necessary, but + /// sometimes you might want a static Solid to wake up a sleeping + /// dynamic Solid by touching it. + virtual void OPAL_CALL setStaticSleepingContactsEnabled(bool enable); + + /// Returns true if contacts are generated between static Solids + /// and sleeping Solids. + virtual bool OPAL_CALL areStaticSleepingContactsEnabled(); + // SOLIDS *************** *** 363,366 **** --- 390,397 ---- unsigned long int mContactGroupFlags[32]; + /// True if contacts are generated between static Solids and + /// sleeping Solids. + bool mStaticSleepingContactsEnabled; + /// Pointer to the Simulator's post-step event handler. PostStepEventHandler* mPostStepEventHandler; |
|
From: tylerstreeter <tyl...@us...> - 2005-04-09 06:24:07
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31248/src/ODE Modified Files: ODESimulator.cpp Log Message: made changes to collision detection "early out" cases to make things faster Index: ODESimulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.cpp,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** ODESimulator.cpp 6 Apr 2005 04:48:44 -0000 1.96 --- ODESimulator.cpp 9 Apr 2005 06:23:58 -0000 1.97 *************** *** 299,325 **** // The following is a set of special cases where we might ! // not want to do collision detection (but not all are // enforced here for various reasons): ! // 1. Two static Solids (neither geom has a body): this is ! // not enforced because sometimes you might want two ! // static Solids to generate collision events. // 2. Two Shapes that are part of the same Solid (they // share a body): this is not enforced because ODE // already takes care of it. // 3. Two sleeping Solids (note: both must have bodies to ! // check this): this is enforced. ODE should handle ! // this, but it doesn't. // 4. Two Solids connected by a fixed Joint: this is // enforced. // 5. Two Solids connected by a Joint (besides ODE ! // contact joints, which never generate ! // contacts) with contacts disabled; (note: both must have // bodies to check this): this is enforced. ! // 6. Solid0 is static and Solid1 is sleeping: not enforced ! // because sometimes you might want to wake up a sleeping ! // Solid with a static Solid. ! // 7. Solid1 is static and Solid0 is sleeping: not enforced ! // because sometimes you might want to wake up a sleeping ! // Solid with a static Solid. // 8. The two Solids' contact groups do not generate // contacts when they collide AND neither Solid has a --- 299,327 ---- // The following is a set of special cases where we might ! // want to skip collision detection (but not all are // enforced here for various reasons): ! // 1. Two static Solids (neither geom has a body) AND ! // neither Solid has a CollisionEventHandler: this is ! // enforced. // 2. Two Shapes that are part of the same Solid (they // share a body): this is not enforced because ODE // already takes care of it. // 3. Two sleeping Solids (note: both must have bodies to ! // check this): this is enforced. (ODE should handle ! // this, but it doesn't.) // 4. Two Solids connected by a fixed Joint: this is // enforced. // 5. Two Solids connected by a Joint (besides ODE ! // contact joints, which should never generate more ! // contacts) with contacts disabled (note: both must have // bodies to check this): this is enforced. ! // 6. Solid0 is static, Solid1 is sleeping, ! // static-to-sleeping contacts are ignored by the ! // Simulator, and neither Solid has a ! // CollisionEventHandler: this is enforced. ! // 7. Solid1 is static, Solid0 is sleeping, ! // static-to-sleeping contacts are ignored by the ! // Simulator, and neither Solid has a ! // CollisionEventHandler: this is enforced. // 8. The two Solids' contact groups do not generate // contacts when they collide AND neither Solid has a *************** *** 329,332 **** --- 331,336 ---- dBodyID o0BodyID = dGeomGetBody(o0); dBodyID o1BodyID = dGeomGetBody(o1); + bool solid0Static = (0 == o0BodyID); + bool solid1Static = (0 == o1BodyID); // Check if both Solids are dynamic (i.e. have ODE bodies). *************** *** 364,367 **** --- 368,376 ---- shape0->contactGroup, shape1->contactGroup); + // Find out whether the Simulator has static-to-sleeping + // contacts disabled. + bool ignoreStaticSleepingContacts = + !sim->areStaticSleepingContactsEnabled(); + // Get pointers to the geoms' Solids. Solid* solid0 = geomData0->solid; *************** *** 376,390 **** solid1->getCollisionEventHandler(); ! if (//(0 == o0BodyID && 0 == o1BodyID) //case 1 //|| (o0BodyID == o1BodyID) //case 2 ! (bothHaveBodies && !dBodyIsEnabled(o0BodyID) && ! !dBodyIsEnabled(o1BodyID)) //case 3 || (commonJoint && commonJoint->getType() == FIXED_JOINT) // case 4 ! || (commonJoint && ! !commonJoint->areContactsEnabled()) // case 5 ! //|| (0 == o0BodyID && !dBodyIsEnabled(o1BodyID)) //case 6 ! //|| (0 == o1BodyID && !dBodyIsEnabled(o0BodyID)) //case 7 ! || (!makeContacts && !(handler0 || handler1)) ) { --- 385,408 ---- solid1->getCollisionEventHandler(); ! bool neitherHasEventHandler = !(handler0 || handler1); ! ! // It is important here that we don't check if a static body ! // is disabled (sleeping) because that crashes ODE. ! if ((neitherHasEventHandler ! && solid0Static && solid1Static) //case 1 //|| (o0BodyID == o1BodyID) //case 2 ! || (bothHaveBodies && !dBodyIsEnabled(o0BodyID) ! && !dBodyIsEnabled(o1BodyID)) //case 3 || (commonJoint && commonJoint->getType() == FIXED_JOINT) // case 4 ! || (commonJoint ! && !commonJoint->areContactsEnabled()) // case 5 ! || (solid0Static && !dBodyIsEnabled(o1BodyID) ! && ignoreStaticSleepingContacts ! && neitherHasEventHandler) //case 6 ! || (solid1Static && !dBodyIsEnabled(o0BodyID) ! && ignoreStaticSleepingContacts ! && neitherHasEventHandler) //case 7 ! || (!makeContacts && neitherHasEventHandler) // case 8 ) { *************** *** 433,437 **** if (handler0) { ! handler0->handleCollisionEvent(e); } --- 451,455 ---- if (handler0) { ! handler0->internal_pushCollisionEvent(e); } *************** *** 443,447 **** e.thisSolid = solid1; e.otherSolid = solid0; ! handler1->handleCollisionEvent(e); } } --- 461,465 ---- e.thisSolid = solid1; e.otherSolid = solid0; ! handler1->internal_pushCollisionEvent(e); } } |
|
From: tylerstreeter <tyl...@us...> - 2005-04-08 20:46:10
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23067 Modified Files: todo.txt Log Message: added a fix to make solid and joint destruction (even more) safe during event handling Index: todo.txt =================================================================== RCS file: /cvsroot/opal/opal/todo.txt,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** todo.txt 6 Apr 2005 04:48:45 -0000 1.70 --- todo.txt 8 Apr 2005 20:46:01 -0000 1.71 *************** *** 105,108 **** --- 105,110 ---- ============== + * interpolate position/orientation of solids using leftover dt + * given that the physics engine is known at compile time, just set the opal::real to the physics engine's real value (e.g. ODE's dReal) |
|
From: tylerstreeter <tyl...@us...> - 2005-04-08 20:46:10
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23067/src Modified Files: CollisionEventHandler.h Simulator.cpp Simulator.h Log Message: added a fix to make solid and joint destruction (even more) safe during event handling Index: CollisionEventHandler.h =================================================================== RCS file: /cvsroot/opal/opal/src/CollisionEventHandler.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CollisionEventHandler.h 21 Mar 2005 05:52:09 -0000 1.2 --- CollisionEventHandler.h 8 Apr 2005 20:46:00 -0000 1.3 *************** *** 68,72 **** }; ! /// A listener that gets notified when two Solids touch. class CollisionEventHandler : public EventHandler { --- 68,75 ---- }; ! /// A listener that gets notified when two Solids touch. These events ! /// get handled at the end of the time step, which is necessary because ! /// some physics engines cannot update objects in the middle of a time ! /// step (e.g. in the middle of collision detection). class CollisionEventHandler : public EventHandler { Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.56 retrieving revision 1.57 diff -C2 -d -r1.56 -r1.57 *** Simulator.cpp 6 Apr 2005 04:48:44 -0000 1.56 --- Simulator.cpp 8 Apr 2005 20:46:00 -0000 1.57 *************** *** 53,56 **** --- 53,58 ---- setUserData(NULL); setPostStepEventHandler(NULL); + mIsSolidDestructionSafe = true; + mIsJointDestructionSafe = true; int i=0; *************** *** 73,76 **** --- 75,81 ---- mSpaceList.pop_back(); } + + mSolidGarbageList.clear(); + mJointGarbageList.clear(); } *************** *** 172,175 **** --- 177,181 ---- // Update Joints. + mIsJointDestructionSafe = false; std::vector<Joint*>::iterator jointIter; for (jointIter = mJointList.begin(); *************** *** 181,184 **** --- 187,191 ---- (*jointIter)->internal_update(); } + mIsJointDestructionSafe = true; // Now do physics engine-specific stuff; collision events will *************** *** 187,190 **** --- 194,198 ---- // Loop over Solids again to handle a few more things... + mIsSolidDestructionSafe = false; for (solidIter = mSolidList.begin(); solidIter != mSolidList.end(); ++solidIter) *************** *** 206,209 **** --- 214,218 ---- } } + mIsSolidDestructionSafe = true; // Fire an event to the PostStepEventHandler, if one exists. *************** *** 213,216 **** --- 222,228 ---- } + // Destroy garbage now that it's safe. + destroyGarbage(); + //Decrement the time buffer mTimeBuffer -= mStepSize; *************** *** 751,755 **** void Simulator::destroySolid(Solid* s) { ! removeSolid(s); } --- 763,774 ---- void Simulator::destroySolid(Solid* s) { ! if (mIsSolidDestructionSafe) ! { ! removeSolid(s); ! } ! else ! { ! mSolidGarbageList.push_back(s); ! } } *************** *** 764,768 **** void Simulator::destroyJoint(Joint* j) { ! removeJoint(j); } --- 783,794 ---- void Simulator::destroyJoint(Joint* j) { ! if (mIsJointDestructionSafe) ! { ! removeJoint(j); ! } ! else ! { ! mJointGarbageList.push_back(j); ! } } *************** *** 1018,1020 **** --- 1044,1063 ---- mSpaceList.push_back(s); } + + void Simulator::destroyGarbage() + { + // Destroy garbage Solids. + while (!mSolidGarbageList.empty()) + { + destroySolid(mSolidGarbageList.back()); + mSolidGarbageList.pop_back(); + } + + // Destroy garbage Joints. + while (!mJointGarbageList.empty()) + { + destroyJoint(mJointGarbageList.back()); + mJointGarbageList.pop_back(); + } + } } Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** Simulator.h 6 Apr 2005 04:48:44 -0000 1.94 --- Simulator.h 8 Apr 2005 20:46:00 -0000 1.95 *************** *** 300,303 **** --- 300,307 ---- void addSpace(Space* s); + /// Destroys all objects marked as garbage. Useful for destroying + /// objects at safe times. + void destroyGarbage(); + /// The constant step size used to break arbitrary simulation dt /// values into constant chunks. *************** *** 337,340 **** --- 341,358 ---- std::vector<Sensor*> mSensorList; + /// True when it is safe to destroy a Solid (e.g. not in the middle + /// of looping over all the Solid). + bool mIsSolidDestructionSafe; + + /// True when it is safe to destroy a Joint (e.g. not in the middle + /// of looping over all the Joint). + bool mIsJointDestructionSafe; + + /// An internal list of Solids marked as garbage. + std::vector<Solid*> mSolidGarbageList; + + /// An internal list of Joints marked as garbage. + std::vector<Joint*> mJointGarbageList; + /// Spaces are stored here so the user doesn't have to destroy them; /// they get destroyed when the Simulator is destroyed. |
|
From: tylerstreeter <tyl...@us...> - 2005-04-08 20:46:09
|
Update of /cvsroot/opal/opal/samples/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23067/samples/src Modified Files: OgreLine.h Log Message: added a fix to make solid and joint destruction (even more) safe during event handling Index: OgreLine.h =================================================================== RCS file: /cvsroot/opal/opal/samples/src/OgreLine.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OgreLine.h 6 Apr 2005 04:48:44 -0000 1.1 --- OgreLine.h 8 Apr 2005 20:46:00 -0000 1.2 *************** *** 163,169 **** vMin = mBox.getMinimum(); vMax = mBox.getMaximum(); ! vMid = ((vMin - vMax) * 0.5) + vMin; vDist = cam->getDerivedPosition() - vMid; - return vDist.squaredLength(); } --- 163,169 ---- vMin = mBox.getMinimum(); vMax = mBox.getMaximum(); ! //vMid = ((vMin - vMax) * 0.5) + vMin; // original ! vMid = ((vMax - vMin) * 0.5) + vMin; // fixed vDist = cam->getDerivedPosition() - vMid; return vDist.squaredLength(); } *************** *** 258,264 **** HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton().createVertexBuffer( ! mRenderOp.vertexData->vertexDeclaration->getVertexSize(0), ! mVertexBufferCapacity, ! HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY); // Bind buffer --- 258,264 ---- HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton().createVertexBuffer( ! mRenderOp.vertexData->vertexDeclaration->getVertexSize(0), ! mVertexBufferCapacity, ! HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY); // Bind buffer *************** *** 306,312 **** mRenderOp.indexData->indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( ! HardwareIndexBuffer::IT_16BIT, ! mIndexBufferCapacity, ! HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY); } --- 306,312 ---- mRenderOp.indexData->indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( ! HardwareIndexBuffer::IT_16BIT, ! mIndexBufferCapacity, ! HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY); } *************** *** 339,343 **** HardwareVertexBufferSharedPtr vbuf = ! mRenderOp.vertexData->vertexBufferBinding->getBuffer(0); Real *prPos = static_cast<Real*>(vbuf->lock( --- 339,343 ---- HardwareVertexBufferSharedPtr vbuf = ! mRenderOp.vertexData->vertexBufferBinding->getBuffer(0); Real *prPos = static_cast<Real*>(vbuf->lock( *************** *** 351,366 **** if(mPoints[i].x < vaabMin.x) ! vaabMin.x = mPoints[i].x; if(mPoints[i].y < vaabMin.y) ! vaabMin.y = mPoints[i].y; if(mPoints[i].z < vaabMin.z) ! vaabMin.z = mPoints[i].z; if(mPoints[i].x > vaabMax.x) ! vaabMax.x = mPoints[i].x; if(mPoints[i].y > vaabMax.y) ! vaabMax.y = mPoints[i].y; if(mPoints[i].z > vaabMax.z) ! vaabMax.z = mPoints[i].z; } } --- 351,366 ---- if(mPoints[i].x < vaabMin.x) ! vaabMin.x = mPoints[i].x; if(mPoints[i].y < vaabMin.y) ! vaabMin.y = mPoints[i].y; if(mPoints[i].z < vaabMin.z) ! vaabMin.z = mPoints[i].z; if(mPoints[i].x > vaabMax.x) ! vaabMax.x = mPoints[i].x; if(mPoints[i].y > vaabMax.y) ! vaabMax.y = mPoints[i].y; if(mPoints[i].z > vaabMax.z) ! vaabMax.z = mPoints[i].z; } } |
|
From: tylerstreeter <tyl...@us...> - 2005-04-08 15:49:45
|
Update of /cvsroot/opal/opal/tools/3dsmax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24172/tools/3dsmax Added Files: opalExporter.ms readme.txt Log Message: added 3dsmax exporter --- NEW FILE: opalExporter.ms --- global D_TRUE = 1 global D_FALSE = 0 global D_BOX_ID = #(16,0) global D_SPHERE_ID = #(17,0) --global D_CYLINDER_ID = #(18,0) global D_CAPSULE_ID = #(1832744876, 2043230633) -- Path for output files. global savePath -- Global handle for the output file. global outFile -- Checks if the scene is in the proper format for exporting. function checkScene = ( -- is something selected? if selection.count == 0 then ( displayTempPrompt "Opal Error: nothing is selected!" 5000 return D_FALSE ) -- if saving is canceled return false savePath = getSaveFileName caption:"Export Solid To..." filename:"untitled" types:"Opal Blueprint(*.xml)|*.xml|All|*.*" if savePath == undefined then return D_FALSE return D_TRUE ) -- Prints an offset element for Solid. function printSolidOffset trans angle axis = ( format "\t\t<Offset>\n" to:outFile format "\t\t\t<Transform type=\"translate\" x=\"%\" y=\"%\" z=\"%\"/>\n" trans.x trans.y trans.z to:outFile -- Only save the rotation if it's significant. if abs(angle) > 0.001 then ( format "\t\t\t<Transform type=\"rotate\" angle=\"%\" x=\"%\" y=\"%\" z=\"%\"/>\n" angle axis.x axis.y axis.z to:outFile ) format "\t\t</Offset>\n" to:outFile ) -- Prints an offset element for Shapes. function printShapeOffset trans angle axis = ( format "\t\t\t<Offset>\n" to:outFile format "\t\t\t\t<Transform type=\"translate\" x=\"%\" y=\"%\" z=\"%\"/>\n" trans.x trans.y trans.z to:outFile -- Only save the rotation if it's significant. if abs(angle) > 0.001 then ( format "\t\t\t\t<Transform type=\"rotate\" angle=\"%\" x=\"%\" y=\"%\" z=\"%\"/>\n" angle axis.x axis.y axis.z to:outFile ) format "\t\t\t</Offset>\n" to:outFile ) -- Prints a Shape element for the given object. function printShape object printOffset = ( if object.classID[1] == D_SPHERE_ID[1] then ( format "\t\t<Shape type=\"sphere\">\n" to:outFile format "\t\t\t<Dimensions radius=\"%\"/>\n" (abs(object.scale[1] * object.radius)) to:outFile ) else if object.classID[1] == D_CAPSULE_ID[1] then ( format "\t\t<Shape type=\"capsule\">\n" to:outFile format "\t\t\t<Dimensions radius=\"%\" length=\"%\"/>\n" (abs(object.scale[1] * object.radius)) (abs(object.scale[1] * object.height)) to:outFile ) -- Default to boxes for everything else. else ( -- We need to find the extents of the object's locally-aligned bounding box. -- The MAXScript bounding box extents are wrong for the local coordsys, -- so we'll just move the object to the global origin, gets its extents, -- and then move it back. -- First, store the object's original transform. originalTransform = object.transform -- Set its transform to the identity. object.transform = Matrix3(1) -- Calculate the bounding box's extents. dimensions = object.max - object.min -- Restore the object's original transform. object.transform = originalTransform format "\t\t<Shape type=\"box\">\n" to:outFile format "\t\t\t<Dimensions x=\"%\" y=\"%\" z=\"%\"/>\n" dimensions.x dimensions.y dimensions.z to:outFile ) -- If requested, print the Shape's offset from its parent. if (true == printOffset) then ( in coordsys parent offsetTranslation = object.center in coordsys parent offsetRotation = object.rotation printShapeOffset offsetTranslation offsetRotation.angle offsetRotation.axis ) format "\t\t</Shape>\n" to:outFile ) -- Check if the scene is valid. readyToGo = checkScene() if(readyToGo == D_TRUE) then ( -- Create the output file. outFile = createfile savePath -- Add the XML version and initial Blueprint tags. format "<?xml version=\"1.0\"?>\n" to:outFile format "<OpalBlueprint>\n" to:outFile -- Handle Solids. --i = 0 for object in selection do ( -- Only print a Solid element for group heads and non-group members. if isGroupHead object or false == isGroupMember object then ( format "\t<Solid>\n" to:outFile -- Use the object name for the Solid name. format "\t\t<Name value=\"%\"/>\n" object.name to:outFile -- If the group has the "static" user property defined, add an element for it. -- Otherwise, the Solid will just use the default OPAL setting. isStatic = getUserProp object "static" if isStatic != undefined then ( if "true" == isStatic then ( format "\t\t<Static value=\"true\"/>\n" to:outFile ) else if "false" == isStatic then ( format "\t\t<Static value=\"false\"/>\n" to:outFile ) else ( displayTempPrompt "Opal Warning: invalid value for \"static\" user property" 2000 ) ) -- Handle group objects. if isGroupHead object then ( -- Create a Shape for each group member. -- Loop over the group members. for member in object do ( -- The group head "is" the Solid; use its transform as the Solid's transform. if true == isGroupHead member then ( in coordsys world worldTranslation = member.center in coordsys world worldRotation = member.rotation printSolidOffset worldTranslation worldRotation.angle worldRotation.axis ) -- Create a Shape for each group member. Their transforms represent offsets from -- the group head. else ( printShape member true ) ) ) -- Handle "normal" (non-group) objects. Just create a single Shape. else if false == isGroupMember object then ( -- Print the Solid's transform. in coordsys world worldTranslation = object.center in coordsys world worldRotation = object.rotation printSolidOffset worldTranslation worldRotation.angle worldRotation.axis -- Print the Shape with no offset from its Solid. printShape object false ) format "\t</Solid>\n" to:outFile ) ) -- Add the closing Blueprint tag. format "</OpalBlueprint>\n" to:outFile -- Close the output file. close outFile displayTempPrompt "Finished exporting OPAL Blueprint" 10000 ) --- NEW FILE: readme.txt --- OPAL 3ds max Exporter --------------------- This exporter for 3ds max generates an OPAL XML file. It is currently limited to a subset of the possible OPAL XML elements. The current feature list includes: * Single-Shape Solids - Ungrouped objects in 3dsmax * Multi-Shape Solids - Grouped objects are automatically added to a single Solid * Shapes - Box (3dsmax "box" primitive) - Sphere (3dsmax "sphere" primitive) - Capsule (3dsmax "capsule" primitive) - All other object types are exported as boxes, using the objects' locally-aligned bounding boxes * Static/dynamic - Solids' static/dynamic property defaults to OPAL's default setting - To explicitly set a Solid as static or dynamic, set a "static" user-defined property for the object/group (right-click on the object/group, go to "Properties", then "User Defined"). For example, static=true or static=false. Note: All objects' local transforms refer to the center of their bounding boxes. For Solids with a single Shape, this refers to the Shape's bounding box center. For grouped objects (multi-Shape Solids), this refers to the group's bounding box center. Planned Features ---------------- * Joints - Joint type - anchor point - axes |
|
From: tylerstreeter <tyl...@us...> - 2005-04-08 15:43:04
|
Update of /cvsroot/opal/opal/tools/3dsmax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20786/3dsmax Log Message: Directory /cvsroot/opal/opal/tools/3dsmax added to the repository |
|
From: tylerstreeter <tyl...@us...> - 2005-04-06 04:49:24
|
Update of /cvsroot/opal/opal/samples/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1764/samples/src Modified Files: BaseOpalApp.h PhysicalCamera.h TemplateApp.cpp Added Files: OgreLine.h Log Message: minor changes; added stuff to sample app Index: PhysicalCamera.h =================================================================== RCS file: /cvsroot/opal/opal/samples/src/PhysicalCamera.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PhysicalCamera.h 5 Apr 2005 05:18:53 -0000 1.3 --- PhysicalCamera.h 6 Apr 2005 04:48:44 -0000 1.4 *************** *** 114,117 **** --- 114,126 ---- mGraspedObject->setSleeping(false); + //// Set the Motor's global desired orientaiton for the Solid. + //Ogre::Vector3 camForward = mOgreCamera->getDirection(); + //Ogre::Vector3 camUp = mOgreCamera->getUp(); + //Ogre::Vector3 camRight = mOgreCamera->getRight(); + //opal::Vec3r f(camForward[0], camForward[1], camForward[2]); + //opal::Vec3r u(camUp[0], camUp[1], camUp[2]); + //opal::Vec3r r(camRight[0], camRight[1], camRight[2]); + //mGraspingMotor->setDesiredOrientation(f, u, r); + // Set the Motor's global desired position for the Solid // (at its attach position). *************** *** 133,136 **** --- 142,151 ---- } + /// Returns a pointer to the Ogre Camera's parent SceneNode. + Ogre::SceneNode* getOgreSceneNode()const + { + return mOgreCamera->getParentSceneNode(); + } + /// Sets the position of the camera in global coordinates. This /// refers to the camera's eye position. *************** *** 281,286 **** --- 296,304 ---- data.solid = result.solid; data.mode = opal::LINEAR_MODE; + //data.mode = opal::LINEAR_AND_ANGULAR_MODE; data.linearKd = 3; data.linearKs = 50; + //data.angularKd = 0.3; + //data.angularKs = 5; // Desired position/orientation will be updated in the // "update" function. Index: TemplateApp.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/src/TemplateApp.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TemplateApp.cpp 4 Apr 2005 13:09:10 -0000 1.5 --- TemplateApp.cpp 6 Apr 2005 04:48:44 -0000 1.6 *************** *** 31,35 **** } ! ~MyApp::MyApp() { } --- 31,35 ---- } ! MyApp::~MyApp() { } *************** *** 58,63 **** // Setup the initial camera position. ! mPhysicalCamera->setPosition(Ogre::Vector3(0, 30, 50)); ! mPhysicalCamera->lookAt(0, 0, 0); // Load models, create physical objects, etc. here. --- 58,63 ---- // Setup the initial camera position. ! mPhysicalCamera->setPosition(opal::Point3r(0, 30, 50)); ! mPhysicalCamera->lookAt(opal::Point3r(0, 0, 0)); // Load models, create physical objects, etc. here. *************** *** 66,70 **** bool MyApp::appFrameStarted(opal::real dt) { ! // Do per-frame application specific things here. // Return true to continue looping. --- 66,70 ---- bool MyApp::appFrameStarted(opal::real dt) { ! // Do per-frame application-specific things here. // Return true to continue looping. Index: BaseOpalApp.h =================================================================== RCS file: /cvsroot/opal/opal/samples/src/BaseOpalApp.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** BaseOpalApp.h 5 Apr 2005 05:18:53 -0000 1.6 --- BaseOpalApp.h 6 Apr 2005 04:48:44 -0000 1.7 *************** *** 22,26 **** mPhysicalCamera = NULL; mPaused = false; - mNamelessObjectCount = 0; } --- 22,25 ---- *************** *** 102,110 **** /// Creates and returns a pointer to a PhysicalEntity. Takes ! /// the name of the new PhysicalEntity, the Ogre Entity, and a ! /// pointer to an OPAL Solid. The name must be unique; unique ! /// names will be automatically generated for empty name strings. PhysicalEntity* createPhysicalEntity(const std::string& name, ! Ogre::Entity* e, opal::Solid* s) { if (!s) --- 101,110 ---- /// Creates and returns a pointer to a PhysicalEntity. Takes ! /// the name of the new PhysicalEntity, the associated Ogre ! /// SceneNode, and a pointer to an OPAL Solid. If the name string ! /// is empty, a unique name will be automatically generated; ! /// otherwise, the given name must be unique. PhysicalEntity* createPhysicalEntity(const std::string& name, ! Ogre::SceneNode* sn, opal::Solid* s) { if (!s) *************** *** 116,133 **** if (nameStr.empty()) { ! // Make a unique name. ! char newName[20]; ! sprintf(newName, "object%d", mNamelessObjectCount); ! mNamelessObjectCount++; ! nameStr = newName; } - // Create an Ogre SceneNode. - Ogre::SceneNode* sn = mSceneMgr->getRootSceneNode()-> - createChildSceneNode(nameStr); - - // Attach the Entity to the SceneNode. - sn->attachObject(e); - // Create a new Physical Entity. PhysicalEntity* pe = new PhysicalEntity(nameStr, sn, s); --- 116,122 ---- if (nameStr.empty()) { ! nameStr = generateUniqueName(); } // Create a new Physical Entity. PhysicalEntity* pe = new PhysicalEntity(nameStr, sn, s); *************** *** 148,154 **** /// Creates a PhysicalEntity drawn as a box. The OPAL Solid can /// be any shape, however. This is useful for prototyping scenes ! /// when you don't have a specific visual mesh to use. The name ! /// must be unique; unique names will be automatically generated ! /// for empty name strings. PhysicalEntity* createPhysicalEntityBox(const std::string& name, const std::string& materialName, Ogre::Vector3 dimensions, --- 137,143 ---- /// Creates a PhysicalEntity drawn as a box. The OPAL Solid can /// be any shape, however. This is useful for prototyping scenes ! /// when you don't have a specific visual mesh to use. If the name ! /// string is empty, a unique name will be automatically generated; ! /// otherwise, the given name must be unique. PhysicalEntity* createPhysicalEntityBox(const std::string& name, const std::string& materialName, Ogre::Vector3 dimensions, *************** *** 160,178 **** if (nameStr.empty()) { ! // Make a unique name. ! char newName[20]; ! sprintf(newName, "object%d", mNamelessObjectCount); ! mNamelessObjectCount++; ! nameStr = newName; } ! // This mesh must be stored as a box with dimensions 1x1x1. Entity* e = mSceneMgr->createEntity(nameStr, "cube.mesh"); e->setMaterialName(materialName); - pe = createPhysicalEntity(nameStr, e, s); ! // Scale the mesh according to the given dimensions. ! e->getParentSceneNode()->scale(dimensions[0], dimensions[1], ! dimensions[2]); return pe; --- 149,172 ---- if (nameStr.empty()) { ! nameStr = generateUniqueName(); } ! // Create an Ogre SceneNode for the Entity. ! Ogre::SceneNode* sn = mSceneMgr->getRootSceneNode()-> ! createChildSceneNode(nameStr); ! ! // Scale the object according to the given dimensions. ! sn->scale(dimensions[0], dimensions[1], ! dimensions[2]); ! ! // Create an Ogre Entity using a cube mesh. This mesh must be ! // stored as a box with dimensions 1x1x1. Entity* e = mSceneMgr->createEntity(nameStr, "cube.mesh"); e->setMaterialName(materialName); ! // Attach the Entity to the SceneNode. ! sn->attachObject(e); ! ! pe = createPhysicalEntity(nameStr, sn, s); return pe; *************** *** 181,187 **** /// Creates a PhysicalEntity drawn as a sphere. The OPAL Solid can /// be any shape, however. This is useful for prototyping scenes ! /// when you don't have a specific visual mesh to use. The name ! /// must be unique; unique names will be automatically generated ! /// for empty name strings. PhysicalEntity* createPhysicalEntitySphere(const std::string& name, const std::string& materialName, Ogre::Real radius, --- 175,181 ---- /// Creates a PhysicalEntity drawn as a sphere. The OPAL Solid can /// be any shape, however. This is useful for prototyping scenes ! /// when you don't have a specific visual mesh to use. If the name ! /// string is empty, a unique name will be automatically generated; ! /// otherwise, the given name must be unique. PhysicalEntity* createPhysicalEntitySphere(const std::string& name, const std::string& materialName, Ogre::Real radius, *************** *** 193,210 **** if (nameStr.empty()) { ! // Make a unique name. ! char newName[20]; ! sprintf(newName, "object%d", mNamelessObjectCount); ! mNamelessObjectCount++; ! nameStr = newName; } ! // This mesh must be stored as a sphere with radius 1. Entity* e = mSceneMgr->createEntity(nameStr, "sphere.mesh"); e->setMaterialName(materialName); - pe = createPhysicalEntity(nameStr, e, s); ! // Scale the mesh according to the given dimensions. ! e->getParentSceneNode()->scale(radius, radius, radius); return pe; --- 187,274 ---- if (nameStr.empty()) { ! nameStr = generateUniqueName(); } ! // Create an Ogre SceneNode for the Entity. ! Ogre::SceneNode* sn = mSceneMgr->getRootSceneNode()-> ! createChildSceneNode(nameStr); ! ! // Scale the object according to the given dimensions. ! sn->scale(radius, radius, radius); ! ! // Create an Ogre Entity using a sphere mesh. This mesh must be ! // stored as a sphere with radius 1. Entity* e = mSceneMgr->createEntity(nameStr, "sphere.mesh"); e->setMaterialName(materialName); ! // Attach the Entity to the SceneNode. ! sn->attachObject(e); ! ! pe = createPhysicalEntity(nameStr, sn, s); ! ! return pe; ! } ! ! /// Creates a PhysicalEntity drawn as a capsule. The OPAL Solid can ! /// be any shape, however. This is useful for prototyping scenes ! /// when you don't have a specific visual mesh to use. If the name ! /// string is empty, a unique name will be automatically generated; ! /// otherwise, the given name must be unique. ! PhysicalEntity* createPhysicalEntityCapsule(const std::string& name, ! const std::string& materialName, Ogre::Real radius, ! Ogre::Real length, opal::Solid* s) ! { ! PhysicalEntity* pe = NULL; ! ! std::string nameStr = name; ! if (nameStr.empty()) ! { ! nameStr = generateUniqueName(); ! } ! ! // Create Ogre Entities using cylinder and sphere meshes. ! ! // Create an Ogre SceneNode for the cylinder Entity. ! std::string subObjectName = "cylinder" + nameStr; ! Ogre::SceneNode* cylinderNode = mSceneMgr->getRootSceneNode()-> ! createChildSceneNode(subObjectName); ! ! // Scale the object according to the given dimensions. This ! // will also scale the transforms for the child nodes, but ! // we disable the "inherit scale" option for child nodes ! // here so the shapes themselves don't get scaled. ! cylinderNode->scale(radius, radius, length); ! ! // This mesh must be stored as a cylinder with length 1 and ! // radius 1. ! Entity* e = mSceneMgr->createEntity(subObjectName, ! "cylinder.mesh"); ! e->setMaterialName(materialName); ! cylinderNode->attachObject(e); ! ! // The spheres must use separate scene nodes that are offset ! // from the cylinder's scene node. ! ! // This mesh must be stored as a sphere with radius 1. ! subObjectName = "sphere0" + nameStr; ! Ogre::SceneNode* sn = ! cylinderNode->createChildSceneNode(subObjectName); ! sn->setInheritScale(false); ! sn->translate(0, 0, -0.5); ! sn->scale(radius, radius, radius); ! e = mSceneMgr->createEntity(subObjectName, "sphere.mesh"); ! e->setMaterialName(materialName); ! sn->attachObject(e); ! ! subObjectName = "sphere1" + nameStr; ! sn = cylinderNode->createChildSceneNode(subObjectName); ! sn->setInheritScale(false); ! sn->translate(0, 0, 0.5); ! sn->scale(radius, radius, radius); ! e = mSceneMgr->createEntity(subObjectName, "sphere.mesh"); ! e->setMaterialName(materialName); ! sn->attachObject(e); ! ! pe = createPhysicalEntity(nameStr, cylinderNode, s); return pe; *************** *** 259,263 **** // in this case, there should only be a single entity // (which is why we can safely call 'removeEntity' ! // here). while(sn->numAttachedObjects() > 0) { --- 323,330 ---- // in this case, there should only be a single entity // (which is why we can safely call 'removeEntity' ! // here). TODO: We should also check child nodes and ! // destroy their Entities here; this isn't a huge ! // issue since Ogre will destroy all the Entities ! // when the app exits. while(sn->numAttachedObjects() > 0) { *************** *** 339,342 **** --- 406,424 ---- virtual bool processUnbufferedMouseInput(Ogre::Real dt) = 0; + /// Returns a unique name string. Useful when creating lots of + /// anonymous objects. + std::string generateUniqueName() + { + static unsigned int namelessObjectCount = 0; + + // Make a unique name. + char newName[20]; + sprintf(newName, "object%d", namelessObjectCount); + std::string nameStr = newName; + ++namelessObjectCount; + + return nameStr; + } + /// Pointer to the OPAL Simulator. opal::Simulator* mSimulator; *************** *** 348,354 **** bool mPaused; - /// A counter used to generate unique object names. - unsigned int mNamelessObjectCount; - /// Map of named PhysicalEntities. This is just used to find a /// PhysicalEntity by name. --- 430,433 ---- --- NEW FILE: OgreLine.h --- #ifndef OPAL_SAMPLES_OGRE_LINE_H #define OPAL_SAMPLES_OGRE_LINE_H /// Adapted from the Dynamic Growing Buffers and the Dynamic Line Drawing /// examples on the Ogre3d wiki site (April 3, 2005). Special thanks to /// DWORD and baxissimo! /// http://grotsnik.ogre3d.org/wiki/index.php/DynamicGrowingBuffers /// http://grotsnik.ogre3d.org/wiki/index.php/DynamicLineDrawing // Here's an example of how to use it. // In initialization somewhere, create the initial lines object: // // OgreLine* line = new OgreLine(RenderOperation::OT_LINE_STRIP); // // Assume 'somePoints' is a collection of Ogre::Vector3s. // for (int i=0; i<somePoints.size(); i++) // { // line->addPoint(somePoints[i]); // } // line->update(); // SceneNode* lineNode = // mScene->getRootSceneNode()->createChildSceneNode("myLine"); // lineNode->attachObject(line); // // Then later on when you want to update the lines: // // SceneNode* lnode = dynamic_cast<SceneNode*>( // mScene->getRootSceneNode()->getChild("myLine")); // OgreLine* line = // dynamic_cast<OgreLine*>(lnode->getAttachedObject(0)); // // if (line->getNumPoints() != myPoints.size()) // { // // The number of points changed. Just recreate the list from // // scratch. // line->clear(); // for (int i=0; i<myPoints.size(); ++i) // { // line->addPoint(myPoints[i]); // } // } // else // { // // Just values have changed, use 'setPoint' instead of 'addPoint'. // for (int i=0; i<myPoints.size(); ++i) // { // line->setPoint(i, myPoints[i]); // } // } // line->update(); #include <Ogre/OgreSimpleRenderable.h> #include <Ogre/OgreHardwareBufferManager.h> #include <vector> namespace opalSamples { enum { POSITION_BINDING, TEXCOORD_BINDING }; class OgreLine : public Ogre::SimpleRenderable { public: /// Constructor - see setOperationType() for description of argument. OgreLine(Ogre::RenderOperation::OperationType opType=Ogre::RenderOperation::OT_LINE_STRIP) { initialize(opType,false); setMaterial("BaseWhiteNoLighting"); mDirty = true; } virtual ~OgreLine() { delete mRenderOp.vertexData; delete mRenderOp.indexData; } /// Add a point to the point list void addPoint(const Ogre::Vector3 &p) { mPoints.push_back(p); mDirty = true; } /// Add a point to the point list void addPoint(Real x, Real y, Real z) { mPoints.push_back(Ogre::Vector3(x,y,z)); mDirty = true; } /// Change the location of an existing point in the point list void setPoint(unsigned short index, const Ogre::Vector3 &value) { assert(index < mPoints.size() && "Point index is out of bounds!!"); mPoints[index] = value; mDirty = true; } /// Return the location of an existing point in the point list const Ogre::Vector3& getPoint(unsigned short index) const { assert(index < mPoints.size() && "Point index is out of bounds!!"); return mPoints[index]; } /// Return the total number of points in the point list unsigned short getNumPoints(void) const { return (unsigned short)mPoints.size(); } /// Remove all points from the point list void clear() { mPoints.clear(); mDirty = true; } /// Call this to update the hardware buffer after making changes. void update() { if (mDirty) { fillHardwareBuffers(); } } /** Set the type of operation to draw with. * @param opType Can be one of * - RenderOperation::OT_LINE_STRIP * - RenderOperation::OT_LINE_LIST * - RenderOperation::OT_POINT_LIST * - RenderOperation::OT_TRIANGLE_LIST * - RenderOperation::OT_TRIANGLE_STRIP * - RenderOperation::OT_TRIANGLE_FAN * The default is OT_LINE_STRIP. */ void setOperationType(Ogre::RenderOperation::OperationType opType) { mRenderOp.operationType = opType; } Ogre::RenderOperation::OperationType getOperationType()const { return mRenderOp.operationType; } /// Implementation of Ogre::SimpleRenderable virtual Ogre::Real getBoundingRadius()const { return Math::Sqrt(std::max(mBox.getMaximum().squaredLength(), mBox.getMinimum().squaredLength())); } /// Implementation of Ogre::SimpleRenderable virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera* cam)const { Vector3 vMin, vMax, vMid, vDist; vMin = mBox.getMinimum(); vMax = mBox.getMaximum(); vMid = ((vMin - vMax) * 0.5) + vMin; vDist = cam->getDerivedPosition() - vMid; return vDist.squaredLength(); } protected: /** Initializes the dynamic renderable. @remarks This function should only be called once. It initializes the render operation, and calls the abstract function createVertexDeclaration(). @param operationType The type of render operation to perform. @param useIndices Specifies whether to use indices to determine the vertices to use as input. */ void initialize(Ogre::RenderOperation::OperationType operationType, bool useIndices) { // Initialize render operation mRenderOp.operationType = operationType; mRenderOp.useIndexes = useIndices; mRenderOp.vertexData = new VertexData; if (mRenderOp.useIndexes) mRenderOp.indexData = new IndexData; // Reset buffer capacities mVertexBufferCapacity = 0; mIndexBufferCapacity = 0; // Create vertex declaration createVertexDeclaration(); } /** Creates the vertex declaration. @remarks Override and set mRenderOp.vertexData->vertexDeclaration here. mRenderOp.vertexData will be created for you before this method is called. */ virtual void createVertexDeclaration() { VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration; decl->addElement(POSITION_BINDING, 0, VET_FLOAT3, VES_POSITION); } /** Prepares the hardware buffers for the requested vertex and index counts. @remarks This function must be called before locking the buffers in fillHardwareBuffers(). It guarantees that the hardware buffers are large enough to hold at least the requested number of vertices and indices (if using indices). The buffers are possibly reallocated to achieve this. @par The vertex and index count in the render operation are set to the values of vertexCount and indexCount respectively. @param vertexCount The number of vertices the buffer must hold. @param indexCount The number of indices the buffer must hold. This parameter is ignored if not using indices. */ void prepareHardwareBuffers(size_t vertexCount, size_t indexCount) { // Prepare vertex buffer size_t newVertCapacity = mVertexBufferCapacity; if ((vertexCount > mVertexBufferCapacity) || (!mVertexBufferCapacity)) { // vertexCount exceeds current capacity! // It is necessary to reallocate the buffer. // Check if this is the first call if (!newVertCapacity) { newVertCapacity = 1; } // Make capacity the next power of two while (newVertCapacity < vertexCount) { newVertCapacity <<= 1; } } else if (vertexCount < mVertexBufferCapacity>>1) { // Make capacity the previous power of two while (vertexCount < newVertCapacity>>1) { newVertCapacity >>= 1; } } if (newVertCapacity != mVertexBufferCapacity) { mVertexBufferCapacity = newVertCapacity; // Create new vertex buffer HardwareVertexBufferSharedPtr vbuf = HardwareBufferManager::getSingleton().createVertexBuffer( mRenderOp.vertexData->vertexDeclaration->getVertexSize(0), mVertexBufferCapacity, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY); // Bind buffer mRenderOp.vertexData->vertexBufferBinding->setBinding(0, vbuf); } // Update vertex count in the render operation mRenderOp.vertexData->vertexCount = vertexCount; if (mRenderOp.useIndexes) { OgreAssert(indexCount <= std::numeric_limits<unsigned short>::max(), "indexCount exceeds 16 bit"); size_t newIndexCapacity = mIndexBufferCapacity; // Prepare index buffer if ((indexCount > newIndexCapacity) || (!newIndexCapacity)) { // indexCount exceeds current capacity! // It is necessary to reallocate the buffer. // Check if this is the first call if (!newIndexCapacity) { newIndexCapacity = 1; } // Make capacity the next power of two while (newIndexCapacity < indexCount) { newIndexCapacity <<= 1; } } else if (indexCount < newIndexCapacity>>1) { // Make capacity the previous power of two while (indexCount < newIndexCapacity>>1) newIndexCapacity >>= 1; } if (newIndexCapacity != mIndexBufferCapacity) { mIndexBufferCapacity = newIndexCapacity; // Create new index buffer mRenderOp.indexData->indexBuffer = HardwareBufferManager::getSingleton().createIndexBuffer( HardwareIndexBuffer::IT_16BIT, mIndexBufferCapacity, HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY); } // Update index count in the render operation mRenderOp.indexData->indexCount = indexCount; } } /** Fills the hardware vertex and index buffers with data. @remarks This function must call prepareHardwareBuffers() before locking the buffers to ensure the they are large enough for the data to be written. Afterwards the vertex and index buffers (if using indices) can be locked, and data can be written to them. */ virtual void fillHardwareBuffers() { size_t size = mPoints.size(); prepareHardwareBuffers(size,0); if (!size) { mBox.setExtents(Vector3::ZERO,Vector3::ZERO); mDirty=false; return; } Vector3 vaabMin = mPoints[0]; Vector3 vaabMax = mPoints[0]; HardwareVertexBufferSharedPtr vbuf = mRenderOp.vertexData->vertexBufferBinding->getBuffer(0); Real *prPos = static_cast<Real*>(vbuf->lock( HardwareBuffer::HBL_DISCARD)); { for(size_t i = 0; i < size; i++) { *prPos++ = mPoints[i].x; *prPos++ = mPoints[i].y; *prPos++ = mPoints[i].z; if(mPoints[i].x < vaabMin.x) vaabMin.x = mPoints[i].x; if(mPoints[i].y < vaabMin.y) vaabMin.y = mPoints[i].y; if(mPoints[i].z < vaabMin.z) vaabMin.z = mPoints[i].z; if(mPoints[i].x > vaabMax.x) vaabMax.x = mPoints[i].x; if(mPoints[i].y > vaabMax.y) vaabMax.y = mPoints[i].y; if(mPoints[i].z > vaabMax.z) vaabMax.z = mPoints[i].z; } } vbuf->unlock(); mBox.setExtents(vaabMin, vaabMax); mDirty = false; } private: std::vector<Vector3> mPoints; bool mDirty; /// Maximum capacity of the currently allocated vertex buffer. size_t mVertexBufferCapacity; /// Maximum capacity of the currently allocated index buffer. size_t mIndexBufferCapacity; }; } #endif |
|
From: tylerstreeter <tyl...@us...> - 2005-04-06 04:49:22
|
Update of /cvsroot/opal/opal/samples/playpen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1764/samples/playpen Modified Files: main.cpp playpen.vcproj Log Message: minor changes; added stuff to sample app Index: main.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/playpen/main.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** main.cpp 5 Apr 2005 05:18:52 -0000 1.6 --- main.cpp 6 Apr 2005 04:48:43 -0000 1.7 *************** *** 58,79 **** PlaypenApp::~PlaypenApp() { ! // Destroy the grasping line and its SceneNode. ! Ogre::SceneNode* sn = mGraspingSpringLine->getParentSceneNode(); ! ! // Detach and destroy all objects from the SceneNode. The ! // scene node should only have the OgreLine attached which ! // we must delete explicitly. ! while(sn->numAttachedObjects() > 0) { ! MovableObject* thisObject = ! sn->detachObject(static_cast<unsigned short>(0)); ! delete thisObject; ! } ! // Destroy the SceneNodes all of its children. ! sn->removeAndDestroyAllChildren(); ! mSceneMgr->getRootSceneNode()->removeAndDestroyChild( ! sn->getName()); ! sn = NULL; } --- 58,81 ---- PlaypenApp::~PlaypenApp() { ! if (mGraspingSpringLine) { ! // Destroy the grasping line and its SceneNode. ! Ogre::SceneNode* sn = mGraspingSpringLine->getParentSceneNode(); ! // Detach and destroy all objects from the SceneNode. The ! // scene node should only have the OgreLine attached which ! // we must delete explicitly. ! while(sn->numAttachedObjects() > 0) ! { ! MovableObject* thisObject = ! sn->detachObject(static_cast<unsigned short>(0)); ! delete thisObject; ! } ! ! // Destroy the SceneNodes all of its children. ! sn->removeAndDestroyAllChildren(); ! mSceneMgr->getRootSceneNode()->removeAndDestroyChild( ! sn->getName()); ! } } *************** *** 91,94 **** --- 93,97 ---- //mSceneMgr->showBoundingBoxes(true); + //mSimulator->setStepSize(0.001); // Set the ambient light level. *************** *** 123,127 **** // Make a crosshairs for picking. ! // Load models, create physical objects, etc. here. --- 126,133 ---- // Make a crosshairs for picking. ! Ogre::Overlay* overlay = ! OverlayManager::getSingleton().getByName("General/Crosshair"); ! overlay->show(); ! // Load models, create physical objects, etc. here. *************** *** 131,135 **** bool PlaypenApp::appFrameStarted(opal::real dt) { ! // Do per-frame application specific things here. // Update the grasping spring line. --- 137,141 ---- bool PlaypenApp::appFrameStarted(opal::real dt) { ! // Do per-frame application-specific things here. // Update the grasping spring line. *************** *** 230,234 **** if(mInputDevice->isKeyDown(KC_3) && mTimeUntilNextToggle <= 0) { ! Ogre::Vector3 boxDim(4, 4, 4); opal::Solid* s = mSimulator->createSolid(); s->setPosition(mCreationPoint); --- 236,240 ---- if(mInputDevice->isKeyDown(KC_3) && mTimeUntilNextToggle <= 0) { ! Ogre::Vector3 boxDim(2, 2, 8); opal::Solid* s = mSimulator->createSolid(); s->setPosition(mCreationPoint); *************** *** 306,311 **** } //// testing ! //if(mInputDevice->isKeyDown(KC_9) && mTimeUntilNextToggle <= 0) //{ // opal::Blueprint ragdollBP; --- 312,335 ---- } + // Create a medium capsule. + if(mInputDevice->isKeyDown(KC_9) && mTimeUntilNextToggle <= 0) + { + Ogre::Real radius = 0.6; + Ogre::Real length = 4; + opal::Solid* s = mSimulator->createSolid(); + s->setPosition(mCreationPoint); + opal::CapsuleShapeData data; + data.radius = radius; + data.length = length; + s->addShape(data); + createPhysicalEntityCapsule("", "Plastic/Blue", radius, length, + s); + + // Reset the timer for toggle keys. + mTimeUntilNextToggle = 0.3; + } + //// testing ! //if(mInputDevice->isKeyDown(KC_0) && mTimeUntilNextToggle <= 0) //{ // opal::Blueprint ragdollBP; *************** *** 521,525 **** opal::BoxShapeData boxData; boxData.dimensions = boxDim; ! boxData.material.friction = 0.001; // testing s->addShape(boxData); Ogre::Vector3 boxDimensions(boxDim[0], boxDim[1], boxDim[2]); --- 545,549 ---- opal::BoxShapeData boxData; boxData.dimensions = boxDim; ! boxData.material.density = 500; s->addShape(boxData); Ogre::Vector3 boxDimensions(boxDim[0], boxDim[1], boxDim[2]); Index: playpen.vcproj =================================================================== RCS file: /cvsroot/opal/opal/samples/playpen/playpen.vcproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** playpen.vcproj 3 Apr 2005 00:11:41 -0000 1.3 --- playpen.vcproj 6 Apr 2005 04:48:43 -0000 1.4 *************** *** 33,37 **** <Tool Name="VCLinkerTool" - AdditionalOptions="/STACK:20000000" AdditionalDependencies="ogremain_d.lib opal-ode_d.lib" OutputFile="../win32bin/debug/playpen.exe" --- 33,36 ---- *************** *** 41,44 **** --- 40,44 ---- ProgramDatabaseFile="$(OutDir)/playpen.pdb" SubSystem="1" + StackReserveSize="10000000" TargetMachine="1"/> <Tool *************** *** 85,89 **** <Tool Name="VCLinkerTool" - AdditionalOptions="/STACK:10000000" AdditionalDependencies="ogremain.lib opal-ode.lib" OutputFile="../win32bin/release/playpen.exe" --- 85,88 ---- *************** *** 92,95 **** --- 91,95 ---- GenerateDebugInformation="TRUE" SubSystem="1" + StackReserveSize="10000000" OptimizeReferences="2" EnableCOMDATFolding="2" |
|
From: tylerstreeter <tyl...@us...> - 2005-04-06 04:49:22
|
Update of /cvsroot/opal/opal/samples/data/materials In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1764/samples/data/materials Modified Files: basic.material Log Message: minor changes; added stuff to sample app Index: basic.material =================================================================== RCS file: /cvsroot/opal/opal/samples/data/materials/basic.material,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** basic.material 4 Apr 2005 13:09:08 -0000 1.3 --- basic.material 6 Apr 2005 04:48:43 -0000 1.4 *************** *** 62,63 **** --- 62,83 ---- } } + + material Special/Crosshair + { + receive_shadows off + + technique + { + pass + { + lighting off + scene_blend colour_blend + depth_check off + + texture_unit + { + texture crosshair.png + } + } + } + } |
|
From: tylerstreeter <tyl...@us...> - 2005-04-06 04:48:54
|
Update of /cvsroot/opal/opal/samples/data/textures In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1764/samples/data/textures Added Files: crosshair.png Log Message: minor changes; added stuff to sample app --- NEW FILE: crosshair.png --- (This appears to be a binary file; contents omitted.) |
|
From: tylerstreeter <tyl...@us...> - 2005-04-06 04:48:54
|
Update of /cvsroot/opal/opal/samples/data/overlays In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1764/samples/data/overlays Added Files: general.overlay Log Message: minor changes; added stuff to sample app --- NEW FILE: general.overlay --- // Ogre overlay scripts General/Crosshair { zorder 200 container Panel(General/Dot) { // Center it horzontally, put it at the top left 0.493 top 0.495 width 0.01 height 0.014 material Special/Crosshair } } |
|
From: tylerstreeter <tyl...@us...> - 2005-04-06 04:48:53
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1764/src Modified Files: Defines.h JointData.h Simulator.cpp Simulator.h Solid.h Log Message: minor changes; added stuff to sample app Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** Simulator.cpp 31 Mar 2005 08:47:02 -0000 1.55 --- Simulator.cpp 6 Apr 2005 04:48:44 -0000 1.56 *************** *** 63,91 **** Simulator::~Simulator() { - //// Mark everything as garbage, then collect the garbage. - //size_t i; - - //for (i=0; i<mSolidList.size(); ++i) - //{ - // mSolidGarbageList.push_back(mSolidList[i]); - //} - - //for (i=0; i<mJointList.size(); ++i) - //{ - // mJointGarbageList.push_back(mJointList[i]); - //} - - //for (i=0; i<mMotorList.size(); ++i) - //{ - // mMotorGarbageList.push_back(mMotorList[i]); - //} - - //for (i=0; i<mSensorList.size(); ++i) - //{ - // mSensorGarbageList.push_back(mSensorList[i]); - //} - - //collectGarbage(); - destroyAllSolids(); destroyAllJoints(); --- 63,66 ---- *************** *** 139,143 **** solidIter != mSolidList.end(); ++solidIter) { ! (*solidIter)->internal_applyForces(mStepSize); } --- 114,172 ---- solidIter != mSolidList.end(); ++solidIter) { ! Solid* solid = *solidIter; ! ! solid->internal_applyForces(mStepSize); ! ! // Limit velocities and forces of moving Solids to ! // limit numerical inaccuracy from explicit integration ! // (mostly from quickly-spinning long, thin objects). ! if (!solid->isSleeping() && !solid->isStatic()) ! { ! bool velChanged = false; ! Vec3r linearVel = solid->getGlobalLinearVel(); ! if (linearVel[0] > mMaxLinearVel) ! { ! linearVel[0] = mMaxLinearVel; ! velChanged = true; ! } ! if (linearVel[1] > mMaxLinearVel) ! { ! linearVel[1] = mMaxLinearVel; ! velChanged = true; ! } ! if (linearVel[2] > mMaxLinearVel) ! { ! linearVel[2] = mMaxLinearVel; ! velChanged = true; ! } ! if (velChanged) ! { ! solid->setGlobalLinearVel(linearVel); ! solid->zeroForces(); ! } ! ! velChanged = false; ! Vec3r angularVel = solid->getGlobalAngularVel(); ! if (angularVel[0] > mMaxAngularVel) ! { ! angularVel[0] = mMaxAngularVel; ! velChanged = true; ! } ! if (angularVel[1] > mMaxAngularVel) ! { ! angularVel[1] = mMaxAngularVel; ! velChanged = true; ! } ! if (angularVel[2] > mMaxAngularVel) ! { ! angularVel[2] = mMaxAngularVel; ! velChanged = true; ! } ! if (velChanged) ! { ! solid->setGlobalAngularVel(angularVel); ! solid->zeroForces(); ! } ! } } *************** *** 163,211 **** Solid* solid = *solidIter; - // Cap velocities. - bool velChanged = false; - Vec3r linearVel = solid->getGlobalLinearVel(); - if (linearVel[0] > mMaxLinearVel) - { - linearVel[0] = mMaxLinearVel; - velChanged = true; - } - if (linearVel[1] > mMaxLinearVel) - { - linearVel[1] = mMaxLinearVel; - velChanged = true; - } - if (linearVel[2] > mMaxLinearVel) - { - linearVel[2] = mMaxLinearVel; - velChanged = true; - } - if (velChanged) - { - solid->setGlobalLinearVel(linearVel); - } - - velChanged = false; - Vec3r angularVel = solid->getGlobalAngularVel(); - if (angularVel[0] > mMaxAngularVel) - { - angularVel[0] = mMaxAngularVel; - velChanged = true; - } - if (angularVel[1] > mMaxAngularVel) - { - angularVel[1] = mMaxAngularVel; - velChanged = true; - } - if (angularVel[2] > mMaxAngularVel) - { - angularVel[2] = mMaxAngularVel; - velChanged = true; - } - if (velChanged) - { - solid->setGlobalAngularVel(angularVel); - } - // Get each Solid's new transform from the physics engine. solid->internal_updateOPALTransform(); --- 192,195 ---- *************** *** 233,239 **** } - //// Deallocate memory here now that it's safe. - //collectGarbage(); - return stepOccurred; } --- 217,220 ---- *************** *** 770,774 **** void Simulator::destroySolid(Solid* s) { - //mSolidGarbageList.push_back(s); removeSolid(s); } --- 751,754 ---- *************** *** 778,782 **** for (size_t i=0; i<mSolidList.size(); ++i) { - //mSolidGarbageList.push_back(mSolidList[i]); removeSolid(mSolidList[i]); } --- 758,761 ---- *************** *** 785,789 **** void Simulator::destroyJoint(Joint* j) { - //mJointGarbageList.push_back(j); removeJoint(j); } --- 764,767 ---- *************** *** 791,800 **** void Simulator::destroyAllJoints() { - // Just mark everything as garbage; it'll get destroyed at the end of - // the current step. - for (size_t i=0; i<mJointList.size(); ++i) { - //mJointGarbageList.push_back(mJointList[i]); removeJoint(mJointList[i]); } --- 769,774 ---- *************** *** 844,848 **** void Simulator::destroyMotor(Motor* m) { - //mMotorGarbageList.push_back(m); removeMotor(m); } --- 818,821 ---- *************** *** 850,859 **** void Simulator::destroyAllMotors() { - // Just mark everything as garbage; it'll get destroyed at the end of - // the current step. - for (size_t i=0; i<mMotorList.size(); ++i) { - //mMotorGarbageList.push_back(mMotorList[i]); removeMotor(mMotorList[i]); } --- 823,828 ---- *************** *** 890,894 **** void Simulator::destroySensor(Sensor* s) { - //mSensorGarbageList.push_back(s); removeSensor(s); } --- 859,862 ---- *************** *** 896,920 **** void Simulator::destroyAllSensors() { - // Just mark everything as garbage; it'll get destroyed at the end of - // the current step. - for (size_t i=0; i<mSensorList.size(); ++i) { - //mSensorGarbageList.push_back(mSensorList[i]); removeSensor(mSensorList[i]); } } - //void Simulator::setDefaultSleepiness(real value) - //{ - // assert(value >= 0.0 && value <= 1.0); - // mDefaultSleepiness = value; - //} - - //real Simulator::getDefaultSleepiness()const - //{ - // return mDefaultSleepiness; - //} - void Simulator::setSolverAccuracy(SolverAccuracyLevel level) { --- 864,873 ---- *************** *** 1065,1100 **** mSpaceList.push_back(s); } - - //void Simulator::collectGarbage() - //{ - // size_t i; - - // for (i=0; i<mSolidGarbageList.size(); ++i) - // { - // removeSolid(mSolidGarbageList[i]); - // } - - // mSolidGarbageList.clear(); - - // for (i=0; i<mJointGarbageList.size(); ++i) - // { - // removeJoint(mJointGarbageList[i]); - // } - - // mJointGarbageList.clear(); - - // for (i=0; i<mMotorGarbageList.size(); ++i) - // { - // removeMotor(mMotorGarbageList[i]); - // } - - // mMotorGarbageList.clear(); - - // for (i=0; i<mSensorGarbageList.size(); ++i) - // { - // removeSensor(mSensorGarbageList[i]); - // } - - // mSensorGarbageList.clear(); - //} } --- 1018,1020 ---- Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** Defines.h 31 Mar 2005 08:47:02 -0000 1.71 --- Defines.h 6 Apr 2005 04:48:44 -0000 1.72 *************** *** 132,139 **** Material(real h, real f, real b, real d) { ! assert(h >= 0.0 && h <= 1.0); ! assert(f >= 0.0 && f <= 1.0); ! assert(b >= 0.0 && b <= 1.0); ! assert(d >= 0.0); hardness = h; --- 132,139 ---- Material(real h, real f, real b, real d) { ! //assert(h >= 0.0 && h <= 1.0); ! //assert(f >= 0.0 && f <= 1.0); ! //assert(b >= 0.0 && b <= 1.0); ! //assert(d >= 0.0); hardness = h; *************** *** 151,158 **** } ! /// Determines how far Solids can interpenetrate. real hardness; ! /// Simple friction constant. real friction; --- 151,159 ---- } ! /// Determines how far Solids can interpenetrate. This must ! /// be between 0 and 1. real hardness; ! /// Simple friction constant. This must be between 0 and 1. real friction; *************** *** 161,169 **** /// words, the more bounciness, the farther the Solids will bounce /// when they collide (and, in real life, the less energy is lost ! /// due to heat and sound). real bounciness; /// Density combined with the volume of a Solid's shapes determine ! /// the Solid's mass. real density; }; --- 162,170 ---- /// words, the more bounciness, the farther the Solids will bounce /// when they collide (and, in real life, the less energy is lost ! /// due to heat and sound). This must be between 0 and 1. real bounciness; /// Density combined with the volume of a Solid's shapes determine ! /// the Solid's mass. This must be >= 0. real density; }; Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** Solid.h 4 Apr 2005 13:09:11 -0000 1.86 --- Solid.h 6 Apr 2005 04:48:44 -0000 1.87 *************** *** 151,154 **** --- 151,157 ---- virtual void OPAL_CALL addForce(const Force& f); + /// Removes all forces and torques currently affecting this Solid. + virtual void OPAL_CALL zeroForces() = 0; + /// Sets the Solid's linear velocity in local coordinates. virtual void OPAL_CALL setLocalLinearVel(const Vec3r& vel) = 0; Index: JointData.h =================================================================== RCS file: /cvsroot/opal/opal/src/JointData.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** JointData.h 28 Mar 2005 22:33:07 -0000 1.7 --- JointData.h 6 Apr 2005 04:48:44 -0000 1.8 *************** *** 50,54 **** real high; ! /// Determines how far a Joint can exceed its limits. real hardness; --- 50,55 ---- real high; ! /// Determines how far a Joint can exceed its limits. This must ! /// be between 0 and 1. real hardness; Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** Simulator.h 31 Mar 2005 08:47:02 -0000 1.93 --- Simulator.h 6 Apr 2005 04:48:44 -0000 1.94 *************** *** 273,279 **** virtual ~Simulator(); - ///// Destroys all objects in the Simulator marked as garbage. - //void collectGarbage(); - /// Adds a Solid to the internal list of Solids. void addSolid(Solid* s); --- 273,276 ---- *************** *** 340,355 **** std::vector<Sensor*> mSensorList; - ///// An internal list of all Solids marked as garbage. - //std::vector<Solid*> mSolidGarbageList; - - ///// An internal list of all Joints. - //std::vector<Joint*> mJointGarbageList; - - ///// An internal list of all Motors marked as garbage. - //std::vector<Motor*> mMotorGarbageList; - - ///// An internal list of all Sensors marked as garbage. - //std::vector<Sensor*> mSensorGarbageList; - /// Spaces are stored here so the user doesn't have to destroy them; /// they get destroyed when the Simulator is destroyed. --- 337,340 ---- |
|
From: tylerstreeter <tyl...@us...> - 2005-04-06 04:48:53
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1764 Modified Files: todo.txt Log Message: minor changes; added stuff to sample app Index: todo.txt =================================================================== RCS file: /cvsroot/opal/opal/todo.txt,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** todo.txt 5 Apr 2005 05:18:53 -0000 1.69 --- todo.txt 6 Apr 2005 04:48:45 -0000 1.70 *************** *** 26,29 **** --- 26,31 ---- * comment math functions + * make an OPAL_ASSERT that prints informative messages; replace all assert() calls + * move samples to a separate module? *************** *** 47,50 **** --- 49,55 ---- ================= + * implement fast rotation instability fix idea for ode, posted on ode message board; remove max velocity caps? (note that novodex uses only max angular velocity) + - alternate solution: just use an aggressive max angular vel and/or angular damping, like novodex does + * private constructors for opal-managed objects? |
|
From: tylerstreeter <tyl...@us...> - 2005-04-06 04:48:53
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1764/src/ODE Modified Files: ODESimulator.cpp ODESolid.cpp ODESolid.h Log Message: minor changes; added stuff to sample app Index: ODESolid.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.h,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** ODESolid.h 4 Apr 2005 13:09:11 -0000 1.67 --- ODESolid.h 6 Apr 2005 04:48:45 -0000 1.68 *************** *** 121,124 **** --- 121,126 ---- //virtual void OPAL_CALL setFastRotationAxis(Vec3r axis); + virtual void OPAL_CALL zeroForces(); + virtual real OPAL_CALL getMass()const; Index: ODESimulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.cpp,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** ODESimulator.cpp 30 Mar 2005 23:26:23 -0000 1.95 --- ODESimulator.cpp 6 Apr 2005 04:48:44 -0000 1.96 *************** *** 146,153 **** dBodyID bodyID = ((ODESolid*)solid)->internal_getBodyID(); ! dBodySetLinearVel(bodyID, 0.0, 0.0, 0.0); ! dBodySetAngularVel(bodyID, 0.0, 0.0, 0.0); ! dBodySetForce(bodyID, 0.0, 0.0, 0.0); ! dBodySetTorque(bodyID, 0.0, 0.0, 0.0); } else --- 146,153 ---- dBodyID bodyID = ((ODESolid*)solid)->internal_getBodyID(); ! dBodySetLinearVel(bodyID, 0, 0, 0); ! dBodySetAngularVel(bodyID, 0, 0, 0); ! dBodySetForce(bodyID, 0, 0, 0); ! dBodySetTorque(bodyID, 0, 0, 0); } else *************** *** 502,505 **** --- 502,507 ---- // Average the hardness of the two materials. + assert(m0->hardness >= 0 && m0->hardness <= 1 + && m1->hardness >= 0 && m1->hardness <= 1); real hardness = (m0->hardness + m1->hardness) * (real)0.5; *************** *** 519,522 **** --- 521,526 ---- // to max, though it is set to dInfinity when // friction == 1.0. + assert(m0->friction >= 0 && m0->friction <= 1 + && m1->friction >= 0 && m1->friction <= 1); if (1.0 == m0->friction && 1.0 == m1->friction) { *************** *** 531,534 **** --- 535,540 ---- // Average the bounciness of the two materials. + assert(m0->bounciness >= 0 && m0->bounciness <= 1 + && m1->bounciness >= 0 && m1->bounciness <= 1); real bounciness = (m0->bounciness + m1->bounciness) * (real)0.5; *************** *** 1023,1068 **** } - //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) { --- 1029,1032 ---- Index: ODESolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** ODESolid.cpp 4 Apr 2005 13:09:10 -0000 1.81 --- ODESolid.cpp 6 Apr 2005 04:48:45 -0000 1.82 *************** *** 481,484 **** --- 481,486 ---- void ODESolid::addShape(const ShapeData& data) { + assert(data.material.density >= 0); + dGeomID newGeomID = NULL; dGeomID newTransformID = NULL; *************** *** 826,829 **** --- 828,845 ---- //} + void ODESolid::zeroForces() + { + if (!mData.isStatic) + { + dBodySetForce(mBodyID, 0, 0, 0); + dBodySetTorque(mBodyID, 0, 0, 0); + + while (!mForceList.empty()) + { + mForceList.pop_back(); + } + } + } + real ODESolid::getMass()const { |
|
From: tylerstreeter <tyl...@us...> - 2005-04-06 04:48:53
|
Update of /cvsroot/opal/opal/samples/data/models In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1764/samples/data/models Added Files: cylinder.mesh sphere.mesh Log Message: minor changes; added stuff to sample app --- NEW FILE: cylinder.mesh --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sphere.mesh --- (This appears to be a binary file; contents omitted.) |
|
From: tylerstreeter <tyl...@us...> - 2005-04-06 04:37:52
|
Update of /cvsroot/opal/opal/samples/data/overlays In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31772/overlays Log Message: Directory /cvsroot/opal/opal/samples/data/overlays added to the repository |
|
From: tylerstreeter <tyl...@us...> - 2005-04-05 05:19:07
|
Update of /cvsroot/opal/opal/samples/playpen In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29607/samples/playpen Modified Files: main.cpp Log Message: fixed bugs in sample app Index: main.cpp =================================================================== RCS file: /cvsroot/opal/opal/samples/playpen/main.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** main.cpp 4 Apr 2005 13:09:09 -0000 1.5 --- main.cpp 5 Apr 2005 05:18:52 -0000 1.6 *************** *** 1,4 **** --- 1,5 ---- #include <time.h> #include "../src/BaseOpalApp.h" + #include "../src/OgreLine.h" namespace playpen *************** *** 20,23 **** --- 21,27 ---- virtual bool processUnbufferedMouseInput(Ogre::Real dt); + /// Creates the initial objects in the world. + void setupInitialPhysicalEntities(); + /// Builds a wall of boxes centered at the origin. void createWall(unsigned int length, unsigned height, *************** *** 54,57 **** --- 58,79 ---- PlaypenApp::~PlaypenApp() { + // Destroy the grasping line and its SceneNode. + Ogre::SceneNode* sn = mGraspingSpringLine->getParentSceneNode(); + + // Detach and destroy all objects from the SceneNode. The + // scene node should only have the OgreLine attached which + // we must delete explicitly. + while(sn->numAttachedObjects() > 0) + { + MovableObject* thisObject = + sn->detachObject(static_cast<unsigned short>(0)); + delete thisObject; + } + + // Destroy the SceneNodes all of its children. + sn->removeAndDestroyAllChildren(); + mSceneMgr->getRootSceneNode()->removeAndDestroyChild( + sn->getName()); + sn = NULL; } *************** *** 100,132 **** mGraspingSpringLine->setVisible(false); - //// Create a physical ground plane. - //mSimulator->createPlane(0, 1, 0, 0); - - //// Create a visual ground plane. - //Ogre::Plane plane(Ogre::Vector3(0, 0, -1), 0); - //Ogre::MeshManager::getSingleton().createPlane("plane", "General", - // plane, 3000, 3000, 10, 10); - //Entity* e = mSceneMgr->createEntity("ground plane", "plane"); - //e->setMaterialName("Flat/Gray"); - //Ogre::SceneNode* sn = mSceneMgr->getRootSceneNode()-> - // createChildSceneNode("ground plane"); - //sn->attachObject(e); - //Ogre::Radian angle(Ogre::Degree(90)); - //sn->rotate(Ogre::Vector3(1, 0, 0), angle); - - // Create a static box for a ground plane. - Ogre::Vector3 groundDim(100, 8, 100); - opal::Solid* s = mSimulator->createSolid(); - s->setStatic(true); - s->setPosition(0, -4, 0); - opal::BoxShapeData data; - data.dimensions.set(groundDim[0], groundDim[1], groundDim[2]); - s->addShape(data); - createPhysicalEntityBox("ground", "Plastic/Gray", groundDim, s); - // Make a crosshairs for picking. - // Load models, create physical objects, etc. here. } --- 122,130 ---- mGraspingSpringLine->setVisible(false); // Make a crosshairs for picking. // Load models, create physical objects, etc. here. + + setupInitialPhysicalEntities(); } *************** *** 190,194 **** --- 188,195 ---- if(mInputDevice->isKeyDown(KC_R)) { + // Make sure the PhysicalCamera isn't grabbing anything. + mPhysicalCamera->release(); destroyAllPhysicalEntities(); + setupInitialPhysicalEntities(); } *************** *** 354,358 **** // The following code updates the camera's position. ! opal::Vec3r cameraDir; bool cameraMoved = false; --- 355,359 ---- // The following code updates the camera's position. ! opal::Vec3r cameraDir(0, 0, 0); bool cameraMoved = false; *************** *** 469,472 **** --- 470,501 ---- } + void PlaypenApp::setupInitialPhysicalEntities() + { + //// Create a physical ground plane. + //mSimulator->createPlane(0, 1, 0, 0); + + //// Create a visual ground plane. + //Ogre::Plane plane(Ogre::Vector3(0, 0, -1), 0); + //Ogre::MeshManager::getSingleton().createPlane("plane", "General", + // plane, 3000, 3000, 10, 10); + //Entity* e = mSceneMgr->createEntity("ground plane", "plane"); + //e->setMaterialName("Flat/Gray"); + //Ogre::SceneNode* sn = mSceneMgr->getRootSceneNode()-> + // createChildSceneNode("ground plane"); + //sn->attachObject(e); + //Ogre::Radian angle(Ogre::Degree(90)); + //sn->rotate(Ogre::Vector3(1, 0, 0), angle); + + // Create a static box for a ground plane. + Ogre::Vector3 groundDim(100, 8, 100); + opal::Solid* s = mSimulator->createSolid(); + s->setStatic(true); + s->setPosition(0, -4, 0); + opal::BoxShapeData data; + data.dimensions.set(groundDim[0], groundDim[1], groundDim[2]); + s->addShape(data); + createPhysicalEntityBox("ground", "Plastic/Gray", groundDim, s); + } + void PlaypenApp::createWall(unsigned int length, unsigned height, const opal::Vec3r& boxDim, const opal::Matrix44r& baseTransform) |
|
From: tylerstreeter <tyl...@us...> - 2005-04-05 05:19:07
|
Update of /cvsroot/opal/opal/samples/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29607/samples/src Modified Files: BaseOpalApp.h ExampleApplication.h PhysicalCamera.h Log Message: fixed bugs in sample app Index: PhysicalCamera.h =================================================================== RCS file: /cvsroot/opal/opal/samples/src/PhysicalCamera.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PhysicalCamera.h 4 Apr 2005 13:09:10 -0000 1.2 --- PhysicalCamera.h 5 Apr 2005 05:18:53 -0000 1.3 *************** *** 4,7 **** --- 4,10 ---- #include <opal/opal.h> + // TODO: Make an option to switch from physical to non-physical and vice + // versa on the fly. + namespace opalSamples { *************** *** 168,172 **** assert(mSolid); ! // TODO... //// don't let the camera fly --- 171,175 ---- assert(mSolid); ! // TODO: finish this. //// don't let the camera fly *************** *** 207,210 **** --- 210,224 ---- //v *= 3; //mSolid->setGlobalLinearVel(v); + + Ogre::Matrix4 ogreCamMat = + mOgreCamera->getViewMatrix().inverse(); + Ogre::Vector3 localDir(dir[0], dir[1], dir[2]); + + // Convert the local direction vector to a global direction + // vector. Subtract out the camera's position. + Ogre::Vector3 globalDir = ogreCamMat * localDir; + globalDir -= mOgreCamera->getPosition(); + opal::Vec3r opalVec(globalDir[0], globalDir[1], globalDir[2]); + mSolid->setGlobalLinearVel(opalVec); } else *************** *** 375,383 **** { Ogre::Matrix4 ogreMat = mOgreCamera->getViewMatrix().inverse(); - //Ogre::Vector3 camPos = mOgreCamera->getPosition(); Ogre::Vector3 graspOffset(mGraspOffset[0], mGraspOffset[1], mGraspOffset[2]); ! // Transform the offset vector to global space. graspOffset = ogreMat * graspOffset; --- 389,397 ---- { Ogre::Matrix4 ogreMat = mOgreCamera->getViewMatrix().inverse(); Ogre::Vector3 graspOffset(mGraspOffset[0], mGraspOffset[1], mGraspOffset[2]); ! // Transform the offset vector (actually representing a point) ! // to global space. graspOffset = ogreMat * graspOffset; Index: BaseOpalApp.h =================================================================== RCS file: /cvsroot/opal/opal/samples/src/BaseOpalApp.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BaseOpalApp.h 4 Apr 2005 13:09:09 -0000 1.5 --- BaseOpalApp.h 5 Apr 2005 05:18:53 -0000 1.6 *************** *** 6,10 **** #include "PhysicalEntity.h" #include "PhysicalCamera.h" - #include "OgreLine.h" #include <opal/opal.h> --- 6,9 ---- *************** *** 253,265 **** mSimulator->destroySolid(pe->getSolid()); ! // Destroy the PhysicalEntity's Ogre SceneNode. Ogre::SceneNode* sn = pe->getSceneNode(); ! // Detach and destroy all objects from the SceneNode. while(sn->numAttachedObjects() > 0) { MovableObject* thisObject = sn->detachObject(static_cast<unsigned short>(0)); ! delete thisObject; } --- 252,269 ---- mSimulator->destroySolid(pe->getSolid()); ! // Destroy the PhysicalEntity's Ogre SceneNode and ! // attached Entities. Ogre::SceneNode* sn = pe->getSceneNode(); ! // Detach and destroy all objects from the SceneNode; ! // in this case, there should only be a single entity ! // (which is why we can safely call 'removeEntity' ! // here). while(sn->numAttachedObjects() > 0) { MovableObject* thisObject = sn->detachObject(static_cast<unsigned short>(0)); ! std::string s = thisObject->getName(); ! mSceneMgr->removeEntity(thisObject->getName()); } *************** *** 268,274 **** --- 272,280 ---- mSceneMgr->getRootSceneNode()->removeAndDestroyChild( sn->getName()); + sn = NULL; // Delete the PhysicalEntity. delete pe; + pe = NULL; // Copy the last element over this one and pop the last *************** *** 287,297 **** void destroyAllPhysicalEntities() { - // TODO: fix this (and maybe destroyPhysicalEntity) since - // they break things when called in the middle of the app. while (!mPhysicalEntityList.empty()) { destroyPhysicalEntity(mPhysicalEntityList.back()); - //delete mPhysicalEntityList.back(); - //mPhysicalEntityList.pop_back(); } --- 293,299 ---- Index: ExampleApplication.h =================================================================== RCS file: /cvsroot/opal/opal/samples/src/ExampleApplication.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ExampleApplication.h 4 Apr 2005 13:09:10 -0000 1.4 --- ExampleApplication.h 5 Apr 2005 05:18:53 -0000 1.5 *************** *** 112,116 **** // If returned true, user clicked OK so initialise // Here we choose to let the system create a default rendering window by passing 'true' ! mWindow = mRoot->initialise(true); return true; } --- 112,116 ---- // If returned true, user clicked OK so initialise // Here we choose to let the system create a default rendering window by passing 'true' ! mWindow = mRoot->initialise(true, "OPAL-Ogre Sample Application"); return true; } |
|
From: tylerstreeter <tyl...@us...> - 2005-04-05 05:19:07
|
Update of /cvsroot/opal/opal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29607 Modified Files: todo.txt Log Message: fixed bugs in sample app Index: todo.txt =================================================================== RCS file: /cvsroot/opal/opal/todo.txt,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** todo.txt 4 Apr 2005 13:09:12 -0000 1.68 --- todo.txt 5 Apr 2005 05:18:53 -0000 1.69 *************** *** 47,50 **** --- 47,52 ---- ================= + * private constructors for opal-managed objects? + * remove plane from shapes; just make it a special object? - it isn't really something you would store in a blueprint *************** *** 83,86 **** --- 85,92 ---- - if we use them, should we also have custom sensors? + * investigate sleeping for entire islands + - this may make stacks a lot more stable + - search ode mailing list for "Any BloodRayne 2 developers listening?" + Build System ============ |