You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

92 lines
3.6 KiB

  1. /** Calculates a pose for a given time of an animation */
  2. /*
  3. ---------------------------------------------------------------------------
  4. Open Asset Import Library (assimp)
  5. ---------------------------------------------------------------------------
  6. Copyright (c) 2006-2012, assimp team
  7. All rights reserved.
  8. Redistribution and use of this software in source and binary forms,
  9. with or without modification, are permitted provided that the following
  10. conditions are met:
  11. * Redistributions of source code must retain the above
  12. copyright notice, this list of conditions and the
  13. following disclaimer.
  14. * Redistributions in binary form must reproduce the above
  15. copyright notice, this list of conditions and the
  16. following disclaimer in the documentation and/or other
  17. materials provided with the distribution.
  18. * Neither the name of the assimp team, nor the names of its
  19. contributors may be used to endorse or promote products
  20. derived from this software without specific prior
  21. written permission of the assimp team.
  22. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. ---------------------------------------------------------------------------
  34. */
  35. #ifndef AV_ANIMEVALUATOR_H_INCLUDED
  36. #define AV_ANIMEVALUATOR_H_INCLUDED
  37. #include <boost/tuple/tuple.hpp>
  38. namespace AssimpView
  39. {
  40. /** Calculates transformations for a given timestamp from a set of animation tracks. Not directly useful,
  41. * better use the AnimPlayer class.
  42. */
  43. class AnimEvaluator
  44. {
  45. public:
  46. /** Constructor on a given animation. The animation is fixed throughout the lifetime of
  47. * the object.
  48. * @param pAnim The animation to calculate poses for. Ownership of the animation object stays
  49. * at the caller, the evaluator just keeps a reference to it as long as it persists.
  50. */
  51. AnimEvaluator( const aiAnimation* pAnim);
  52. /** Evaluates the animation tracks for a given time stamp. The calculated pose can be retrieved as a
  53. * array of transformation matrices afterwards by calling GetTransformations().
  54. * @param pTime The time for which you want to evaluate the animation, in seconds. Will be mapped into the animation cycle, so
  55. * it can be an arbitrary value. Best use with ever-increasing time stamps.
  56. */
  57. void Evaluate( double pTime);
  58. /** Returns the transform matrices calculated at the last Evaluate() call. The array matches the mChannels array of
  59. * the aiAnimation. */
  60. const std::vector<aiMatrix4x4>& GetTransformations() const { return mTransforms; }
  61. protected:
  62. /** The animation we're working on */
  63. const aiAnimation* mAnim;
  64. /** At which frame the last evaluation happened for each channel.
  65. * Useful to quickly find the corresponding frame for slightly increased time stamps
  66. */
  67. double mLastTime;
  68. std::vector<boost::tuple<unsigned int, unsigned int, unsigned int> > mLastPositions;
  69. /** The array to store the transformations results of the evaluation */
  70. std::vector<aiMatrix4x4> mTransforms;
  71. };
  72. } // end of namespace AssimpView
  73. #endif // AV_ANIMEVALUATOR_H_INCLUDED