llheadrotmotion.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLHEADROTMOTION_H
00033 #define LL_LLHEADROTMOTION_H
00034 
00035 //-----------------------------------------------------------------------------
00036 // Header files
00037 //-----------------------------------------------------------------------------
00038 #include "llmotion.h"
00039 #include "llframetimer.h"
00040 
00041 #define MIN_REQUIRED_PIXEL_AREA_HEAD_ROT 500.f;
00042 #define MIN_REQUIRED_PIXEL_AREA_EYE 25000.f;
00043 
00044 //-----------------------------------------------------------------------------
00045 // class LLHeadRotMotion
00046 //-----------------------------------------------------------------------------
00047 class LLHeadRotMotion :
00048         public LLMotion
00049 {
00050 public:
00051         // Constructor
00052         LLHeadRotMotion(const LLUUID &id);
00053 
00054         // Destructor
00055         virtual ~LLHeadRotMotion();
00056 
00057 public:
00058         //-------------------------------------------------------------------------
00059         // functions to support MotionController and MotionRegistry
00060         //-------------------------------------------------------------------------
00061 
00062         // static constructor
00063         // all subclasses must implement such a function and register it
00064         static LLMotion *create(const LLUUID &id) { return new LLHeadRotMotion(id); }
00065 
00066 public:
00067         //-------------------------------------------------------------------------
00068         // animation callbacks to be implemented by subclasses
00069         //-------------------------------------------------------------------------
00070 
00071         // motions must specify whether or not they loop
00072         virtual BOOL getLoop() { return TRUE; }
00073 
00074         // motions must report their total duration
00075         virtual F32 getDuration() { return 0.0; }
00076 
00077         // motions must report their "ease in" duration
00078         virtual F32 getEaseInDuration() { return 1.f; }
00079 
00080         // motions must report their "ease out" duration.
00081         virtual F32 getEaseOutDuration() { return 1.f; }
00082 
00083         // called to determine when a motion should be activated/deactivated based on avatar pixel coverage
00084         virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_HEAD_ROT; }
00085 
00086         // motions must report their priority
00087         virtual LLJoint::JointPriority getPriority() { return LLJoint::MEDIUM_PRIORITY; }
00088 
00089         virtual LLMotionBlendType getBlendType() { return NORMAL_BLEND; }
00090 
00091         // run-time (post constructor) initialization,
00092         // called after parameters have been set
00093         // must return true to indicate success and be available for activation
00094         virtual LLMotionInitStatus onInitialize(LLCharacter *character);
00095 
00096         // called when a motion is activated
00097         // must return TRUE to indicate success, or else
00098         // it will be deactivated
00099         virtual BOOL onActivate();
00100 
00101         // called per time step
00102         // must return TRUE while it is active, and
00103         // must return FALSE when the motion is completed.
00104         virtual BOOL onUpdate(F32 time, U8* joint_mask);
00105 
00106         // called when a motion is deactivated
00107         virtual void onDeactivate();
00108 
00109 public:
00110         //-------------------------------------------------------------------------
00111         // joint states to be animated
00112         //-------------------------------------------------------------------------
00113         LLCharacter                     *mCharacter;
00114 
00115         LLJoint                         *mTorsoJoint;
00116         LLJoint                         *mHeadJoint;
00117         LLJoint                         *mRootJoint;
00118         LLJoint                         *mPelvisJoint;
00119 
00120         LLJointState            mTorsoState;
00121         LLJointState            mNeckState;
00122         LLJointState            mHeadState;
00123 
00124         LLQuaternion            mLastHeadRot;
00125 };
00126 
00127 //-----------------------------------------------------------------------------
00128 // class LLEyeMotion
00129 //-----------------------------------------------------------------------------
00130 class LLEyeMotion :
00131         public LLMotion
00132 {
00133 public:
00134         // Constructor
00135         LLEyeMotion(const LLUUID &id);
00136 
00137         // Destructor
00138         virtual ~LLEyeMotion();
00139 
00140 public:
00141         //-------------------------------------------------------------------------
00142         // functions to support MotionController and MotionRegistry
00143         //-------------------------------------------------------------------------
00144 
00145         // static constructor
00146         // all subclasses must implement such a function and register it
00147         static LLMotion *create( const LLUUID &id) { return new LLEyeMotion(id); }
00148 
00149 public:
00150         //-------------------------------------------------------------------------
00151         // animation callbacks to be implemented by subclasses
00152         //-------------------------------------------------------------------------
00153 
00154         // motions must specify whether or not they loop
00155         virtual BOOL getLoop() { return TRUE; }
00156 
00157         // motions must report their total duration
00158         virtual F32 getDuration() { return 0.0; }
00159 
00160         // motions must report their "ease in" duration
00161         virtual F32 getEaseInDuration() { return 0.5f; }
00162 
00163         // motions must report their "ease out" duration.
00164         virtual F32 getEaseOutDuration() { return 0.5f; }
00165 
00166         // called to determine when a motion should be activated/deactivated based on avatar pixel coverage
00167         virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_EYE; }
00168 
00169         // motions must report their priority
00170         virtual LLJoint::JointPriority getPriority() { return LLJoint::MEDIUM_PRIORITY; }
00171 
00172         virtual LLMotionBlendType getBlendType() { return NORMAL_BLEND; }
00173 
00174         // run-time (post constructor) initialization,
00175         // called after parameters have been set
00176         // must return true to indicate success and be available for activation
00177         virtual LLMotionInitStatus onInitialize(LLCharacter *character);
00178 
00179         // called when a motion is activated
00180         // must return TRUE to indicate success, or else
00181         // it will be deactivated
00182         virtual BOOL onActivate();
00183 
00184         // called per time step
00185         // must return TRUE while it is active, and
00186         // must return FALSE when the motion is completed.
00187         virtual BOOL onUpdate(F32 time, U8* joint_mask);
00188 
00189         // called when a motion is deactivated
00190         virtual void onDeactivate();
00191 
00192 public:
00193         //-------------------------------------------------------------------------
00194         // joint states to be animated
00195         //-------------------------------------------------------------------------
00196         LLCharacter                     *mCharacter;
00197 
00198         LLJoint                         *mHeadJoint;
00199         LLJointState            mLeftEyeState;
00200         LLJointState            mRightEyeState;
00201 
00202         LLFrameTimer            mEyeJitterTimer;
00203         F32                                     mEyeJitterTime;
00204         F32                                     mEyeJitterYaw;
00205         F32                                     mEyeJitterPitch;
00206         F32                                     mEyeLookAwayTime;
00207         F32                                     mEyeLookAwayYaw;
00208         F32                                     mEyeLookAwayPitch;
00209 
00210         // eye blinking
00211         LLFrameTimer            mEyeBlinkTimer;
00212         F32                                     mEyeBlinkTime;
00213         BOOL                            mEyesClosed;
00214 };
00215 
00216 #endif // LL_LLHEADROTMOTION_H
00217 

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