Changeset 4121 in orxonox.OLD
- Timestamp:
- May 9, 2005, 3:01:57 AM (19 years ago)
- Location:
- orxonox/branches/physics/src/util/physics
- Files:
-
- 2 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/util/physics/i_physics.cc
r3961 r4121 19 19 20 20 #include "i_physics.h" 21 21 #include "list.h" 22 #include "string.h" 22 23 #include "stdincl.h" 23 24 … … 31 32 { 32 33 this->setClassName ("IPhysics"); 34 this->mass = 0; 35 this->massChildren = 0; 33 36 } 34 37 … … 42 45 // delete what has to be deleted here 43 46 } 47 48 49 50 void IPhysics::setMass( float mass ) 51 { 52 this->mass = mass; 53 } 54 55 float IPhysics::getMass( void ) const 56 { 57 return this->mass; 58 } 59 60 float IPhysics::getTotalMass( void ) const 61 { 62 return (this->mass + this->massChildren); 63 } 64 65 void IPhysics::recalcMass() 66 { 67 float massSum = 0; 68 69 tIterator<PNode>* iterator = this->children->getIterator(); 70 PNode* pn = iterator->nextElement(); 71 while( pn != NULL) 72 { 73 // todo: find out if children are IPhysics in an efficient way 74 if (strcmp( pn->getClassName(), "IPhysics")) { 75 massSum += ((IPhysics*)pn)->getTotalMass(); 76 } 77 pn = iterator->nextElement(); 78 } 79 delete iterator; 80 81 if (massSum != this->massChildren ) { 82 this->massChildren = massSum; 83 if (strcmp( parent->getClassName(), "IPhysics")) 84 ((IPhysics*)parent)->recalcMass(); 85 } else { 86 this->massChildren = massSum; 87 } 88 } 89 90 -
orxonox/branches/physics/src/util/physics/i_physics.h
r3961 r4121 1 1 /*! 2 2 \file i_physics.h 3 \brief a physics interface 3 \brief a physics interface simulating a body with a mass 4 4 */ 5 5 … … 7 7 #define _I_PHYSICS_H 8 8 9 #include "base_object.h" 10 11 9 #include "p_node.h" 12 10 13 11 //! A Physics interface … … 15 13 here can be some longer description of this class 16 14 */ 17 class IPhysics : public BaseObject{15 class IPhysics : public PNode { 18 16 19 17 public: 20 18 IPhysics(); 21 19 virtual ~IPhysics(); 20 21 void setMass( float mass ); //!< Set the mass of this node 22 float getMass( void ) const; //!< Get the mass of this node 23 float getTotalMass( void ) const; //!< Get the sum of the masses of this node and all subnodes 24 25 protected: 26 void recalcMass(); //!< Recalculate the mass of the children 27 float mass; //!< Mass of this node 28 float massChildren; //!< Sum of the masses of the children nodes 29 22 30 23 31 private: 24 32 25 33 26 34 }; -
orxonox/branches/physics/src/util/physics/physics_engine.cc
r4003 r4121 18 18 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY 19 19 20 #include "p roto_class.h"20 #include "physics_engine.h" 21 21 22 22 #include "stdincl.h" // maybe … … 29 29 \todo this constructor is not jet implemented - do it 30 30 */ 31 P rotoClass::ProtoClass()31 PhysicsEngine::PhysicsEngine () 32 32 { 33 this->setClassName ("P rotoClass");33 this->setClassName ("PhysicsEngine"); 34 34 } 35 35 … … 39 39 40 40 */ 41 P rotoClass::~ProtoClass()41 PhysicsEngine::~PhysicsEngine () 42 42 { 43 43 // delete what has to be deleted here … … 51 51 this is just to show the doxygen abilities (this for example is an extension for a long comment) 52 52 */ 53 bool P rotoClass::doNonSense (int nothing) {}53 bool PhysicsEngine::doNonSense (int nothing) {} -
orxonox/branches/physics/src/util/physics/physics_engine.h
r4003 r4121 1 1 /*! 2 \file p roto_class.h2 \file physics_engine.h 3 3 \brief Definition of the proto class template, used quickly start work 4 4 \todo Example: this shows how to use simply add a Marker that here has to be done something. 5 5 6 The P rotoclassexists, to help you quikly getting the run for how to develop in orxonox.6 The PhysicsEngine exists, to help you quikly getting the run for how to develop in orxonox. 7 7 It is an example for the CODING-CONVENTION, and a starting-point for every class. 8 8 */ 9 9 10 #ifndef _P ROTO_CLASS_H11 #define _P ROTO_CLASS_H10 #ifndef _PHYSICS_ENGINE_H 11 #define _PHYSICS_ENGINE_H 12 12 13 #include "what realy has to be included"14 13 #include "base_object.h" 15 14 … … 24 23 here can be some longer description of this class 25 24 */ 26 class P rotoClass: public BaseObject {25 class PhysicsEngine : public BaseObject { 27 26 28 27 public: 29 P rotoClass();30 virtual ~P rotoClass();28 PhysicsEngine(); 29 virtual ~PhysicsEngine(); 31 30 32 31 bool doNonSense (int nothing); … … 37 36 }; 38 37 39 #endif /* _P ROTO_CLASS_H */38 #endif /* _PHYSICS_ENGINE_H */
Note: See TracChangeset
for help on using the changeset viewer.