Changeset 2124
- Timestamp:
- Nov 2, 2008, 8:43:36 PM (16 years ago)
- Location:
- code/branches/physics
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/HelloBullet.cc
r2119 r2124 40 40 #include "core/ConfigValueIncludes.h" 41 41 #include "core/XMLPort.h" 42 #include " GraphicsEngine.h"42 #include "objects/Scene.h" 43 43 44 44 #include "util/Sleep.h" … … 49 49 CreateFactory(HelloBullet); 50 50 51 HelloBullet::HelloBullet() 51 HelloBullet::HelloBullet(BaseObject* creator) 52 : BaseObject(creator) 52 53 { 53 54 RegisterObject(HelloBullet); … … 94 95 95 96 //load floor mash 96 Ogre::SceneManager* sceneMgr = GraphicsEngine::getInstance().getLevelSceneManager();97 Ogre::SceneManager* sceneMgr = creator->getScene()->getSceneManager(); 97 98 98 99 int i = 0; -
code/branches/physics/src/orxonox/objects/HelloBullet.h
r2119 r2124 42 42 { 43 43 public: 44 HelloBullet( );44 HelloBullet(BaseObject* creator); 45 45 virtual ~HelloBullet(); 46 46 void setConfigValues(); -
code/branches/physics/src/orxonox/objects/PhysicsTest.cc
r2119 r2124 40 40 #include "core/XMLPort.h" 41 41 #include "GraphicsEngine.h" 42 #include "Scene.h" 42 43 43 44 namespace orxonox … … 45 46 CreateFactory(PhysicsTest); 46 47 47 PhysicsTest::PhysicsTest() 48 : odeWorld_(0) 48 PhysicsTest::PhysicsTest(BaseObject* creator) 49 : BaseObject(creator) 50 , odeWorld_(0) 49 51 , odeSpace_(0) 50 52 , odeStepper_(0) … … 84 86 SUPER(PhysicsTest, XMLPort, xmlelement, mode); 85 87 86 Ogre::SceneManager* sceneMgr = GraphicsEngine::getInstance().getLevelSceneManager();88 Ogre::SceneManager* sceneMgr = this->getScene()->getSceneManager(); 87 89 88 90 // set up OgreOde … … 103 105 const Ogre::Real time_scale = Ogre::Real(1.7); 104 106 const Ogre::Real max_frame_time = Ogre::Real(1.0 / 4); 105 odeStepper_ = new OgreOde::StepHandler(odeWorld_, OgreOde::StepHandler::QuickStep, _time_step,107 odeStepper_ = new OgreOde::StepHandler(odeWorld_, OgreOde::StepHandler::QuickStep, _time_step, 106 108 max_frame_time, time_scale); 107 109 108 110 109 // Create a hanging crate111 // create a plane in x-z dimensions. 110 112 111 113 odeGround_ = new OgreOde::InfinitePlaneGeometry(Ogre::Plane(Ogre::Vector3(0,1,0),0), 112 114 odeWorld_, odeWorld_->getDefaultSpace()); 113 115 114 CollidingObject* collidingObject = new CollidingObject(); 115 116 odeGround_->setUserObject(static_cast<CollisionTestedObject*>(collidingObject)); 116 CollidingObject* collidingObject = new CollidingObject(); 117 odeGround_->setUserObject(static_cast<CollisionTestedObject*>(collidingObject)); 117 118 118 119 // Use a load of meshes to represent the floor … … 139 140 140 141 141 // create a plane in x-z dimensions.142 // create a hanging crate 142 143 143 144 entity_ = sceneMgr->createEntity("crate","crate.mesh"); … … 147 148 entity_->setNormaliseNormals(true); 148 149 entity_->setCastShadows(true); 149 150 150 151 151 odeBody_ = new OgreOde::Body(odeWorld_); … … 178 178 } 179 179 180 bool PhysicsTest::collision(OgreOde::Contact *Contact)181 { 182 183 OgreOde::Geometry * const g1 = Contact->getFirstGeometry();184 OgreOde::Geometry * const g2 = Contact->getSecondGeometry();185 186 187 188 189 const OgreOde::Body * constb2 = g1->getBody();190 191 192 193 194 195 Contact->setBouncyness(1.0);196 Contact->setCoulombFriction(OgreOde::Utility::Infinity);197 Contact->setForceDependentSlip(1.0);198 Contact->setAdditionalFDS(1.0);199 200 /*we have 2 collidable objects from our object system, if one of the Collide function returns false, e return false in this method, too, else we return true, so ode computes a normal collision.201 true means ode will treat this like a normal collison => rigid body behavior202 false means ode will not treat this collision at all => objects ignore each other*/203 204 bool Return= true;205 180 bool PhysicsTest::collision(OgreOde::Contact* contact) 181 { 182 // Check for collisions between things that are connected and ignore them 183 OgreOde::Geometry * const g1 = contact->getFirstGeometry(); 184 OgreOde::Geometry * const g2 = contact->getSecondGeometry(); 185 186 if (g1 && g2) 187 { 188 const OgreOde::Body * const b1 = g2->getBody(); 189 const OgreOde::Body * const b2 = g1->getBody(); 190 if (b1 && b2 && OgreOde::Joint::areConnected(b1, b2)) 191 return false; 192 } 193 194 //set contact parameters: 195 contact->setBouncyness(1.0); 196 contact->setCoulombFriction(OgreOde::Utility::Infinity); 197 contact->setForceDependentSlip(1.0); 198 contact->setAdditionalFDS(1.0); 199 200 // we have 2 collidable objects from our object system, if one of the Collide function returns false, e return false in this method, too, else we return true, so ode computes a normal collision. 201 // true means ode will treat this like a normal collison => rigid body behavior 202 // false means ode will not treat this collision at all => objects ignore each other 203 204 bool res = true; 205 206 206 if (g1->getUserObject()) 207 if (!static_cast<CollisionTestedObject*>(g1->getUserObject())->Collide(true, Contact))208 Return= false;209 207 if (!static_cast<CollisionTestedObject*>(g1->getUserObject())->collide(true, contact)) 208 res = false; 209 210 210 if (g2->getUserObject()) 211 if (!static_cast<CollisionTestedObject*>(g2->getUserObject())->Collide(false, Contact))212 Return= false;213 214 return Return;215 } 216 217 bool CollidingObject::Collide(bool MineIsFirst, OgreOde::Contact *Contact)218 219 Contact->setForceDependentSlip(Contact->getForceDependentSlip() * ForceDependentSlip);220 Contact->setAdditionalFDS(Contact->getForceDependentSlip2() * ForceDependentSlip);221 Contact->setCoulombFriction(Contact->getCoulombFrictionMu() * Friction);222 Contact->setBouncyness(Contact->getBouncyness() * Bouncyness, Contact->getBouncynessVelocity() * BounceVelocity);223 224 211 if (!static_cast<CollisionTestedObject*>(g2->getUserObject())->collide(false, contact)) 212 res = false; 213 214 return res; 215 } 216 217 bool CollidingObject::Collide(bool MineIsFirst, OgreOde::Contact* contact) 218 { 219 contact->setForceDependentSlip(contact->getForceDependentSlip() * ForceDependentSlip); 220 contact->setAdditionalFDS(contact->getForceDependentSlip2() * ForceDependentSlip); 221 contact->setCoulombFriction(contact->getCoulombFrictionMu() * Friction); 222 contact->setBouncyness(contact->getBouncyness() * Bouncyness, contact->getBouncynessVelocity() * BounceVelocity); 223 return true; 224 } 225 225 226 226 } -
code/branches/physics/src/orxonox/objects/PhysicsTest.h
r2119 r2124 42 42 { 43 43 public: 44 PhysicsTest( );44 PhysicsTest(BaseObject* creator); 45 45 virtual ~PhysicsTest(); 46 46 void setConfigValues(); … … 66 66 67 67 68 class _OrxonoxExport CollisionTestedObject69 {70 71 72 73 virtual bool Collide(bool MineIsFirst, OgreOde::Contact *Contact) = 0;74 };68 class _OrxonoxExport CollisionTestedObject 69 { 70 public: 71 CollisionTestedObject(void); 72 virtual ~CollisionTestedObject(void); 73 virtual bool Collide(bool bMineFirst, OgreOde::Contact* contact) = 0; 74 }; 75 75 76 class _OrxonoxExport CollidingObject : public virtual CollisionTestedObject 77 { 78 protected: 79 float Friction; 80 float Bouncyness; 81 float BounceVelocity; 82 float ForceDependentSlip; 83 84 public: 85 CollidingObject(void); 86 virtual ~CollidingObject(void); 87 88 // bool virtual WriteToIni(IniFile& Ini) const; 89 // bool virtual LoadFromIni(const std::basic_string<wchar_t>& ObjectID, IniFile& Ini); 90 91 float GetFriction(void) const {return Friction;} 92 float GetBouncyness(void) const {return Bouncyness;} 93 float GetBounceVelocity(void) const {return BounceVelocity;} 94 float GetFDS(void) const {return ForceDependentSlip;} 95 96 virtual bool Collide(bool MineIsFirst, OgreOde::Contact *Contact); 97 98 private: 99 static const wchar_t* KEY_FRICTION; 100 static const float DEF_FRICTION; 101 static const wchar_t* KEY_BOUNCYNESS; 102 static const float DEF_BOUNCYNESS; 103 static const wchar_t* KEY_FDS; 104 static const float DEF_FDS; 105 static const wchar_t* KEY_BOUNCE_VELO; 106 static const float DEF_BOUNCE_VELO; 107 }; 76 class _OrxonoxExport CollidingObject : virtual public CollisionTestedObject 77 { 78 protected: 79 float friction_; 80 float bouncyness_; 81 float bounceVelocity_; 82 float forceDependentSlip_; 83 84 public: 85 CollidingObject(void); 86 virtual ~CollidingObject(void); 87 88 //virtual bool writeToIni(IniFile& ini) const; 89 //virtual bool loadFromIni(const std::basic_string<wchar_t>& objectID, IniFile& ini); 90 91 float getFriction(void) const {return friction_;} 92 float getBouncyness(void) const {return bouncyness_;} 93 float getBounceVelocity(void) const {return bounceVelocity_;} 94 float getFDS(void) const {return forceDependentSlip_;} 95 96 virtual bool collide(bool bMineFirst, OgreOde::Contact *contact); 97 98 private: 99 //static const wchar_t* KEY_FRICTION; 100 //static const float DEF_FRICTION; 101 //static const wchar_t* KEY_BOUNCYNESS; 102 //static const float DEF_BOUNCYNESS; 103 //static const wchar_t* KEY_FDS; 104 //static const float DEF_FDS; 105 //static const wchar_t* KEY_BOUNCE_VELO; 106 //static const float DEF_BOUNCE_VELO; 107 108 }; 108 109 109 110 } -
code/branches/physics/visual_studio/vc8/base.vsprops
r2119 r2124 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalIncludeDirectories=""$(RootDir)src";"$(RootDir)src\ceguilua-0.6.1";"$( LibDir)ogre-1.4.9\include";"$(LibDir)boost-1.35.0\include";"$(LibDir)cegui-0.6.1\include";"$(LibDir)enet-1.2\include";"$(LibDir)libogg-1.1.3\include";"$(LibDir)libvorbis-1.2.0\include";"$(LibDir)openal-1.1\include";"$(LibDir)freealut-1.1.0\include";"$(LibDir)tcl-8.5.2\include";"$(LibDir)zlib-1.2.3\include";"$(LibDir)ode-0.10.1\include""10 AdditionalIncludeDirectories=""$(RootDir)src";"$(RootDir)src\ceguilua-0.6.1";"$(RootDir)src\ogrebullet\Dynamics";"$(RootDir)src\ogrebullet\Collisions";"$(RootDir)src\bullet";"$(LibDir)ogre-1.4.9\include";"$(LibDir)boost-1.35.0\include";"$(LibDir)cegui-0.6.1\include";"$(LibDir)enet-1.2\include";"$(LibDir)libogg-1.1.3\include";"$(LibDir)libvorbis-1.2.0\include";"$(LibDir)openal-1.1\include";"$(LibDir)freealut-1.1.0\include";"$(LibDir)tcl-8.5.2\include";"$(LibDir)zlib-1.2.3\include";"$(LibDir)ode-0.10.1\include"" 11 11 PreprocessorDefinitions="WIN32;__WIN32__;_WIN32;_WINDOWS;BOOST_ALL_DYN_LINK;OIS_DYNAMIC_LIB;ZLIB_WINAPI" 12 12 WarningLevel="3" -
code/branches/physics/visual_studio/vc8/bullet.vsprops
r2119 r2124 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalIncludeDirectories=" $(RootDir)src\bullet;$(RootDir)src\bullet\BulletCollision;$(RootDir)src\bullet\BulletDynamics;$(RootDir)src\bullet\BulletSoftBody;$(RootDir)src\bullet\LinearMath"10 AdditionalIncludeDirectories="" 11 11 TreatWChar_tAsBuiltInType="false" 12 12 /> -
code/branches/physics/visual_studio/vc8/ogrebullet_collisions.vsprops
r2119 r2124 9 9 Name="VCCLCompilerTool" 10 10 AdditionalOptions="/Zm200" 11 AdditionalIncludeDirectories=" $(RootDir)src\bullet;$(RootDir)src\ogrebullet\Collisions"11 AdditionalIncludeDirectories="" 12 12 PreprocessorDefinitions="_PRECOMP" 13 13 UsePrecompiledHeader="2" -
code/branches/physics/visual_studio/vc8/ogrebullet_dynamics.vsprops
r2119 r2124 9 9 Name="VCCLCompilerTool" 10 10 AdditionalOptions="/Zm200" 11 AdditionalIncludeDirectories=" $(RootDir)src\bullet;$(RootDir)src\ogrebullet\Collisions;$(RootDir)src\ogrebullet\Dynamics"11 AdditionalIncludeDirectories="" 12 12 PreprocessorDefinitions="_PRECOMP" 13 13 UsePrecompiledHeader="2" -
code/branches/physics/visual_studio/vc8/orxonox.vcproj
r2107 r2124 206 206 </File> 207 207 <File 208 RelativePath="..\..\src\orxonox\objects\HelloBullet.cc" 209 > 210 </File> 211 <File 212 RelativePath="..\..\src\orxonox\objects\PhysicsTest.cc" 213 > 214 <FileConfiguration 215 Name="Debug|Win32" 216 ExcludedFromBuild="true" 217 > 218 <Tool 219 Name="VCCLCompilerTool" 220 /> 221 </FileConfiguration> 222 <FileConfiguration 223 Name="Release|Win32" 224 ExcludedFromBuild="true" 225 > 226 <Tool 227 Name="VCCLCompilerTool" 228 /> 229 </FileConfiguration> 230 </File> 231 <File 208 232 RelativePath="..\..\src\orxonox\objects\Radar.cc" 209 233 > … … 846 870 </File> 847 871 <File 872 RelativePath="..\..\src\orxonox\objects\HelloBullet.h" 873 > 874 </File> 875 <File 876 RelativePath="..\..\src\orxonox\objects\PhysicsTest.h" 877 > 878 </File> 879 <File 848 880 RelativePath="..\..\src\orxonox\objects\Radar.h" 849 881 > -
code/branches/physics/visual_studio/vc8/orxonox_vc8.sln
r2119 r2124 8 8 EndProjectSection 9 9 ProjectSection(ProjectDependencies) = postProject 10 {4733BD1A-E04C-458D-8BFB-5010250EA497} = {4733BD1A-E04C-458D-8BFB-5010250EA497}11 10 {35575B59-E1AE-40E8-89C4-2862B5B09B68} = {35575B59-E1AE-40E8-89C4-2862B5B09B68} 12 {40511677-D792-42A1-AD87-DEE31D887F67} = {40511677-D792-42A1-AD87-DEE31D887F67}13 11 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F} 14 12 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC} 15 13 {F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F} 16 14 {271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86} 17 {77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD} = {77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}18 15 {09E86264-CA02-4A60-98EA-61BB3F460160} = {09E86264-CA02-4A60-98EA-61BB3F460160} 19 16 {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5} = {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5} … … 21 18 {BA753941-F455-43A2-925C-7F3E02F6A995} = {BA753941-F455-43A2-925C-7F3E02F6A995} 22 19 {4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F} = {4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F} 23 {BBA88DC2-CD78-4C00-814B-183899090F3E} = {BBA88DC2-CD78-4C00-814B-183899090F3E}24 20 {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} = {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} 25 21 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} … … 230 226 {271715F3-5B90-4110-A552-70C788084A86}.Release|Win32.Build.0 = Release|Win32 231 227 {4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.ActiveCfg = Debug|Win32 232 {4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.Build.0 = Debug|Win32233 228 {4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.ActiveCfg = Release|Win32 234 {4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.Build.0 = Release|Win32235 229 {35575B59-E1AE-40E8-89C4-2862B5B09B68}.Debug|Win32.ActiveCfg = Debug|Win32 236 230 {35575B59-E1AE-40E8-89C4-2862B5B09B68}.Debug|Win32.Build.0 = Debug|Win32 … … 258 252 {8F5B7ED0-D380-4B4F-A744-3A568718176C}.Release|Win32.Build.0 = Release|Win32 259 253 {BBA88DC2-CD78-4C00-814B-183899090F3E}.Debug|Win32.ActiveCfg = Debug|Win32 260 {BBA88DC2-CD78-4C00-814B-183899090F3E}.Debug|Win32.Build.0 = Debug|Win32261 254 {BBA88DC2-CD78-4C00-814B-183899090F3E}.Release|Win32.ActiveCfg = Release|Win32 262 {BBA88DC2-CD78-4C00-814B-183899090F3E}.Release|Win32.Build.0 = Release|Win32263 255 {77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}.Debug|Win32.ActiveCfg = Debug|Win32 264 {77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}.Debug|Win32.Build.0 = Debug|Win32265 256 {77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}.Release|Win32.ActiveCfg = Release|Win32 266 {77D52DF7-23DD-4739-A4F4-D9BD6C1EA9AD}.Release|Win32.Build.0 = Release|Win32267 257 {40511677-D792-42A1-AD87-DEE31D887F67}.Debug|Win32.ActiveCfg = Debug|Win32 268 {40511677-D792-42A1-AD87-DEE31D887F67}.Debug|Win32.Build.0 = Debug|Win32269 258 {40511677-D792-42A1-AD87-DEE31D887F67}.Release|Win32.ActiveCfg = Release|Win32 270 {40511677-D792-42A1-AD87-DEE31D887F67}.Release|Win32.Build.0 = Release|Win32271 259 {BA753941-F455-43A2-925C-7F3E02F6A995}.Debug|Win32.ActiveCfg = Debug|Win32 272 260 {BA753941-F455-43A2-925C-7F3E02F6A995}.Debug|Win32.Build.0 = Debug|Win32
Note: See TracChangeset
for help on using the changeset viewer.