Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10566 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 2.1 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#include "quaternion.h"
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  ObjectListDeclaration(PhysicsInterface);
32 public:
33  PhysicsInterface();
34  virtual ~PhysicsInterface();
35  /** @param mass the mass to set for this node. */
36  inline void setMass( float mass ) { this->mass = mass; };
37  /** @returns the mass of the node. */
38  inline float getMass( void ) const { return mass; };
39  /** @returns the mass of this node plus all its children (only valid for PNodes). */
40  inline float getTotalMass( void ) const { return mass + massChildren; };
41
42  /** @returns the velocity */
43  inline const Vector getVelocity() { return this->velocity; }
44  /** @returns the acceleration */
45  inline const Vector getAcceleration() { return this->acceleration; }
46
47  virtual void applyForce(const Vector& force);
48  virtual void applyField(Field* field);
49  virtual void tickPhys( float dt );
50
51 protected:
52  virtual void recalcMass();
53
54
55 private:
56  float          mass;                  //!< Mass of this object
57  float          massChildren;          //!< Sum of the masses of the children nodes
58
59  Vector         velocity;              //!< the velocity of the masspoint
60  Vector         acceleration;          //!< acceleration of the masspoint
61
62  Vector         forceSum;              //!< Total central force for this tick
63  Quaternion     momentumSum;           //!< Total momentum in this tick
64  bool           bForceApplied;         //!< If a force was applied to this object.
65};
66
67#endif /* _PHYSICS_INTERFACE_H */
Note: See TracBrowser for help on using the repository browser.