Changeset 2292 for code/branches/physics/src/orxonox/objects/Scene.cc
- Timestamp:
- Nov 28, 2008, 1:25:16 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/Scene.cc
r2192 r2292 39 39 #include "core/XMLPort.h" 40 40 41 #include "BulletCollision/BroadphaseCollision/btAxisSweep3.h" 42 #include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" 43 #include "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h" 44 41 45 namespace orxonox 42 46 { … … 70 74 } 71 75 72 ///////////// 73 // Physics // 74 ///////////// 75 76 // create bullet world; bullet solver etc. 77 78 // int maxProxies = 1024; 79 80 btVector3 worldAabbMin(-10000,-10000,-10000); 81 btVector3 worldAabbMax(10000,10000,10000); 82 bt32BitAxisSweep3* broadphase = new bt32BitAxisSweep3(worldAabbMin,worldAabbMax); 83 84 this -> collisionConfiguration_ = new btDefaultCollisionConfiguration(); 85 this -> dispatcher_ = new btCollisionDispatcher(collisionConfiguration_); 86 87 this -> solver_ = new btSequentialImpulseConstraintSolver; 88 89 this -> dynamicsWorld_ = new btDiscreteDynamicsWorld(dispatcher_,broadphase,solver_,collisionConfiguration_); 90 91 dynamicsWorld_->setGravity(btVector3(0,-10,0)); 92 76 // No physics for default 77 this->physicalWorld_ = 0; 93 78 94 79 // test test test … … 130 115 XMLPortParam(Scene, "shadow", setShadow, getShadow, xmlelement, mode).defaultValues(true); 131 116 117 const int defaultMaxWorldSize = 100000; 118 Vector3 worldAabbMin(-defaultMaxWorldSize, -defaultMaxWorldSize, -defaultMaxWorldSize); 119 Vector3 worldAabbMax( defaultMaxWorldSize, defaultMaxWorldSize, defaultMaxWorldSize); 120 XMLPortParamVariable(Scene, "negativeWorldRange", worldAabbMin, xmlelement, mode); 121 XMLPortParamVariable(Scene, "positiveWorldRange", worldAabbMax, xmlelement, mode); 122 XMLPortParam(Scene, "hasPhysics", setPhysicalWorld, hasPhysics, xmlelement, mode).defaultValue(0, true).defaultValue(1, worldAabbMin).defaultValue(2, worldAabbMax); 123 132 124 XMLPortObjectExtended(Scene, BaseObject, "", addObject, getObject, xmlelement, mode, true, false); 133 125 } … … 137 129 REGISTERSTRING(this->skybox_, network::direction::toclient, new network::NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox)); 138 130 REGISTERDATA(this->ambientLight_, network::direction::toclient, new network::NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight)); 131 } 132 133 void Scene::setPhysicalWorld(bool wantPhysics, const Vector3& worldAabbMin, const Vector3& worldAabbMax) 134 { 135 if (wantPhysics && !hasPhysics()) 136 { 137 btVector3 worldAabbMin(worldAabbMin.x, worldAabbMin.y, worldAabbMin.z); 138 btVector3 worldAabbMax(worldAabbMax.x, worldAabbMax.y, worldAabbMax.z); 139 140 btDefaultCollisionConfiguration* collisionConfig = new btDefaultCollisionConfiguration(); 141 btCollisionDispatcher* dispatcher = new btCollisionDispatcher(collisionConfig); 142 bt32BitAxisSweep3* broadphase = new bt32BitAxisSweep3(worldAabbMin,worldAabbMax); 143 btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver; 144 145 this->physicalWorld_ = new btDiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfig); 146 147 // test test test 148 this->physicalWorld_->setGravity(btVector3(0,0,0)); 149 // test test test 150 } 151 else 152 { 153 // TODO: Destroy Bullet physics 154 } 155 } 156 157 void Scene::tick(float dt) 158 { 159 if (physicalWorld_) 160 physicalWorld_->stepSimulation(dt,10); 139 161 } 140 162
Note: See TracChangeset
for help on using the changeset viewer.