/*! \file IPhys.h \brief Interface to physics engine */ #ifndef IPHYS_H #define IPHYS_H #include "stdincl.h" //! Avaiable types of behaviour for a physical object. Mainly determines which //! attributes are used and what calculations are done. enum IPHYS_BEHAVIOUR { // Bodies B_MASS_POINT, //!< Body: No orientation, just a inf. small mass B_RIGID_BODY, //!< Body: Rigid Body, lossless bumping B_ELAST_BODY, //!< Body: Rigid, lossy bumping // Interactions I_SPRING_LINEAR, //!< Interaction: Linear, ideal spring I_DMPSPR_LINEAR, //!< Interaction: Linear, damped spring I_SPRING_MOMENTUM, //!< Interaction: Momentum spring, ideal I_DMPSPR_MOMENTUM, //!< Interaction: Momentum spring, damped // Fields F_GRAVITY, //!< Field: Gravity field in some direction F_HOVER, //!< Field: Something like antigravity (hover drive) F_SHOCKWAVE, //!< Field: Cylindrical Shockwave F_BEAM //!< Field: Electromagnetic beam (exerts pressure on intersecting objects) }; class IPhys { public: IPhys (); ~IPhys (); // Simulation void simIterate(Uint32 deltaT); // Exertion of external forces void exertForce( Vector force ); void exertMomentum( Vector Momentum ); // set attributes void setBehaviour( IPHYS_BEHAVIOUR desiredBehaviour ); void setBody( float mass ); void setBody( float mass, float inertMoment[] ); void setBody( float mass, float inertMoment[], float YoungsModulus ); void setMounts( WorldEntity *point1, WorldEntity *point2 ); void setSpring( float neutralLength, float springConst ); void setSpring( float neutralLength, float springConst, float damping ); void setSpring( Quaternion neutralOrientation, float springConst ); void setSpring( Quaternion neutralOrientation, float springConst, float damping ); //void setInfluence //void setGravity // get attributes Placement getPlacement() ; float getMass(); float* getInertMoment(); private: IPHYS_BEHAVIOUR behav; //!< Behaviour Vector pos; //!< Position Quaternion ori; //!< Orientation Vector vel; //!< Velocity Quaternion rot; //!< Rotation Vector resForce; //!< Resulting force Vector resMomentum; //!< Resulting Momentum // Attributes for bodies float m; //!< Mass float inertM[3,3]; //!< Inertial Moment Matrix float YE; //!< Youngs Modulus E (Elasticity) // Attributes for interactions WorldEntity* mounts[2]; //!< Mounts; meaning depends on obj. behaviour float spNeutralL; //!< Spring neutral length float spConst; //!< Spring constant k float dmp; //!< Damping Quaternion mspNeutralOri; //!< Momentum spring neutral orientation }; #endif