00001 00032 #ifndef LL_LLPOSE_H 00033 #define LL_LLPOSE_H 00034 00035 //----------------------------------------------------------------------------- 00036 // Header Files 00037 //----------------------------------------------------------------------------- 00038 #include <string> 00039 00040 #include "linked_lists.h" 00041 #include "llmap.h" 00042 #include "lljointstate.h" 00043 #include "llassoclist.h" 00044 #include "lljoint.h" 00045 #include <map> 00046 00047 00048 //----------------------------------------------------------------------------- 00049 // class LLPose 00050 //----------------------------------------------------------------------------- 00051 class LLPose 00052 { 00053 friend class LLPoseBlender; 00054 protected: 00055 typedef std::map<std::string, LLJointState*> joint_map; 00056 typedef joint_map::iterator joint_map_iterator; 00057 typedef joint_map::value_type joint_map_value_type; 00058 00059 joint_map mJointMap; 00060 F32 mWeight; 00061 joint_map_iterator mListIter; 00062 public: 00063 // Iterate through jointStates 00064 LLJointState *getFirstJointState(); 00065 LLJointState *getNextJointState(); 00066 LLJointState *findJointState(LLJoint *joint); 00067 LLJointState *findJointState(const std::string &name); 00068 public: 00069 // Constructor 00070 LLPose() : mWeight(0.f) {} 00071 // Destructor 00072 ~LLPose(); 00073 // add a joint state in this pose 00074 BOOL addJointState(LLJointState *jointState); 00075 // remove a joint state from this pose 00076 BOOL removeJointState(LLJointState *jointState); 00077 // removes all joint states from this pose 00078 BOOL removeAllJointStates(); 00079 // set weight for all joint states in this pose 00080 void setWeight(F32 weight); 00081 // get weight for this pose 00082 F32 getWeight() const; 00083 // returns number of joint states stored in this pose 00084 S32 getNumJointStates() const; 00085 }; 00086 00087 const S32 JSB_NUM_JOINT_STATES = 6; 00088 00089 class LLJointStateBlender 00090 { 00091 protected: 00092 LLJointState* mJointStates[JSB_NUM_JOINT_STATES]; 00093 S32 mPriorities[JSB_NUM_JOINT_STATES]; 00094 BOOL mAdditiveBlends[JSB_NUM_JOINT_STATES]; 00095 public: 00096 LLJointStateBlender(); 00097 ~LLJointStateBlender(); 00098 void blendJointStates(BOOL apply_now = TRUE); 00099 BOOL addJointState(LLJointState *joint_state, S32 priority, BOOL additive_blend); 00100 void interpolate(F32 u); 00101 void clear(); 00102 void resetCachedJoint(); 00103 00104 public: 00105 LLJoint mJointCache; 00106 }; 00107 00108 class LLMotion; 00109 00110 class LLPoseBlender 00111 { 00112 protected: 00113 typedef std::list<LLJointStateBlender*> blender_list_t; 00114 typedef std::map<LLJoint*,LLJointStateBlender*> blender_map_t; 00115 blender_map_t mJointStateBlenderPool; 00116 blender_list_t mActiveBlenders; 00117 00118 S32 mNextPoseSlot; 00119 LLPose mBlendedPose; 00120 public: 00121 // Constructor 00122 LLPoseBlender(); 00123 // Destructor 00124 ~LLPoseBlender(); 00125 00126 // request motion joint states to be added to pose blender joint state records 00127 BOOL addMotion(LLMotion* motion); 00128 00129 // blend all joint states and apply to skeleton 00130 void blendAndApply(); 00131 00132 // removes all joint state blenders from last time 00133 void clearBlenders(); 00134 00135 // blend all joint states and cache results 00136 void blendAndCache(BOOL reset_cached_joints); 00137 00138 // interpolate all joints towards cached values 00139 void interpolate(F32 u); 00140 00141 LLPose* getBlendedPose() { return &mBlendedPose; } 00142 }; 00143 00144 #endif // LL_LLPOSE_H 00145