/indra/newview/llemote.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 143 lines · 65 code · 24 blank · 54 comment · 6 complexity · 03d7e950b02cf69dc50a8042dece74ca MD5 · raw file

  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. // Header Files
  28. //-----------------------------------------------------------------------------
  29. #include "llviewerprecompiledheaders.h"
  30. #include "llemote.h"
  31. #include "llcharacter.h"
  32. #include "m3math.h"
  33. #include "llvoavatar.h"
  34. //-----------------------------------------------------------------------------
  35. // Constants
  36. //-----------------------------------------------------------------------------
  37. //-----------------------------------------------------------------------------
  38. // LLEmote()
  39. // Class Constructor
  40. //-----------------------------------------------------------------------------
  41. LLEmote::LLEmote(const LLUUID &id) : LLMotion(id)
  42. {
  43. mCharacter = NULL;
  44. //RN: flag face joint as highest priority for now, until we implement a proper animation track
  45. mJointSignature[0][LL_FACE_JOINT_NUM] = 0xff;
  46. mJointSignature[1][LL_FACE_JOINT_NUM] = 0xff;
  47. mJointSignature[2][LL_FACE_JOINT_NUM] = 0xff;
  48. }
  49. //-----------------------------------------------------------------------------
  50. // ~LLEmote()
  51. // Class Destructor
  52. //-----------------------------------------------------------------------------
  53. LLEmote::~LLEmote()
  54. {
  55. }
  56. //-----------------------------------------------------------------------------
  57. // LLEmote::onInitialize(LLCharacter *character)
  58. //-----------------------------------------------------------------------------
  59. LLMotion::LLMotionInitStatus LLEmote::onInitialize(LLCharacter *character)
  60. {
  61. mCharacter = character;
  62. return STATUS_SUCCESS;
  63. }
  64. //-----------------------------------------------------------------------------
  65. // LLEmote::onActivate()
  66. //-----------------------------------------------------------------------------
  67. BOOL LLEmote::onActivate()
  68. {
  69. LLVisualParam* default_param = mCharacter->getVisualParam( "Express_Closed_Mouth" );
  70. if( default_param )
  71. {
  72. default_param->setWeight( default_param->getMaxWeight(), FALSE );
  73. }
  74. mParam = mCharacter->getVisualParam(mName.c_str());
  75. if (mParam)
  76. {
  77. mParam->setWeight(0.f, FALSE);
  78. mCharacter->updateVisualParams();
  79. }
  80. return TRUE;
  81. }
  82. //-----------------------------------------------------------------------------
  83. // LLEmote::onUpdate()
  84. //-----------------------------------------------------------------------------
  85. BOOL LLEmote::onUpdate(F32 time, U8* joint_mask)
  86. {
  87. if( mParam )
  88. {
  89. F32 weight = mParam->getMinWeight() + mPose.getWeight() * (mParam->getMaxWeight() - mParam->getMinWeight());
  90. mParam->setWeight(weight, FALSE);
  91. // Cross fade against the default parameter
  92. LLVisualParam* default_param = mCharacter->getVisualParam( "Express_Closed_Mouth" );
  93. if( default_param )
  94. {
  95. F32 default_param_weight = default_param->getMinWeight() +
  96. (1.f - mPose.getWeight()) * ( default_param->getMaxWeight() - default_param->getMinWeight() );
  97. default_param->setWeight( default_param_weight, FALSE );
  98. }
  99. mCharacter->updateVisualParams();
  100. }
  101. return TRUE;
  102. }
  103. //-----------------------------------------------------------------------------
  104. // LLEmote::onDeactivate()
  105. //-----------------------------------------------------------------------------
  106. void LLEmote::onDeactivate()
  107. {
  108. if( mParam )
  109. {
  110. mParam->setWeight( mParam->getDefaultWeight(), FALSE );
  111. }
  112. LLVisualParam* default_param = mCharacter->getVisualParam( "Express_Closed_Mouth" );
  113. if( default_param )
  114. {
  115. default_param->setWeight( default_param->getMaxWeight(), FALSE );
  116. }
  117. mCharacter->updateVisualParams();
  118. }
  119. // End