llemote.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /**
  2. * @file llemote.cpp
  3. * @brief Implementation of LLEmote class
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #include "linden_common.h"
  33. #include "llemote.h"
  34. #include "llcharacter.h"
  35. LLEmote::LLEmote(const LLUUID& id)
  36. : LLMotion(id)
  37. {
  38. mCharacter = NULL;
  39. // RN: flag face joint as highest priority for now, until we implement a
  40. // proper animation track
  41. mJointSignature[0][LL_FACE_JOINT_NUM] = 0xff;
  42. mJointSignature[1][LL_FACE_JOINT_NUM] = 0xff;
  43. mJointSignature[2][LL_FACE_JOINT_NUM] = 0xff;
  44. }
  45. LLMotion::LLMotionInitStatus LLEmote::onInitialize(LLCharacter* character)
  46. {
  47. mCharacter = character;
  48. return STATUS_SUCCESS;
  49. }
  50. bool LLEmote::onActivate()
  51. {
  52. if (!mCharacter)
  53. {
  54. return true;
  55. }
  56. LLVisualParam* default_param;
  57. default_param = mCharacter->getVisualParam("Express_Closed_Mouth");
  58. if (default_param)
  59. {
  60. default_param->setWeight(default_param->getMaxWeight(), false);
  61. }
  62. mParam = mCharacter->getVisualParam(mName.c_str());
  63. if (mParam)
  64. {
  65. mParam->setWeight(0.f, false);
  66. mCharacter->updateVisualParams();
  67. }
  68. return true;
  69. }
  70. bool LLEmote::onUpdate(F32 time, U8* joint_mask)
  71. {
  72. if (mParam && mCharacter)
  73. {
  74. F32 weight = mParam->getMinWeight() +
  75. mPose.getWeight() *
  76. (mParam->getMaxWeight() - mParam->getMinWeight());
  77. mParam->setWeight(weight, false);
  78. // Cross fade against the default parameter
  79. LLVisualParam* default_param =
  80. mCharacter->getVisualParam("Express_Closed_Mouth");
  81. if (default_param)
  82. {
  83. F32 default_param_weight = default_param->getMinWeight() +
  84. (1.f - mPose.getWeight()) *
  85. (default_param->getMaxWeight() -
  86. default_param->getMinWeight());
  87. default_param->setWeight(default_param_weight, false);
  88. }
  89. mCharacter->updateVisualParams();
  90. }
  91. return true;
  92. }
  93. void LLEmote::onDeactivate()
  94. {
  95. if (!mCharacter) return;
  96. if (mParam)
  97. {
  98. mParam->setWeight(mParam->getDefaultWeight(), false);
  99. }
  100. LLVisualParam* default_param;
  101. default_param = mCharacter->getVisualParam("Express_Closed_Mouth");
  102. if (default_param)
  103. {
  104. default_param->setWeight(default_param->getMaxWeight(), false);
  105. }
  106. mCharacter->updateVisualParams();
  107. }