[4555] | 1 | /*! |
---|
[5039] | 2 | * @file physics_interface.h |
---|
[4836] | 3 | * a physics interface simulating a body with a mass |
---|
[3954] | 4 | */ |
---|
| 5 | |
---|
[4375] | 6 | #ifndef _PHYSICS_INTERFACE_H |
---|
| 7 | #define _PHYSICS_INTERFACE_H |
---|
[3954] | 8 | |
---|
[4376] | 9 | #include "vector.h" |
---|
[4377] | 10 | #include "base_object.h" |
---|
[3954] | 11 | |
---|
[4397] | 12 | #ifndef NULL |
---|
[4480] | 13 | #define NULL 0 //!< NULL |
---|
[4397] | 14 | #endif |
---|
| 15 | |
---|
[4377] | 16 | // Forward Declaration |
---|
| 17 | class Field; |
---|
| 18 | |
---|
[3961] | 19 | //! A Physics interface |
---|
[3954] | 20 | /** |
---|
[4395] | 21 | The PhysicsInterface is an extension to Any other object, |
---|
| 22 | that can be used to turn it to be Physcally animated. |
---|
| 23 | Still you have to connect fields. |
---|
| 24 | IMPORTANT is, that when using PNodes this baseclass is ok. |
---|
| 25 | BUT, when using any other class that does not by itself implement |
---|
| 26 | PNode you __MUST__ implement all the virtual functions by your own |
---|
[3954] | 27 | */ |
---|
[4382] | 28 | class PhysicsInterface : virtual public BaseObject |
---|
[4377] | 29 | { |
---|
[3954] | 30 | public: |
---|
[4762] | 31 | PhysicsInterface(); |
---|
[4375] | 32 | virtual ~PhysicsInterface(); |
---|
[4836] | 33 | /** @param mass the mass to set for this node. */ |
---|
[4376] | 34 | inline void setMass( float mass ) { this->mass = mass; }; |
---|
[4836] | 35 | /** @returns the mass of the node. */ |
---|
[4376] | 36 | inline float getMass( void ) const { return mass; }; |
---|
[4836] | 37 | /** @returns the mass of this node plus all its children (only valid for PNodes). */ |
---|
[4376] | 38 | inline float getTotalMass( void ) const { return mass + massChildren; }; |
---|
[3954] | 39 | |
---|
[4395] | 40 | virtual void applyField(Field* field); |
---|
[4377] | 41 | virtual void tickPhys( float dt ); |
---|
[4376] | 42 | |
---|
[4121] | 43 | protected: |
---|
[4395] | 44 | virtual void recalcMass(); |
---|
[4376] | 45 | |
---|
[4555] | 46 | |
---|
[4376] | 47 | private: |
---|
[4555] | 48 | float mass; //!< Mass of this object |
---|
| 49 | float massChildren; //!< Sum of the masses of the children nodes |
---|
[4558] | 50 | |
---|
[4555] | 51 | Vector forceSum; //!< Total central force for this tick |
---|
| 52 | Quaternion momentumSum; //!< Total momentum in this tick |
---|
[4558] | 53 | bool bForceApplied; //!< If a force was applied to this object. |
---|
[3954] | 54 | }; |
---|
| 55 | |
---|
[4375] | 56 | #endif /* _PHYSICS_INTERFACE_H */ |
---|