llpose.h

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

Generated on Fri May 16 08:32:00 2008 for SecondLife by  doxygen 1.5.5