From: <bel...@us...> - 2010-11-23 01:48:26
|
Revision: 2978 http://ogreaddons.svn.sourceforge.net/ogreaddons/?rev=2978&view=rev Author: bellyfish Date: 2010-11-23 01:48:19 +0000 (Tue, 23 Nov 2010) Log Message: ----------- * adding 6DofSpringConstraint patch. Thanks to snegovick: http://www.ogre3d.org/addonforums/viewtopic.php?f=12&t=13652 Modified Paths: -------------- trunk/ogrebullet/Demos/include/OgreBulletInputListener.h trunk/ogrebullet/Dynamics/include/Constraints/Makefile.am trunk/ogrebullet/Dynamics/scripts/VC8/OgreBulletDynamics_VC8.vcproj trunk/ogrebullet/Dynamics/src/Makefile.am Added Paths: ----------- trunk/ogrebullet/Dynamics/include/Constraints/OgreBulletDynamics6DofSpringConstraint.h trunk/ogrebullet/Dynamics/src/Constraints/OgreBulletDynamics6DofSpringConstraint.cpp Modified: trunk/ogrebullet/Demos/include/OgreBulletInputListener.h =================================================================== --- trunk/ogrebullet/Demos/include/OgreBulletInputListener.h 2010-11-15 21:39:06 UTC (rev 2977) +++ trunk/ogrebullet/Demos/include/OgreBulletInputListener.h 2010-11-23 01:48:19 UTC (rev 2978) @@ -32,7 +32,7 @@ #define BULLET_MOUSE_EVENT Ogre::MouseEvent* #define BULLET_KC Ogre::KC #define BULLET_LISTENER_IMPLEMENTATION_RETURN void - #define BULLET_LISTENER_IMPLEMENTATION_RETURN_CODE + #define BULLET_LISTENER_IMPLEMENTATION_RETURN_CODE #define BULLET_GETKEY e->getKey() @@ -46,14 +46,18 @@ #define BULLET_BUTTON2_UP e->getButtonID() == e->BUTTON2_MASK #define BULLET_GETRELX e->getRelX() - #define BULLET_GETRELY e->getRelY() + #define BULLET_GETRELY e->getRelY() #define BULLET_GETX e->getX() #define BULLET_GETY e->getY() #else // NOTICE: You may need to change this line to <OIS.h> if you build OIS from source. - #include "OIS\OIS.h" +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 + #include "OIS.h" +#else + #include "OIS.h" +#endif namespace OIS { class Keyboard; @@ -92,10 +96,10 @@ /* The base Test class, is also able to listen for collisions and thus change the contact properties */ -class OgreBulletInputListener : +class OgreBulletInputListener : #if (OGRE_VERSION < ((1 << 16) | (3 << 8) | 0)) - public Ogre::MouseMotionListener, - public Ogre::MouseListener, + public Ogre::MouseMotionListener, + public Ogre::MouseListener, public Ogre::KeyListener #else public OIS::MouseListener, @@ -106,7 +110,7 @@ static const Ogre::Real KEY_DELAY; // Constructor/destructor - OgreBulletInputListener(OgreBulletListener * ogreBulletListener, + OgreBulletInputListener(OgreBulletListener * ogreBulletListener, Ogre::RenderWindow *win); virtual ~OgreBulletInputListener(){}; @@ -146,10 +150,10 @@ bool getButton1Pressed() const {return mButton1Pressed;} bool getButton2Pressed() const {return mButton2Pressed;} - + protected: - + Ogre::Real mRelX; Ogre::Real mRelY; Ogre::Real mMouseCursorX; Modified: trunk/ogrebullet/Dynamics/include/Constraints/Makefile.am =================================================================== --- trunk/ogrebullet/Dynamics/include/Constraints/Makefile.am 2010-11-15 21:39:06 UTC (rev 2977) +++ trunk/ogrebullet/Dynamics/include/Constraints/Makefile.am 2010-11-23 01:48:19 UTC (rev 2978) @@ -2,6 +2,7 @@ ogrebulletdynconstraintsinclude_HEADERS = \ OgreBulletDynamics6DofConstraint.h \ + OgreBulletDynamics6DofSpringConstraint.h \ OgreBulletDynamicsConeTwistConstraint.h \ OgreBulletDynamicsHingeConstraint.h \ OgreBulletDynamicsPoint2pointConstraint.h \ Added: trunk/ogrebullet/Dynamics/include/Constraints/OgreBulletDynamics6DofSpringConstraint.h =================================================================== --- trunk/ogrebullet/Dynamics/include/Constraints/OgreBulletDynamics6DofSpringConstraint.h (rev 0) +++ trunk/ogrebullet/Dynamics/include/Constraints/OgreBulletDynamics6DofSpringConstraint.h 2010-11-23 01:48:19 UTC (rev 2978) @@ -0,0 +1,76 @@ +/*************************************************************************** + +This source file is part of OGREBULLET +(Object-oriented Graphics Rendering Engine Bullet Wrapper) +For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10 + +Copyright (c) 2007 tua...@gm... (Use it Freely, even Statically, but have to contribute any changes) + + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +----------------------------------------------------------------------------- +*/ + +#ifndef _OGREBULLETDYNAMICS_SixDofSpringConstraint_H +#define _OGREBULLETDYNAMICS_SixDofSpringConstraint_H + +#include "OgreBulletDynamicsPreRequisites.h" + +#include "OgreBulletDynamicsConstraint.h" + + +namespace OgreBulletDynamics +{ + // ------------------------------------------------------------------------- + // SixDofSpringConstraint class + class SixDofSpringConstraint : public TypedConstraint + { + public: + SixDofSpringConstraint(RigidBody * rbA, RigidBody * rbB, + const Ogre::Vector3& FrameInAVector, const Ogre::Quaternion& FrameInAOrientation, + const Ogre::Vector3& FrameInBVector, const Ogre::Quaternion& FrameInBOrientation); + + void setLinearLowerLimit(const Ogre::Vector3& linearLower); + void setLinearUpperLimit(const Ogre::Vector3& linearUpper); + void setAngularLowerLimit(const Ogre::Vector3& angularLower); + void setAngularUpperLimit(const Ogre::Vector3& angularUpper); + + void setLimit(const int axis, const Ogre::Real lo, const Ogre::Real hi); + + void enableSpring(int index, bool onOff); + void setStiffness(int index, const Ogre::Real stiffness); + void setDamping(int index, const Ogre::Real damping); + void setEquilibriumPoint(int index); + void setEquilibriumPoint(); + //! Test limit + /*! + - free means upper < lower, + - locked means upper == lower + - limited means upper > lower + - limitIndex: first 3 are linear, next 3 are angular + */ + bool isLimited(int limitIndex); + + virtual ~SixDofSpringConstraint(); + + }; +} +#endif //_OGREBULLETDYNAMICS_SixDofSpringConstraint_H + Property changes on: trunk/ogrebullet/Dynamics/include/Constraints/OgreBulletDynamics6DofSpringConstraint.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ogrebullet/Dynamics/scripts/VC8/OgreBulletDynamics_VC8.vcproj =================================================================== --- trunk/ogrebullet/Dynamics/scripts/VC8/OgreBulletDynamics_VC8.vcproj 2010-11-15 21:39:06 UTC (rev 2977) +++ trunk/ogrebullet/Dynamics/scripts/VC8/OgreBulletDynamics_VC8.vcproj 2010-11-23 01:48:19 UTC (rev 2978) @@ -212,6 +212,10 @@ > </File> <File + RelativePath="..\..\src\Constraints\OgreBulletDynamics6DofSpringConstraint.cpp" + > + </File> + <File RelativePath="..\..\src\Constraints\OgreBulletDynamicsHingeConstraint.cpp" > </File> @@ -270,6 +274,10 @@ > </File> <File + RelativePath="..\..\include\Constraints\OgreBulletDynamics6DofSpringConstraint.h" + > + </File> + <File RelativePath="..\..\include\Constraints\OgreBulletDynamicsHingeConstraint.h" > </File> Added: trunk/ogrebullet/Dynamics/src/Constraints/OgreBulletDynamics6DofSpringConstraint.cpp =================================================================== --- trunk/ogrebullet/Dynamics/src/Constraints/OgreBulletDynamics6DofSpringConstraint.cpp (rev 0) +++ trunk/ogrebullet/Dynamics/src/Constraints/OgreBulletDynamics6DofSpringConstraint.cpp 2010-11-23 01:48:19 UTC (rev 2978) @@ -0,0 +1,120 @@ +/*************************************************************************** + +This source file is part of OGREBULLET +(Object-oriented Graphics Rendering Engine Bullet Wrapper) +For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10 + +Copyright (c) 2007 tua...@gm... (Use it Freely, even Statically, but have to contribute any changes) + + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +----------------------------------------------------------------------------- +*/ + +#include "OgreBulletDynamics.h" + +#include "OgreBulletDynamicsWorld.h" +#include "OgreBulletDynamicsRigidBody.h" + +#include "OgreBulletDynamicsConstraint.h" +#include "Constraints/OgreBulletDynamics6DofSpringConstraint.h" + +using namespace Ogre; + +namespace OgreBulletDynamics +{ + // ------------------------------------------------------------------------- + SixDofSpringConstraint::SixDofSpringConstraint(RigidBody * rbA, RigidBody * rbB, + const Vector3& FrameInAVector3, const Quaternion& FrameInAOrientation, + const Vector3& FrameInBVector3, const Quaternion& FrameInBOrientation): + TypedConstraint(rbA, rbB) + { + btTransform frameInA (OgreBulletCollisions::OgreBtConverter::to (FrameInAOrientation), + OgreBulletCollisions::OgreBtConverter::to (FrameInAVector3)); + btTransform frameInB (OgreBulletCollisions::OgreBtConverter::to (FrameInBOrientation), + OgreBulletCollisions::OgreBtConverter::to (FrameInBVector3)); + + mConstraint = new btGeneric6DofSpringConstraint( + *rbA->getBulletRigidBody (), + *rbB->getBulletRigidBody (), + frameInA, + frameInB, + true); // Eric added this because Bullet 2.61 has a new argument (useLinearReferenceFrameA) + } + // ------------------------------------------------------------------------- + SixDofSpringConstraint::~SixDofSpringConstraint() + { + } + // ------------------------------------------------------------------------- + void SixDofSpringConstraint::setLinearLowerLimit(const Ogre::Vector3& linearLower) + { + static_cast<btGeneric6DofSpringConstraint* > (mConstraint)->setLinearLowerLimit(OgreBulletCollisions::OgreBtConverter::to (linearLower)); + } + // ------------------------------------------------------------------------- + void SixDofSpringConstraint::setLinearUpperLimit(const Ogre::Vector3& linearUpper) + { + static_cast<btGeneric6DofSpringConstraint* > (mConstraint)->setLinearLowerLimit(OgreBulletCollisions::OgreBtConverter::to (linearUpper)); + } + // ------------------------------------------------------------------------- + void SixDofSpringConstraint::setAngularLowerLimit(const Ogre::Vector3& angularLower) + { + static_cast<btGeneric6DofSpringConstraint* > (mConstraint)->setLinearLowerLimit(OgreBulletCollisions::OgreBtConverter::to (angularLower)); + } + // ------------------------------------------------------------------------- + void SixDofSpringConstraint::setAngularUpperLimit(const Ogre::Vector3& angularUpper) + { + static_cast<btGeneric6DofSpringConstraint* > (mConstraint)->setLinearLowerLimit(OgreBulletCollisions::OgreBtConverter::to (angularUpper)); + } + // ------------------------------------------------------------------------- + void SixDofSpringConstraint::setLimit(const int axis, const Ogre::Real lo, const Ogre::Real hi) + { + static_cast<btGeneric6DofSpringConstraint* > (mConstraint)->setLimit(axis, lo, hi); + } + // ------------------------------------------------------------------------- + bool SixDofSpringConstraint::isLimited(int limitIndex) + { + return static_cast<btGeneric6DofSpringConstraint* > (mConstraint)->isLimited(limitIndex); + } + // ------------------------------------------------------------------------- + void SixDofSpringConstraint::enableSpring(int index, bool onOff) + { + static_cast<btGeneric6DofSpringConstraint* > (mConstraint)->enableSpring(index, onOff); + } + // ------------------------------------------------------------------------- + void SixDofSpringConstraint::setStiffness(int index, const Ogre::Real stiffness) + { + static_cast<btGeneric6DofSpringConstraint* > (mConstraint)->setStiffness(index, stiffness); + } + // ------------------------------------------------------------------------- + void SixDofSpringConstraint::setDamping(int index, const Ogre::Real damping) + { + static_cast<btGeneric6DofSpringConstraint* > (mConstraint)->setStiffness(index, damping); + } + // ------------------------------------------------------------------------- + void SixDofSpringConstraint::setEquilibriumPoint(int index) + { + static_cast<btGeneric6DofSpringConstraint* > (mConstraint)->setEquilibriumPoint(index); + } + // ------------------------------------------------------------------------- + void SixDofSpringConstraint::setEquilibriumPoint() + { + static_cast<btGeneric6DofSpringConstraint* > (mConstraint)->setEquilibriumPoint(); + } +} Property changes on: trunk/ogrebullet/Dynamics/src/Constraints/OgreBulletDynamics6DofSpringConstraint.cpp ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/ogrebullet/Dynamics/src/Makefile.am =================================================================== --- trunk/ogrebullet/Dynamics/src/Makefile.am 2010-11-15 21:39:06 UTC (rev 2977) +++ trunk/ogrebullet/Dynamics/src/Makefile.am 2010-11-23 01:48:19 UTC (rev 2978) @@ -13,6 +13,7 @@ OgreBulletDynamicsRigidBody.cpp \ OgreBulletDynamicsWorld.cpp \ Constraints/OgreBulletDynamics6DofConstraint.cpp \ + Constraints/OgreBulletDynamics6DofSpringConstraint.cpp \ Constraints/OgreBulletDynamicsConeTwistConstraint.cpp \ Constraints/OgreBulletDynamicsHingeConstraint.cpp \ Constraints/OgreBulletDynamicsPoint2pointConstraint.cpp \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |