/indra/newview/llemote.cpp
C++ | 143 lines | 65 code | 24 blank | 54 comment | 6 complexity | 03d7e950b02cf69dc50a8042dece74ca MD5 | raw file
Possible License(s): LGPL-2.1
1/** 2 * @file llemote.cpp 3 * @brief Implementation of LLEmote class 4 * 5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$ 6 * Second Life Viewer Source Code 7 * Copyright (C) 2010, Linden Research, Inc. 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public 11 * License as published by the Free Software Foundation; 12 * version 2.1 of the License only. 13 * 14 * This library is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public 20 * License along with this library; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 * 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA 24 * $/LicenseInfo$ 25 */ 26 27//----------------------------------------------------------------------------- 28// Header Files 29//----------------------------------------------------------------------------- 30#include "llviewerprecompiledheaders.h" 31 32#include "llemote.h" 33#include "llcharacter.h" 34#include "m3math.h" 35#include "llvoavatar.h" 36 37//----------------------------------------------------------------------------- 38// Constants 39//----------------------------------------------------------------------------- 40 41//----------------------------------------------------------------------------- 42// LLEmote() 43// Class Constructor 44//----------------------------------------------------------------------------- 45LLEmote::LLEmote(const LLUUID &id) : LLMotion(id) 46{ 47 mCharacter = NULL; 48 49 //RN: flag face joint as highest priority for now, until we implement a proper animation track 50 mJointSignature[0][LL_FACE_JOINT_NUM] = 0xff; 51 mJointSignature[1][LL_FACE_JOINT_NUM] = 0xff; 52 mJointSignature[2][LL_FACE_JOINT_NUM] = 0xff; 53} 54 55 56//----------------------------------------------------------------------------- 57// ~LLEmote() 58// Class Destructor 59//----------------------------------------------------------------------------- 60LLEmote::~LLEmote() 61{ 62} 63 64//----------------------------------------------------------------------------- 65// LLEmote::onInitialize(LLCharacter *character) 66//----------------------------------------------------------------------------- 67LLMotion::LLMotionInitStatus LLEmote::onInitialize(LLCharacter *character) 68{ 69 mCharacter = character; 70 return STATUS_SUCCESS; 71} 72 73 74//----------------------------------------------------------------------------- 75// LLEmote::onActivate() 76//----------------------------------------------------------------------------- 77BOOL LLEmote::onActivate() 78{ 79 LLVisualParam* default_param = mCharacter->getVisualParam( "Express_Closed_Mouth" ); 80 if( default_param ) 81 { 82 default_param->setWeight( default_param->getMaxWeight(), FALSE ); 83 } 84 85 mParam = mCharacter->getVisualParam(mName.c_str()); 86 if (mParam) 87 { 88 mParam->setWeight(0.f, FALSE); 89 mCharacter->updateVisualParams(); 90 } 91 92 return TRUE; 93} 94 95 96//----------------------------------------------------------------------------- 97// LLEmote::onUpdate() 98//----------------------------------------------------------------------------- 99BOOL LLEmote::onUpdate(F32 time, U8* joint_mask) 100{ 101 if( mParam ) 102 { 103 F32 weight = mParam->getMinWeight() + mPose.getWeight() * (mParam->getMaxWeight() - mParam->getMinWeight()); 104 mParam->setWeight(weight, FALSE); 105 106 // Cross fade against the default parameter 107 LLVisualParam* default_param = mCharacter->getVisualParam( "Express_Closed_Mouth" ); 108 if( default_param ) 109 { 110 F32 default_param_weight = default_param->getMinWeight() + 111 (1.f - mPose.getWeight()) * ( default_param->getMaxWeight() - default_param->getMinWeight() ); 112 113 default_param->setWeight( default_param_weight, FALSE ); 114 } 115 116 mCharacter->updateVisualParams(); 117 } 118 119 return TRUE; 120} 121 122 123//----------------------------------------------------------------------------- 124// LLEmote::onDeactivate() 125//----------------------------------------------------------------------------- 126void LLEmote::onDeactivate() 127{ 128 if( mParam ) 129 { 130 mParam->setWeight( mParam->getDefaultWeight(), FALSE ); 131 } 132 133 LLVisualParam* default_param = mCharacter->getVisualParam( "Express_Closed_Mouth" ); 134 if( default_param ) 135 { 136 default_param->setWeight( default_param->getMaxWeight(), FALSE ); 137 } 138 139 mCharacter->updateVisualParams(); 140} 141 142 143// End