Changeset 4397 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- May 30, 2005, 4:57:04 PM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/particles/particle_system.cc
r4395 r4397 40 40 \todo this constructor is not jet implemented - do it 41 41 */ 42 ParticleSystem::ParticleSystem (unsigned int maxCount, PARTICLE_TYPE type) 42 ParticleSystem::ParticleSystem (unsigned int maxCount, PARTICLE_TYPE type) : PhysicsInterface(this) 43 43 { 44 44 this->setClassID(CL_PARTICLE_SYSTEM, "ParticleSystem"); -
orxonox/trunk/src/lib/physics/physics_interface.cc
r4396 r4397 36 36 \brief standard constructor 37 37 */ 38 PhysicsInterface::PhysicsInterface ( )38 PhysicsInterface::PhysicsInterface (void* objectPointer) 39 39 { 40 this->objectPointer = objectPointer; 41 40 42 // this->setClassName ("PhysicsInterface"); 41 43 this->mass = 1; … … 90 92 void PhysicsInterface::applyField(Field* field) 91 93 { 92 this->forceSum += field->calcForce(dynamic_cast<PNode*>(this)->getAbsCoor()); 94 PNode* tmp = (PNode*) objectPointer; 95 this->forceSum += field->calcForce(tmp->getAbsCoor()); 93 96 } 94 97 95 98 void PhysicsInterface::tickPhys( float dt ) 96 99 { 97 Vector acc = this->forceSum / ( this->massChildren + this->mass );98 PNode* coorTick = (PNode*) this;99 coorTick->setRelCoor(coorTick->getRelCoor() + (this->forceSum / this->mass * dt));100 100 // Vector acc = this->forceSum / ( this->massChildren + this->mass ); 101 PNode* coorTick = (PNode*)(this->objectPointer); 102 if (coorTick) 103 coorTick->setRelCoor(coorTick->getRelCoor() + this->forceSum/this->mass * dt); 101 104 this->forceSum = Vector(0,0,0); 102 105 // todo: introduce kinematics -
orxonox/trunk/src/lib/physics/physics_interface.h
r4395 r4397 9 9 #include "vector.h" 10 10 #include "base_object.h" 11 12 #ifndef NULL 13 #define NULL 0 14 #endif 11 15 12 16 // Forward Declaration … … 26 30 27 31 public: 28 PhysicsInterface( );32 PhysicsInterface(void* objectPointer); 29 33 virtual ~PhysicsInterface(); 30 34 /** \param mass the mass to set for this node. */ … … 43 47 44 48 private: 49 void* objectPointer; 45 50 float mass; //!< Mass of this object 46 51 float massChildren; //!< Sum of the masses of the children nodes -
orxonox/trunk/src/story_entities/world.cc
r4396 r4397 477 477 478 478 Field* gravity = new Gravity(); 479 gravity->setMagnitude(10 00);479 gravity->setMagnitude(10.0); 480 480 // gravity->setParent(this->localCamera->getTarget()); 481 481 … … 484 484 485 485 new PhysicsConnection(system, gravity); 486 new PhysicsConnection(this->localPlayer, gravity);487 488 489 WorldEntity* testEntity = new TestEntity();490 //testEntity->setRelCoor(Vector(570, 10, -15));491 testEntity->setRelCoor(Vector(25, -10, -20));486 // new PhysicsConnection(this->localPlayer, gravity); 487 488 489 TestEntity* testEntity = new TestEntity(); 490 testEntity->setRelCoor(Vector(570, 10, -15)); 491 //testEntity->setRelCoor(Vector(25, -10, -20)); 492 492 testEntity->setRelDir(Quaternion(M_PI, Vector(0, 1, 0))); 493 493 this->spawn(testEntity); 494 this->localPlayer->addChild(testEntity); 494 // this->localPlayer->addChild(testEntity); 495 496 new PhysicsConnection(testEntity, gravity); 495 497 } 496 498 … … 585 587 this->localPlayer->setName ("player"); 586 588 this->spawn (this->localPlayer); 589 this->localPlayer->setRelCoor(Vector(5,0,0)); 587 590 /*monitor progress*/ 588 591 this->glmis->step(); 592 593 Field* testField = new Gravity(); 594 testField->setMagnitude(10); 595 new PhysicsConnection(this->localPlayer, testField); 589 596 590 597 // bind camera … … 1010 1017 this->localCamera->tick(this->dt); 1011 1018 AnimationPlayer::getInstance()->tick(this->dtS); 1012 1013 1019 PhysicsEngine::getInstance()->tick(this->dtS); 1014 1020 -
orxonox/trunk/src/world_entities/player.cc
r4389 r4397 39 39 \param isFree if the player is free 40 40 */ 41 Player::Player() : WorldEntity() 41 Player::Player() : WorldEntity(), PhysicsInterface(this) 42 42 { 43 43 /* … … 46 46 the player.cc for debug also 47 47 */ 48 this->setClassName("Player"); 48 49 this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN); 49 50 travelSpeed = 15.0; … … 82 83 \todo add more parameters to load 83 84 */ 84 Player::Player(const TiXmlElement* root) : WorldEntity(root) 85 { 85 Player::Player(const TiXmlElement* root) : WorldEntity(root), PhysicsInterface(this) 86 { 87 this->setClassName("Player"); 86 88 this->weapons = new tList<Weapon>(); 87 89 this->activeWeapon = NULL; … … 196 198 void Player::tick (float time) 197 199 { 200 printf("%p\n", this); 201 this->getRelCoor().debug(); 202 198 203 /* link tick to weapon */ 199 204 //this->activeWeapon->tick(time); -
orxonox/trunk/src/world_entities/test_entity.cc
r4320 r4397 26 26 27 27 28 TestEntity::TestEntity () : WorldEntity() 28 TestEntity::TestEntity () : WorldEntity(), PhysicsInterface(this) 29 29 { 30 30 this->setClassID(CL_TEST_ENTITY, "TestEntity"); -
orxonox/trunk/src/world_entities/test_entity.h
r4276 r4397 3 3 4 4 #include "world_entity.h" 5 #include "physics_interface.h" 5 6 6 7 class MD2Loader; … … 10 11 class Material; 11 12 12 class TestEntity : public WorldEntity 13 class TestEntity : public WorldEntity, PhysicsInterface 13 14 { 14 15 friend class World;
Note: See TracChangeset
for help on using the changeset viewer.