1 | /*! |
---|
2 | \file IPhys.h |
---|
3 | \brief Interface to physics engine |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef IPHYS_H |
---|
7 | #define IPHYS_H |
---|
8 | |
---|
9 | #include "stdincl.h" |
---|
10 | |
---|
11 | //! Avaiable types of behaviour for a physical object. Mainly determines which |
---|
12 | //! attributes are used and what calculations are done. |
---|
13 | enum IPHYS_BEHAVIOUR { |
---|
14 | // Bodies |
---|
15 | B_MASS_POINT, //!< Body: No orientation, just a inf. small mass |
---|
16 | B_RIGID_BODY, //!< Body: Rigid Body, lossless bumping |
---|
17 | B_ELAST_BODY, //!< Body: Rigid, lossy bumping |
---|
18 | // Interactions |
---|
19 | I_SPRING_LINEAR, //!< Interaction: Linear, ideal spring |
---|
20 | I_DMPSPR_LINEAR, //!< Interaction: Linear, damped spring |
---|
21 | I_SPRING_MOMENTUM, //!< Interaction: Momentum spring, ideal |
---|
22 | I_DMPSPR_MOMENTUM, //!< Interaction: Momentum spring, damped |
---|
23 | // Fields |
---|
24 | F_GRAVITY, //!< Field: Gravity field in some direction |
---|
25 | F_HOVER, //!< Field: Something like antigravity (hover drive) |
---|
26 | F_SHOCKWAVE, //!< Field: Cylindrical Shockwave |
---|
27 | F_BEAM //!< Field: Electromagnetic beam (exerts pressure on intersecting objects) |
---|
28 | }; |
---|
29 | |
---|
30 | class IPhys |
---|
31 | { |
---|
32 | public: |
---|
33 | IPhys (); |
---|
34 | ~IPhys (); |
---|
35 | |
---|
36 | // Simulation |
---|
37 | void simIterate(Uint32 deltaT); |
---|
38 | |
---|
39 | // Exertion of external forces |
---|
40 | void exertForce( Vector force ); |
---|
41 | void exertMomentum( Vector Momentum ); |
---|
42 | |
---|
43 | // set attributes |
---|
44 | void setBehaviour( IPHYS_BEHAVIOUR desiredBehaviour ); |
---|
45 | void setBody( float mass ); |
---|
46 | void setBody( float mass, float inertMoment[] ); |
---|
47 | void setBody( float mass, float inertMoment[], float YoungsModulus ); |
---|
48 | |
---|
49 | void setMounts( WorldEntity *point1, WorldEntity *point2 ); |
---|
50 | void setSpring( float neutralLength, float springConst ); |
---|
51 | void setSpring( float neutralLength, float springConst, float damping ); |
---|
52 | void setSpring( Quaternion neutralOrientation, float springConst ); |
---|
53 | void setSpring( Quaternion neutralOrientation, float springConst, float damping ); |
---|
54 | |
---|
55 | //void setInfluence |
---|
56 | //void setGravity |
---|
57 | |
---|
58 | // get attributes |
---|
59 | Placement getPlacement() ; |
---|
60 | float getMass(); |
---|
61 | float* getInertMoment(); |
---|
62 | |
---|
63 | |
---|
64 | private: |
---|
65 | IPHYS_BEHAVIOUR behav; //!< Behaviour |
---|
66 | Vector pos; //!< Position |
---|
67 | Quaternion ori; //!< Orientation |
---|
68 | |
---|
69 | Vector vel; //!< Velocity |
---|
70 | Quaternion rot; //!< Rotation |
---|
71 | |
---|
72 | Vector resForce; //!< Resulting force |
---|
73 | Vector resMomentum; //!< Resulting Momentum |
---|
74 | |
---|
75 | // Attributes for bodies |
---|
76 | float m; //!< Mass |
---|
77 | float inertM[3,3]; //!< Inertial Moment Matrix |
---|
78 | float YE; //!< Youngs Modulus E (Elasticity) |
---|
79 | |
---|
80 | // Attributes for interactions |
---|
81 | WorldEntity* mounts[2]; //!< Mounts; meaning depends on obj. behaviour |
---|
82 | float spNeutralL; //!< Spring neutral length |
---|
83 | float spConst; //!< Spring constant k |
---|
84 | float dmp; //!< Damping |
---|
85 | Quaternion mspNeutralOri; //!< Momentum spring neutral orientation |
---|
86 | |
---|
87 | |
---|
88 | }; |
---|
89 | |
---|
90 | #endif |
---|