PageRenderTime 114ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llwlanimator.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 139 lines | 77 code | 27 blank | 35 comment | 3 complexity | 939cbaad8687eb53f705c7438623d5a3 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llwlanimator.h
  3. * @brief Interface for the LLWLAnimator class.
  4. *
  5. * $LicenseInfo:firstyear=2007&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. #ifndef LL_WL_ANIMATOR_H
  27. #define LL_WL_ANIMATOR_H
  28. #include "llwlparamset.h"
  29. #include "llwaterparamset.h"
  30. #include <string>
  31. #include <map>
  32. struct LLWLParamKey;
  33. class LLWLAnimator {
  34. public:
  35. typedef enum e_time
  36. {
  37. TIME_LINDEN,
  38. TIME_LOCAL,
  39. TIME_CUSTOM
  40. } ETime;
  41. F64 mStartTime;
  42. F32 mDayRate;
  43. F64 mDayTime;
  44. // track to play
  45. std::map<F32, LLWLParamKey> mTimeTrack;
  46. std::map<F32, LLWLParamKey>::iterator mFirstIt, mSecondIt;
  47. // simple constructor
  48. LLWLAnimator();
  49. ~LLWLAnimator()
  50. {
  51. delete mInterpBeginWL;
  52. delete mInterpBeginWater;
  53. delete mInterpEndWater;
  54. }
  55. // update the parameters
  56. void update(LLWLParamSet& curParams);
  57. // get time in seconds
  58. //F64 getTime(void);
  59. // returns a float 0 - 1 saying what time of day is it?
  60. F64 getDayTime(void);
  61. // sets a float 0 - 1 saying what time of day it is
  62. void setDayTime(F64 dayTime);
  63. // set an animation track
  64. void setTrack(std::map<F32, LLWLParamKey>& track,
  65. F32 dayRate, F64 dayTime = 0, bool run = true);
  66. void deactivate()
  67. {
  68. mIsRunning = false;
  69. }
  70. void activate(ETime time)
  71. {
  72. mIsRunning = true;
  73. mTimeType = time;
  74. }
  75. void startInterpolation(const LLSD& targetWater);
  76. bool getIsRunning()
  77. {
  78. return mIsRunning;
  79. }
  80. bool getUseCustomTime()
  81. {
  82. return mTimeType == TIME_CUSTOM;
  83. }
  84. bool getUseLocalTime()
  85. {
  86. return mTimeType == TIME_LOCAL;
  87. }
  88. bool getUseLindenTime()
  89. {
  90. return mTimeType == TIME_LINDEN;
  91. }
  92. void setTimeType(ETime time)
  93. {
  94. mTimeType = time;
  95. }
  96. ETime getTimeType()
  97. {
  98. return mTimeType;
  99. }
  100. /// convert the present time to a digital clock time
  101. static std::string timeToString(F32 curTime);
  102. /// get local time between 0 and 1
  103. static F64 getLocalTime();
  104. private:
  105. ETime mTimeType;
  106. bool mIsRunning, mIsInterpolating;
  107. LLWLParamSet *mInterpBeginWL;
  108. LLWaterParamSet *mInterpBeginWater, *mInterpEndWater;
  109. clock_t mInterpStartTime, mInterpEndTime;
  110. static F64 INTERP_TOTAL_SECONDS;
  111. };
  112. #endif // LL_WL_ANIMATOR_H