vrshoot

view libs/assimp/TargetAnimation.h @ 0:b2f14e535253

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