00001 00032 #ifndef LL_LLKEYFRAMEMOTIONPARAM_H 00033 #define LL_LLKEYFRAMEMOTIONPARAM_H 00034 00035 //----------------------------------------------------------------------------- 00036 // Header files 00037 //----------------------------------------------------------------------------- 00038 00039 #include <string> 00040 00041 #include "llmotion.h" 00042 #include "lljointstate.h" 00043 #include "v3math.h" 00044 #include "llquaternion.h" 00045 #include "linked_lists.h" 00046 #include "llkeyframemotion.h" 00047 00048 //----------------------------------------------------------------------------- 00049 // class LLKeyframeMotionParam 00050 //----------------------------------------------------------------------------- 00051 class LLKeyframeMotionParam : 00052 public LLMotion 00053 { 00054 public: 00055 // Constructor 00056 LLKeyframeMotionParam(const LLUUID &id); 00057 00058 // Destructor 00059 virtual ~LLKeyframeMotionParam(); 00060 00061 public: 00062 //------------------------------------------------------------------------- 00063 // functions to support MotionController and MotionRegistry 00064 //------------------------------------------------------------------------- 00065 00066 // static constructor 00067 // all subclasses must implement such a function and register it 00068 static LLMotion *create(const LLUUID &id) { return new LLKeyframeMotionParam(id); } 00069 00070 public: 00071 //------------------------------------------------------------------------- 00072 // animation callbacks to be implemented by subclasses 00073 //------------------------------------------------------------------------- 00074 00075 // motions must specify whether or not they loop 00076 virtual BOOL getLoop() { 00077 return TRUE; 00078 } 00079 00080 // motions must report their total duration 00081 virtual F32 getDuration() { 00082 return mDuration; 00083 } 00084 00085 // motions must report their "ease in" duration 00086 virtual F32 getEaseInDuration() { 00087 return mEaseInDuration; 00088 } 00089 00090 // motions must report their "ease out" duration. 00091 virtual F32 getEaseOutDuration() { 00092 return mEaseOutDuration; 00093 } 00094 00095 // motions must report their priority 00096 virtual LLJoint::JointPriority getPriority() { 00097 return mPriority; 00098 } 00099 00100 virtual LLMotionBlendType getBlendType() { return NORMAL_BLEND; } 00101 00102 // called to determine when a motion should be activated/deactivated based on avatar pixel coverage 00103 virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_KEYFRAME; } 00104 00105 // run-time (post constructor) initialization, 00106 // called after parameters have been set 00107 // must return true to indicate success and be available for activation 00108 virtual LLMotionInitStatus onInitialize(LLCharacter *character); 00109 00110 // called when a motion is activated 00111 // must return TRUE to indicate success, or else 00112 // it will be deactivated 00113 virtual BOOL onActivate(); 00114 00115 // called per time step 00116 // must return TRUE while it is active, and 00117 // must return FALSE when the motion is completed. 00118 virtual BOOL onUpdate(F32 time, U8* joint_mask); 00119 00120 // called when a motion is deactivated 00121 virtual void onDeactivate(); 00122 00123 virtual LLPose* getPose() { return mPoseBlender.getBlendedPose();} 00124 00125 protected: 00126 //------------------------------------------------------------------------- 00127 // new functions defined by this subclass 00128 //------------------------------------------------------------------------- 00129 typedef std::pair<LLMotion*, F32> ParameterizedMotion; 00130 00131 // add a motion and associated parameter triplet 00132 BOOL addKeyframeMotion(char *name, const LLUUID &id, char *param, F32 value); 00133 00134 // set default motion for LOD and retrieving blend constants 00135 void setDefaultKeyframeMotion(char *); 00136 00137 static BOOL sortFunc(ParameterizedMotion *new_motion, ParameterizedMotion *tested_motion); 00138 00139 BOOL loadMotions(); 00140 00141 protected: 00142 //------------------------------------------------------------------------- 00143 // Member Data 00144 //------------------------------------------------------------------------- 00145 00146 struct compare_motions 00147 { 00148 bool operator() (const ParameterizedMotion& a, const ParameterizedMotion& b) const 00149 { 00150 if (a.second != b.second) 00151 return (a.second < b.second); 00152 else 00153 return a.first < b.first; 00154 } 00155 }; 00156 00157 typedef std::set < ParameterizedMotion, compare_motions > motion_list_t; 00158 typedef std::map <std::string, motion_list_t > motion_map_t; 00159 motion_map_t mParameterizedMotions; 00160 LLMotion* mDefaultKeyframeMotion; 00161 LLCharacter* mCharacter; 00162 LLPoseBlender mPoseBlender; 00163 00164 F32 mEaseInDuration; 00165 F32 mEaseOutDuration; 00166 F32 mDuration; 00167 LLJoint::JointPriority mPriority; 00168 00169 LLUUID mTransactionID; 00170 }; 00171 00172 #endif // LL_LLKEYFRAMEMOTIONPARAM_H