Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

180 řádky
5.7 KiB

  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2012, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** @file Defines a helper class for the ASE and 3DS loaders to
  34. help them compute camera and spot light animation channels */
  35. #ifndef AI_TARGET_ANIMATION_H_INC
  36. #define AI_TARGET_ANIMATION_H_INC
  37. namespace Assimp {
  38. // ---------------------------------------------------------------------------
  39. /** Helper class to iterate through all keys in an animation channel.
  40. *
  41. * Missing tracks are interpolated. This is a helper class for
  42. * TargetAnimationHelper, but it can be freely used for other purposes.
  43. */
  44. class KeyIterator
  45. {
  46. public:
  47. // ------------------------------------------------------------------
  48. /** Constructs a new key iterator
  49. *
  50. * @param _objPos Object position track. May be NULL.
  51. * @param _targetObjPos Target object position track. May be NULL.
  52. * @param defaultObjectPos Default object position to be used if
  53. * no animated track is available. May be NULL.
  54. * @param defaultTargetPos Default target position to be used if
  55. * no animated track is available. May be NULL.
  56. */
  57. KeyIterator(const std::vector<aiVectorKey>* _objPos,
  58. const std::vector<aiVectorKey>* _targetObjPos,
  59. const aiVector3D* defaultObjectPos = NULL,
  60. const aiVector3D* defaultTargetPos = NULL);
  61. // ------------------------------------------------------------------
  62. /** Returns true if all keys have been processed
  63. */
  64. bool Finished() const
  65. {return reachedEnd;}
  66. // ------------------------------------------------------------------
  67. /** Increment the iterator
  68. */
  69. void operator++();
  70. inline void operator++(int)
  71. {return ++(*this);}
  72. // ------------------------------------------------------------------
  73. /** Getters to retrieve the current state of the iterator
  74. */
  75. inline const aiVector3D& GetCurPosition() const
  76. {return curPosition;}
  77. inline const aiVector3D& GetCurTargetPosition() const
  78. {return curTargetPosition;}
  79. inline double GetCurTime() const
  80. {return curTime;}
  81. private:
  82. //! Did we reach the end?
  83. bool reachedEnd;
  84. //! Represents the current position of the iterator
  85. aiVector3D curPosition, curTargetPosition;
  86. double curTime;
  87. //! Input tracks and the next key to process
  88. const std::vector<aiVectorKey>* objPos,*targetObjPos;
  89. unsigned int nextObjPos, nextTargetObjPos;
  90. std::vector<aiVectorKey> defaultObjPos,defaultTargetObjPos;
  91. };
  92. // ---------------------------------------------------------------------------
  93. /** Helper class for the 3DS and ASE loaders to compute camera and spot light
  94. * animations.
  95. *
  96. * 3DS and ASE store the differently to Assimp - there is an animation
  97. * channel for the camera/spot light itself and a separate position
  98. * animation channels specifying the position of the camera/spot light
  99. * look-at target */
  100. class TargetAnimationHelper
  101. {
  102. public:
  103. TargetAnimationHelper()
  104. : targetPositions (NULL)
  105. , objectPositions (NULL)
  106. {}
  107. // ------------------------------------------------------------------
  108. /** Sets the target animation channel
  109. *
  110. * This channel specifies the position of the camera/spot light
  111. * target at a specific position.
  112. *
  113. * @param targetPositions Translation channel*/
  114. void SetTargetAnimationChannel (const
  115. std::vector<aiVectorKey>* targetPositions);
  116. // ------------------------------------------------------------------
  117. /** Sets the main animation channel
  118. *
  119. * @param objectPositions Translation channel */
  120. void SetMainAnimationChannel ( const
  121. std::vector<aiVectorKey>* objectPositions);
  122. // ------------------------------------------------------------------
  123. /** Sets the main animation channel to a fixed value
  124. *
  125. * @param fixed Fixed value for the main animation channel*/
  126. void SetFixedMainAnimationChannel(const aiVector3D& fixed);
  127. // ------------------------------------------------------------------
  128. /** Computes final animation channels
  129. * @param distanceTrack Receive camera translation keys ... != NULL. */
  130. void Process( std::vector<aiVectorKey>* distanceTrack );
  131. private:
  132. const std::vector<aiVectorKey>* targetPositions,*objectPositions;
  133. aiVector3D fixedMain;
  134. };
  135. } // ! end namespace Assimp
  136. #endif // include guard