Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/physics/physics_interface.h @ 5211

Last change on this file since 5211 was 5143, checked in by bensch, 19 years ago

orxonox/trunk: minor cleanup

File size: 1.7 KB
Line 
1/*!
2 * @file physics_interface.h
3  *  a physics interface simulating a body with a mass
4*/
5
6#ifndef _PHYSICS_INTERFACE_H
7#define _PHYSICS_INTERFACE_H
8
9#include "base_object.h"
10
11#include "vector.h"
12
13#ifndef NULL
14#define NULL 0          //!< NULL
15#endif
16
17// Forward Declaration
18class Field;
19
20//! A Physics interface
21/**
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
28*/
29class PhysicsInterface : virtual public BaseObject
30{
31 public:
32  PhysicsInterface();
33  virtual ~PhysicsInterface();
34  /** @param mass the mass to set for this node. */
35  inline void setMass( float mass ) { this->mass = mass; };
36  /** @returns the mass of the node. */
37  inline float getMass( void ) const { return mass; };
38  /** @returns the mass of this node plus all its children (only valid for PNodes). */
39  inline float getTotalMass( void ) const { return mass + massChildren; };
40
41  virtual void applyField(Field* field);
42  virtual void tickPhys( float dt );
43
44 protected:
45  virtual void recalcMass();
46
47
48 private:
49  float          mass;                  //!< Mass of this object
50  float          massChildren;          //!< Sum of the masses of the children nodes
51
52  Vector         forceSum;              //!< Total central force for this tick
53  Quaternion     momentumSum;           //!< Total momentum in this tick
54  bool           bForceApplied;         //!< If a force was applied to this object.
55};
56
57#endif /* _PHYSICS_INTERFACE_H */
Note: See TracBrowser for help on using the repository browser.