vrshoot

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/TargetAnimation.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,179 @@
     1.4 +/*
     1.5 +Open Asset Import Library (assimp)
     1.6 +----------------------------------------------------------------------
     1.7 +
     1.8 +Copyright (c) 2006-2012, assimp team
     1.9 +All rights reserved.
    1.10 +
    1.11 +Redistribution and use of this software in source and binary forms, 
    1.12 +with or without modification, are permitted provided that the 
    1.13 +following conditions are met:
    1.14 +
    1.15 +* Redistributions of source code must retain the above
    1.16 +  copyright notice, this list of conditions and the
    1.17 +  following disclaimer.
    1.18 +
    1.19 +* Redistributions in binary form must reproduce the above
    1.20 +  copyright notice, this list of conditions and the
    1.21 +  following disclaimer in the documentation and/or other
    1.22 +  materials provided with the distribution.
    1.23 +
    1.24 +* Neither the name of the assimp team, nor the names of its
    1.25 +  contributors may be used to endorse or promote products
    1.26 +  derived from this software without specific prior
    1.27 +  written permission of the assimp team.
    1.28 +
    1.29 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    1.30 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    1.31 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.32 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    1.33 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.34 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    1.35 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.36 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    1.37 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1.38 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.39 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.40 +
    1.41 +----------------------------------------------------------------------
    1.42 +*/
    1.43 +
    1.44 +/** @file Defines a helper class for the ASE and 3DS loaders to
    1.45 + help them compute camera and spot light animation channels */
    1.46 +#ifndef AI_TARGET_ANIMATION_H_INC
    1.47 +#define AI_TARGET_ANIMATION_H_INC
    1.48 +
    1.49 +
    1.50 +namespace Assimp	{
    1.51 +
    1.52 +
    1.53 +
    1.54 +// ---------------------------------------------------------------------------
    1.55 +/** Helper class to iterate through all keys in an animation channel.
    1.56 + *
    1.57 + *  Missing tracks are interpolated. This is a helper class for
    1.58 + *  TargetAnimationHelper, but it can be freely used for other purposes.
    1.59 +*/
    1.60 +class KeyIterator
    1.61 +{
    1.62 +public:
    1.63 +
    1.64 +	
    1.65 +	// ------------------------------------------------------------------
    1.66 +	/** Constructs a new key iterator
    1.67 +	 *
    1.68 +	 *  @param _objPos Object position track. May be NULL.
    1.69 +	 *  @param _targetObjPos Target object position track. May be NULL.
    1.70 +	 *  @param defaultObjectPos Default object position to be used if
    1.71 +	 *	  no animated track is available. May be NULL.
    1.72 +	 *  @param defaultTargetPos Default target position to be used if
    1.73 +	 *	  no animated track is available. May be NULL.
    1.74 +	 */
    1.75 +	KeyIterator(const std::vector<aiVectorKey>* _objPos,
    1.76 +		const std::vector<aiVectorKey>* _targetObjPos,
    1.77 +		const aiVector3D*  defaultObjectPos = NULL,
    1.78 +		const aiVector3D*  defaultTargetPos = NULL);
    1.79 +
    1.80 +	// ------------------------------------------------------------------
    1.81 +	/** Returns true if all keys have been processed
    1.82 +	 */
    1.83 +	bool Finished() const
    1.84 +		{return reachedEnd;}
    1.85 +
    1.86 +	// ------------------------------------------------------------------
    1.87 +	/** Increment the iterator
    1.88 +	 */
    1.89 +	void operator++();
    1.90 +	inline void operator++(int)
    1.91 +		{return ++(*this);}
    1.92 +
    1.93 +
    1.94 +
    1.95 +	// ------------------------------------------------------------------
    1.96 +	/** Getters to retrieve the current state of the iterator
    1.97 +	 */
    1.98 +	inline const aiVector3D& GetCurPosition() const
    1.99 +		{return curPosition;}
   1.100 +
   1.101 +	inline const aiVector3D& GetCurTargetPosition() const
   1.102 +		{return curTargetPosition;}
   1.103 +
   1.104 +	inline double GetCurTime() const
   1.105 +		{return curTime;}
   1.106 +
   1.107 +private:
   1.108 +
   1.109 +	//! Did we reach the end?
   1.110 +	bool reachedEnd;
   1.111 +
   1.112 +	//! Represents the current position of the iterator
   1.113 +	aiVector3D curPosition, curTargetPosition;
   1.114 +
   1.115 +	double curTime;
   1.116 +
   1.117 +	//! Input tracks and the next key to process
   1.118 +	const std::vector<aiVectorKey>* objPos,*targetObjPos;
   1.119 +
   1.120 +	unsigned int nextObjPos, nextTargetObjPos;
   1.121 +	std::vector<aiVectorKey> defaultObjPos,defaultTargetObjPos;
   1.122 +};
   1.123 +
   1.124 +// ---------------------------------------------------------------------------
   1.125 +/** Helper class for the 3DS and ASE loaders to compute camera and spot light
   1.126 + *  animations.
   1.127 + *
   1.128 + * 3DS and ASE store the differently to Assimp - there is an animation
   1.129 + * channel for the camera/spot light itself and a separate position
   1.130 + * animation channels specifying the position of the camera/spot light
   1.131 + * look-at target */
   1.132 +class TargetAnimationHelper
   1.133 +{
   1.134 +public:
   1.135 +
   1.136 +	TargetAnimationHelper()
   1.137 +		:	targetPositions		(NULL)
   1.138 +		,	objectPositions		(NULL)
   1.139 +	{}
   1.140 +
   1.141 +
   1.142 +	// ------------------------------------------------------------------
   1.143 +	/** Sets the target animation channel
   1.144 +	 *
   1.145 +	 *  This channel specifies the position of the camera/spot light
   1.146 +	 *  target at a specific position.
   1.147 +	 *
   1.148 +	 *  @param targetPositions Translation channel*/
   1.149 +	void SetTargetAnimationChannel (const 
   1.150 +		std::vector<aiVectorKey>* targetPositions);
   1.151 +
   1.152 +
   1.153 +	// ------------------------------------------------------------------
   1.154 +	/** Sets the main animation channel
   1.155 +	 *
   1.156 +	 *  @param objectPositions Translation channel */
   1.157 +	void SetMainAnimationChannel ( const
   1.158 +		std::vector<aiVectorKey>* objectPositions);
   1.159 +
   1.160 +	// ------------------------------------------------------------------
   1.161 +	/** Sets the main animation channel to a fixed value 
   1.162 +	 *
   1.163 +	 *  @param fixed Fixed value for the main animation channel*/
   1.164 +	void SetFixedMainAnimationChannel(const aiVector3D& fixed);
   1.165 +
   1.166 +
   1.167 +	// ------------------------------------------------------------------
   1.168 +	/** Computes final animation channels
   1.169 +	 * @param distanceTrack Receive camera translation keys ... != NULL. */
   1.170 +	void Process( std::vector<aiVectorKey>* distanceTrack );
   1.171 +
   1.172 +
   1.173 +private:
   1.174 +
   1.175 +	const std::vector<aiVectorKey>* targetPositions,*objectPositions;
   1.176 +	aiVector3D fixedMain;
   1.177 +};
   1.178 +
   1.179 +
   1.180 +} // ! end namespace Assimp
   1.181 +
   1.182 +#endif // include guard