Changeset 4376 in orxonox.OLD for orxonox/trunk/src/lib/physics/physics_interface.cc
- Timestamp:
- May 29, 2005, 12:30:54 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/physics/physics_interface.cc
r4375 r4376 21 21 22 22 #include "physics_interface.h" 23 24 #include "p_node.h" 25 23 26 #include "list.h" 24 27 #include "string.h" … … 33 36 PhysicsInterface::PhysicsInterface () 34 37 { 35 this->setClassName ("PhysicsInterface");38 // this->setClassName ("PhysicsInterface"); 36 39 this->mass = 0; 37 40 this->massChildren = 0; … … 49 52 } 50 53 54 /** 55 \brief recalculates the total mass of all the children of this node 56 57 (only availiable for PNodes) 58 */ 51 59 void PhysicsInterface::recalcMass() 52 60 { 53 float massSum = 0; 54 55 tIterator<PNode>* iterator = this->children->getIterator(); 56 PNode* pn = iterator->nextElement(); 57 while( pn != NULL) 61 PNode* massCalcPNode = dynamic_cast<PNode*>(this); //! \todo not sure if this will work .... 62 float massSum = 0; 63 64 tIterator<PNode>* iterator = massCalcPNode->children->getIterator(); 65 PNode* pn = iterator->nextElement(); 66 while( pn != NULL) 58 67 { 59 60 61 62 68 // todo: find out if children are PhysicsInterface in an efficient way 69 if (strcmp( pn->getClassName(), "PhysicsInterface")) { 70 massSum += ((PhysicsInterface*)pn)->getTotalMass(); 71 } 63 72 pn = iterator->nextElement(); 64 73 } 65 74 delete iterator; 66 75 67 68 69 if (strcmp(parent->getClassName(), "PhysicsInterface"))70 ((PhysicsInterface*)parent)->recalcMass();71 72 73 76 if (massSum != this->massChildren ) { 77 this->massChildren = massSum; 78 if (strcmp( massCalcPNode->parent->getClassName(), "PhysicsInterface")) 79 ((PhysicsInterface*)massCalcPNode->parent)->recalcMass(); 80 } else { 81 this->massChildren = massSum; 82 } 74 83 } 75 84 76 85 77 void PhysicsInterface::a ddForce( Vector force )86 void PhysicsInterface::applyForce( Vector force ) 78 87 { 79 88 this->forceSum += force; 80 89 } 81 90 82 void PhysicsInterface:: addForce(Vector force, Vector grip)91 void PhysicsInterface::tickPhys( float dt ) 83 92 { 84 // add central force 85 forceSum += force; 86 // add momentum 87 // todo: some vector math 93 Vector acc = this->forceSum / ( this->massChildren + this->mass ); 94 // todo: introduce kinematics 88 95 } 89 90 void PhysicsInterface::tick( float dt )91 {92 Vector acc = forceSum / ( massChildren + mass );93 // todo: introduce kinematics94 }
Note: See TracChangeset
for help on using the changeset viewer.