Changeset 4558 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Jun 8, 2005, 9:02:12 PM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/physics/physics_engine.cc
r4519 r4558 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 28 28 \brief standard constructor 29 29 */ 30 PhysicsEngine::PhysicsEngine() 30 PhysicsEngine::PhysicsEngine() 31 31 { 32 32 this->setClassName ("PhysicsEngine"); … … 46 46 47 47 */ 48 PhysicsEngine::~PhysicsEngine () 48 PhysicsEngine::~PhysicsEngine () 49 49 { 50 50 PhysicsEngine::singletonRef = NULL; … … 71 71 void PhysicsEngine::removePhysicsInterface(PhysicsInterface* physicsInterface) 72 72 { 73 this->interfaces->remove(physicsInterface); 73 this->interfaces->remove(physicsInterface); 74 74 } 75 75 … … 99 99 \brief adds A Physical Connection to the List of Connections 100 100 \param connection the Connection to add 101 101 102 102 Usually this is done through the constructor of PhysicshConnections 103 103 */ … … 110 110 \brief removes A Physical Connection from the List of Connections 111 111 \param connection the Connection to remove 112 112 113 113 Usually this is done through the destructor of PhysicsConnections 114 114 */ … … 130 130 void PhysicsEngine::tick(float dt) 131 131 { 132 /* go through all the PhysicsInterface(s) and tick them, 133 meaning let the fields work */ 132 134 tIterator<PhysicsConnection>* itPC = this->connections->getIterator(); 133 135 PhysicsConnection* enumPC = itPC->nextElement(); … … 135 137 { 136 138 enumPC->apply(); 139 137 140 enumPC = itPC->nextElement(); 138 141 } 139 142 delete itPC; 140 143 141 144 /* actually tick all the PhysicsInterfaces. Move the objects around */ 142 145 tIterator<PhysicsInterface>* itPI = this->interfaces->getIterator(); 143 146 PhysicsInterface* enumPI = itPI->nextElement(); … … 145 148 { 146 149 enumPI->tickPhys(dt); 150 147 151 enumPI = itPI->nextElement(); 148 152 } -
orxonox/trunk/src/lib/physics/physics_engine.h
r4519 r4558 1 /*! 1 /*! 2 2 \file physics_engine.h 3 \brief Definition of the ...singleton Class4 3 \brief Definition of the PhysicsEngine-singleton Class 4 5 5 */ 6 6 … … 18 18 19 19 20 //! A default singleton class.20 //! A class, that brings things into motion through Physics. 21 21 class PhysicsEngine : public BaseObject { 22 22 … … 41 41 private: 42 42 PhysicsEngine(void); 43 static PhysicsEngine* singletonRef; //!< the singleton reference of the PhysicsEngine44 43 45 tList<PhysicsInterface>* interfaces; //!< a list of physically based objects 46 tList<Field>* fields; //!< a list of physicsl fields. 47 tList<PhysicsConnection>* connections; //!< a list of physical connections 44 private: 45 static PhysicsEngine* singletonRef; //!< the singleton reference of the PhysicsEngine 46 47 tList<PhysicsInterface>* interfaces; //!< a list of physically based objects 48 tList<Field>* fields; //!< a list of physicsl fields. 49 tList<PhysicsConnection>* connections; //!< a list of physical connections 48 50 }; 49 51 -
orxonox/trunk/src/lib/physics/physics_interface.cc
r4555 r4558 44 44 this->massChildren = 0; 45 45 this->forceSum = Vector(0, 0, 0); 46 this->bForceApplied = false; 46 47 47 48 PhysicsEngine::getInstance()->addPhysicsInterface(this); … … 97 98 PNode* tmp = (PNode*) objectPointer; 98 99 this->forceSum += field->calcForce(tmp->getAbsCoor()); 100 this->bForceApplied = true; 99 101 } 100 102 … … 107 109 // Vector acc = this->forceSum / ( this->massChildren + this->mass ); 108 110 PNode* coorTick = (PNode*)(this->objectPointer); 109 if (coorTick) 110 coorTick->setRelCoor(coorTick->getRelCoor() + this->forceSum/this->mass * dt); 111 if (this->bForceApplied && coorTick) 112 { 113 coorTick->shiftCoor((coorTick->getVelocity()+ this->forceSum/this->mass * dt)*dt); 114 115 this->bForceApplied = false; 116 } 111 117 this->forceSum = Vector(0,0,0); 112 // todo: introduce kinematics113 118 } -
orxonox/trunk/src/lib/physics/physics_interface.h
r4555 r4558 48 48 private: 49 49 void* objectPointer; //!< A Pointer to the object we handel (actually should be this) 50 51 50 52 float mass; //!< Mass of this object 51 53 float massChildren; //!< Sum of the masses of the children nodes 54 52 55 Vector forceSum; //!< Total central force for this tick 53 56 Quaternion momentumSum; //!< Total momentum in this tick 57 bool bForceApplied; //!< If a force was applied to this object. 54 58 }; 55 59 -
orxonox/trunk/src/story_entities/world.cc
r4555 r4558 214 214 this->debugWorldNr = worldID; 215 215 this->entities = new tList<WorldEntity>(); 216 this->cycle = 0; 216 217 } 217 218 … … 498 499 Field* gravity = new Gravity(); 499 500 gravity->setMagnitude(10.0); 500 //gravity->setParent(this->localCamera->getTarget());501 gravity->setParent(this->localCamera->getTarget()); 501 502 502 503 // Add the Flow from the Emitter into the System … … 958 959 while( !this->bQuitOrxonox && !this->bQuitCurrentGame) /* \todo implement pause */ 959 960 { 961 ++this->cycle; 960 962 PRINTF(3)("World::mainloop() - number of entities: %i\n", this->entities->getSize()); 961 963 // Network … … 1058 1060 this->trackManager->tick(this->dt); 1059 1061 this->localCamera->tick(this->dt); 1062 // tick the engines 1060 1063 AnimationPlayer::getInstance()->tick(this->dtS); 1061 PhysicsEngine::getInstance()->tick(this->dtS);1062 1063 1064 particleEngine->tick(this->dtS);1065 this->garbageCollector->tick(this->dtS);1066 1067 /* actualy the Graphics Engine should tick the world not the other way around...1064 if (this->cycle > 5) 1065 PhysicsEngine::getInstance()->tick(this->dtS); 1066 1067 ParticleEngine::getInstance()->tick(this->dtS); 1068 GarbageCollector::getInstance()->tick(this->dtS); 1069 1070 /** actualy the Graphics Engine should tick the world not the other way around... 1068 1071 but since we like the things not too complicated we got it this way around 1069 1072 until there is need or time to do it the other way around. -
orxonox/trunk/src/story_entities/world.h
r4409 r4558 1 /*! 1 /*! 2 2 \file world.h 3 3 \brief Holds and manages all game data 4 */ 4 */ 5 5 6 6 #ifndef _WORLD_H … … 81 81 virtual void displayLoadScreen(); 82 82 virtual void releaseLoadScreen(); 83 83 84 84 /* command node functions */ 85 85 bool command (Command* cmd); … … 90 90 void spawn (WorldEntity* entity); 91 91 void spawn (WorldEntity* entity, Vector* absCoor, Quaternion* absDir); 92 void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir, 93 92 void spawn(WorldEntity* entity, PNode* parentNode, Vector* relCoor, Quaternion* relDir, 93 int parentingMode); 94 94 95 95 const char* getPath(); … … 102 102 103 103 Uint32 lastFrame; //!< last time of frame 104 Uint32 cycle; //!< The cycle we are in (starts with 0 and rises with every frame) 104 105 Uint32 dt; //!< time needed to calculate this frame 105 106 float dtS; //!< The time needed for caluculations in seconds
Note: See TracChangeset
for help on using the changeset viewer.