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