00001 /***************************************************************************** 00002 * $Id: rigidbody.h,v 1.4 2003/07/16 11:42:15 schou Exp $ 00003 * Author: Jakob Schou Jensen <schou@sourceforge.net> 00004 * Licence: GPL 00005 * 00006 * Description: Rigid body physics 00007 * 00008 ****************************************************************************/ 00009 00010 #ifndef RIGIDBODY_H 00011 #define RIGIDBODY_H 00012 00013 #include <adsomath.h> 00014 #include "object.h" 00015 00017 class RigidBody : public Object { 00018 protected: 00019 float mass; // mass M 00020 sqm3f Ibodyinv; // Inverse of Ibody 00021 00022 // State values 00023 v3f massPos; // Mass pos (center of mass) 00024 sqm3f R; // Rotation matrix 00025 v3f P; // Linear momentum 00026 v3f L; // Angular momentum 00027 00028 // Derived values 00029 sqm3f Iinv; // I(t) inverse 00030 v3f vel; // Linear velocity 00031 v3f omega; // Angular velocity 00032 00033 // External values 00034 v3f force; // Total force 00035 v3f torque; // Angular force 00036 00037 public: 00038 00039 void deStep(float dt); 00040 void impulse(v3f i, v3f relp); 00041 void movePoint(v3f r, v3f d); 00042 00043 sqm3f getRotationMatrix(){ return R; } 00044 v3f getMassPos(){ return massPos; } 00045 00046 RigidBody(){ 00047 mass = 1.0; 00048 Ibodyinv.ident(); 00049 massPos = v3f(0.0,0.0,0.0); 00050 R.ident(); 00051 P = v3f(0.0,0.0,0.0); 00052 L = v3f(0.0,0.0,0.0); 00053 } 00054 friend class State; 00055 friend class NetLink; 00056 }; 00057 00058 #endif
1.3.2