lljoint.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLJOINT_H
00033 #define LL_LLJOINT_H
00034 
00035 //-----------------------------------------------------------------------------
00036 // Header Files
00037 //-----------------------------------------------------------------------------
00038 #include <string>
00039 
00040 #include "linked_lists.h"
00041 #include "v3math.h"
00042 #include "v4math.h"
00043 #include "m4math.h"
00044 #include "llquaternion.h"
00045 #include "xform.h"
00046 #include "lldarray.h"
00047 
00048 const S32 LL_CHARACTER_MAX_JOINTS_PER_MESH = 15;
00049 const U32 LL_CHARACTER_MAX_JOINTS = 32; // must be divisible by 4!
00050 const U32 LL_HAND_JOINT_NUM = 31;
00051 const U32 LL_FACE_JOINT_NUM = 30;
00052 const S32 LL_CHARACTER_MAX_PRIORITY = 7;
00053 const F32 LL_MAX_PELVIS_OFFSET = 5.f;
00054 
00055 //-----------------------------------------------------------------------------
00056 // class LLJoint
00057 //-----------------------------------------------------------------------------
00058 class LLJoint
00059 {
00060 public:
00061         // priority levels, from highest to lowest
00062         enum JointPriority
00063         {
00064                 USE_MOTION_PRIORITY = -1,
00065                 LOW_PRIORITY = 0,
00066                 MEDIUM_PRIORITY,
00067                 HIGH_PRIORITY,
00068                 HIGHER_PRIORITY,
00069                 HIGHEST_PRIORITY,
00070                 ADDITIVE_PRIORITY = LL_CHARACTER_MAX_PRIORITY
00071         };
00072 
00073         enum DirtyFlags
00074         {
00075                 MATRIX_DIRTY = 0x1 << 0,
00076                 ROTATION_DIRTY = 0x1 << 1,
00077                 POSITION_DIRTY = 0x1 << 2,
00078                 ALL_DIRTY = 0x7
00079         };
00080 protected:
00081         std::string     mName;
00082 
00083         // parent joint
00084         LLJoint *mParent;
00085 
00086         // explicit transformation members
00087         LLXformMatrix           mXform;
00088 
00089 public:
00090         U32                             mDirtyFlags;
00091         BOOL                    mUpdateXform;
00092 
00093         // describes the skin binding pose
00094         LLVector3               mSkinOffset;
00095 
00096         S32                             mJointNum;
00097 
00098         // child joints
00099         typedef std::list<LLJoint*> child_list_t;
00100         child_list_t mChildren;
00101 
00102         // debug statics
00103         static S32              sNumTouches;
00104         static S32              sNumUpdates;
00105 
00106 public:
00107         LLJoint();
00108         LLJoint( const std::string &name, LLJoint *parent=NULL );
00109 
00110         virtual ~LLJoint();
00111 
00112         // set name and parent
00113         void setup( const std::string &name, LLJoint *parent=NULL );
00114 
00115         void touch(U32 flags = ALL_DIRTY);
00116 
00117         // get/set name
00118         const std::string &getName() { return mName; }
00119         void setName( const std::string &name ) { mName = name; }
00120 
00121         // getParent
00122         LLJoint *getParent() { return mParent; }
00123 
00124         // getRoot
00125         LLJoint *getRoot();
00126 
00127         // search for child joints by name
00128         LLJoint *findJoint( const std::string &name );
00129 
00130         // add/remove children
00131         void addChild( LLJoint *joint );
00132         void removeChild( LLJoint *joint );
00133         void removeAllChildren();
00134 
00135         // get/set local position
00136         const LLVector3& getPosition();
00137         void setPosition( const LLVector3& pos );
00138 
00139         // get/set world position
00140         LLVector3 getWorldPosition();
00141         LLVector3 getLastWorldPosition();
00142         void setWorldPosition( const LLVector3& pos );
00143 
00144         // get/set local rotation
00145         const LLQuaternion& getRotation();
00146         void setRotation( const LLQuaternion& rot );
00147 
00148         // get/set world rotation
00149         LLQuaternion getWorldRotation();
00150         LLQuaternion getLastWorldRotation();
00151         void setWorldRotation( const LLQuaternion& rot );
00152 
00153         // get/set local scale
00154         const LLVector3& getScale();
00155         void setScale( const LLVector3& scale );
00156 
00157         // get/set world matrix
00158         const LLMatrix4 &getWorldMatrix();
00159         void setWorldMatrix( const LLMatrix4& mat );
00160 
00161         void updateWorldMatrixChildren();
00162         void updateWorldMatrixParent();
00163 
00164         void updateWorldPRSParent();
00165 
00166         void updateWorldMatrix();
00167 
00168         // get/set skin offset
00169         const LLVector3 &getSkinOffset();
00170         void setSkinOffset( const LLVector3 &offset);
00171 
00172         LLXformMatrix   *getXform() { return &mXform; }
00173 
00174         void clampRotation(LLQuaternion old_rot, LLQuaternion new_rot);
00175 
00176         virtual BOOL isAnimatable() { return TRUE; }
00177 
00178         S32 getJointNum() { return mJointNum; }
00179         void setJointNum(S32 joint_num) { mJointNum = joint_num; }
00180 };
00181 #endif // LL_LLJOINT_H
00182 

Generated on Thu Jul 1 06:08:47 2010 for Second Life Viewer by  doxygen 1.4.7