00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __CT_RIGIDBODY_H__
00022 #define __CT_RIGIDBODY_H__
00023
00024 #include "csphyzik/phyzent.h"
00025 #include "csphyzik/phyztype.h"
00026
00027 #define RBSTATESIZE (6 + PHYSICALENTITY_STATESIZE)
00028 struct iObjectRegistry;
00029
00031 class ctRigidBody : public ctDynamicEntity
00032 {
00033 public:
00034
00035
00036
00037 ctRigidBody();
00038 ctRigidBody( ctReferenceFrame &ref, ctDeltaReferenceFrame &dref );
00039
00040 virtual ~ctRigidBody();
00041
00043 static ctRigidBody *new_ctRigidBody ();
00045 static ctRigidBody *new_ctRigidBody ( coord x, coord y, coord z );
00047 static int get_RB_state_size ()
00048 { return RBSTATESIZE; }
00049
00050
00051 iObjectRegistry *object_reg;
00052
00053
00054
00055
00060 void calc_simple_I_tensor( real width, real height, real depth );
00061
00063 const ctMatrix3 &get_I ()
00064 { return I; }
00065
00067 const ctMatrix3 &get_I_inv ()
00068 { return I_inv; }
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 ctMatrix3 get_I_inv_world ()
00085 {
00086 const ctMatrix3 &R = RF.get_R();
00087 ctMatrix3 I_inv_world;
00088 R.similarity_transform( I_inv_world, I_inv );
00089 return I_inv_world;
00090 }
00091
00092 ctMatrix3 get_I_world ()
00093 {
00094 const ctMatrix3 &R = RF.get_R();
00095 ctMatrix3 I_world;
00096 R.similarity_transform( I_world, I );
00097 return I_world;
00098 }
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 virtual void get_impulse_m_and_I_inv ( real *pm, ctMatrix3 *pI_inv,
00111 const ctVector3 &impulse_point, const ctVector3 &unit_length_impulse_vector )
00112 {
00113 (void)unit_length_impulse_vector;
00114 (void)impulse_point;
00115 *pm = m;
00116 const ctMatrix3 &R = RF.get_R();
00117 R.similarity_transform( *pI_inv, I_inv );
00118 }
00119
00121 ctVector3 get_angular_P ()
00122 { return L; }
00123
00124 ctVector3 get_P ()
00125 { return P; }
00126
00128 virtual int get_state_size () { return RBSTATESIZE; }
00129 virtual int set_state ( real *state_array );
00130 virtual int get_state ( const real *state_array );
00131 virtual int set_delta_state ( real *state_array );
00132 virtual void set_angular_v ( const ctVector3 &pw );
00133 virtual void set_v ( const ctVector3 &pv );
00134 virtual void add_angular_v ( const ctVector3 &pw );
00135 virtual void add_v ( const ctVector3 &pv );
00136 virtual void set_m ( real pm );
00137
00142 virtual void apply_impulse( ctVector3 impulse_point, ctVector3 impulse_vector );
00143
00144 protected:
00146 ctVector3 P;
00148 ctVector3 L;
00150 ctMatrix3 I;
00152 ctMatrix3 I_inv;
00153
00154 };
00155
00156 #endif // __CT_RIGIDBODY_H__