llemote.cpp

Go to the documentation of this file.
00001 
00032 //-----------------------------------------------------------------------------
00033 // Header Files
00034 //-----------------------------------------------------------------------------
00035 #include "llviewerprecompiledheaders.h"
00036 
00037 #include "llemote.h"
00038 #include "llcharacter.h"
00039 #include "m3math.h"
00040 #include "llvoavatar.h"
00041 #include "llagent.h"
00042 
00043 //-----------------------------------------------------------------------------
00044 // Constants
00045 //-----------------------------------------------------------------------------
00046 
00047 //-----------------------------------------------------------------------------
00048 // LLEmote()
00049 // Class Constructor
00050 //-----------------------------------------------------------------------------
00051 LLEmote::LLEmote(const LLUUID &id) : LLMotion(id)
00052 {
00053         mCharacter = NULL;
00054 
00055         //RN: flag face joint as highest priority for now, until we implement a proper animation track
00056         mJointSignature[0][LL_FACE_JOINT_NUM] = 0xff;
00057         mJointSignature[1][LL_FACE_JOINT_NUM] = 0xff;
00058         mJointSignature[2][LL_FACE_JOINT_NUM] = 0xff;
00059 }
00060 
00061 
00062 //-----------------------------------------------------------------------------
00063 // ~LLEmote()
00064 // Class Destructor
00065 //-----------------------------------------------------------------------------
00066 LLEmote::~LLEmote()
00067 {
00068 }
00069 
00070 //-----------------------------------------------------------------------------
00071 // LLEmote::onInitialize(LLCharacter *character)
00072 //-----------------------------------------------------------------------------
00073 LLMotion::LLMotionInitStatus LLEmote::onInitialize(LLCharacter *character)
00074 {
00075         mCharacter = character;
00076         return STATUS_SUCCESS;
00077 }
00078 
00079 
00080 //-----------------------------------------------------------------------------
00081 // LLEmote::onActivate()
00082 //-----------------------------------------------------------------------------
00083 BOOL LLEmote::onActivate()
00084 {
00085         LLVisualParam* default_param = mCharacter->getVisualParam( "Express_Closed_Mouth" );
00086         if( default_param )
00087         {
00088                 default_param->setWeight( default_param->getMaxWeight(), FALSE );
00089         }
00090 
00091         mParam = mCharacter->getVisualParam(mName.c_str());
00092         if (mParam)
00093         {
00094                 mParam->setWeight(0.f, FALSE);
00095                 mCharacter->updateVisualParams();
00096         }
00097         
00098         return TRUE;
00099 }
00100 
00101 
00102 //-----------------------------------------------------------------------------
00103 // LLEmote::onUpdate()
00104 //-----------------------------------------------------------------------------
00105 BOOL LLEmote::onUpdate(F32 time, U8* joint_mask)
00106 {
00107         if( mParam )
00108         {
00109                 F32 weight = mParam->getMinWeight() + mPose.getWeight() * (mParam->getMaxWeight() - mParam->getMinWeight());
00110                 mParam->setWeight(weight, FALSE);
00111 
00112                 // Cross fade against the default parameter
00113                 LLVisualParam* default_param = mCharacter->getVisualParam( "Express_Closed_Mouth" );
00114                 if( default_param )
00115                 {
00116                         F32 default_param_weight = default_param->getMinWeight() + 
00117                                 (1.f - mPose.getWeight()) * ( default_param->getMaxWeight() - default_param->getMinWeight() );
00118                         
00119                         default_param->setWeight( default_param_weight, FALSE );
00120                 }
00121 
00122                 mCharacter->updateVisualParams();
00123         }
00124 
00125         return TRUE;
00126 }
00127 
00128 
00129 //-----------------------------------------------------------------------------
00130 // LLEmote::onDeactivate()
00131 //-----------------------------------------------------------------------------
00132 void LLEmote::onDeactivate()
00133 {
00134         if( mParam )
00135         {
00136                 mParam->setWeight( mParam->getDefaultWeight(), FALSE );
00137         }
00138 
00139         LLVisualParam* default_param = mCharacter->getVisualParam( "Express_Closed_Mouth" );
00140         if( default_param )
00141         {
00142                 default_param->setWeight( default_param->getMaxWeight(), FALSE );
00143         }
00144 
00145         mCharacter->updateVisualParams();
00146 }
00147 
00148 
00149 // End

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