Fix some findings in animation header.
parent
f45aeca3f6
commit
d87400b76a
|
@ -59,7 +59,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
using namespace Assimp::Collada;
|
using namespace Assimp::Collada;
|
||||||
using namespace Assimp::Formatter;
|
using namespace Assimp::Formatter;
|
||||||
|
|
|
@ -268,8 +268,7 @@ namespace Assimp
|
||||||
Collada::InputType GetTypeForSemantic( const std::string& pSemantic);
|
Collada::InputType GetTypeForSemantic( const std::string& pSemantic);
|
||||||
|
|
||||||
/** Finds the item in the given library by its reference, throws if not found */
|
/** Finds the item in the given library by its reference, throws if not found */
|
||||||
template <typename Type> const Type& ResolveLibraryReference(
|
template <typename Type> const Type& ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
|
||||||
const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Filename, for a verbose error message */
|
/** Filename, for a verbose error message */
|
||||||
|
|
|
@ -39,7 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @file anim.h
|
/**
|
||||||
|
* @file anim.h
|
||||||
* @brief Defines the data structures in which the imported animations
|
* @brief Defines the data structures in which the imported animations
|
||||||
* are returned.
|
* are returned.
|
||||||
*/
|
*/
|
||||||
|
@ -47,8 +48,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef AI_ANIM_H_INC
|
#ifndef AI_ANIM_H_INC
|
||||||
#define AI_ANIM_H_INC
|
#define AI_ANIM_H_INC
|
||||||
|
|
||||||
#include "types.h"
|
#include <assimp/types.h>
|
||||||
#include "quaternion.h"
|
#include <assimp/quaternion.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -66,16 +67,20 @@ struct aiVectorKey
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
//! Default constructor
|
/// @brief The default constructor.
|
||||||
aiVectorKey(){}
|
aiVectorKey()
|
||||||
|
: mTime( 0.0 )
|
||||||
|
, mValue() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @brief Construction from a given time and key value.
|
||||||
|
|
||||||
//! Construction from a given time and key value
|
|
||||||
aiVectorKey(double time, const aiVector3D& value)
|
aiVectorKey(double time, const aiVector3D& value)
|
||||||
: mTime (time)
|
: mTime (time)
|
||||||
, mValue (value)
|
, mValue (value)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
typedef aiVector3D elem_type;
|
typedef aiVector3D elem_type;
|
||||||
|
|
||||||
// Comparison operators. For use with std::find();
|
// Comparison operators. For use with std::find();
|
||||||
|
@ -93,7 +98,7 @@ struct aiVectorKey
|
||||||
bool operator > (const aiVectorKey& o) const {
|
bool operator > (const aiVectorKey& o) const {
|
||||||
return mTime > o.mTime;
|
return mTime > o.mTime;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // __cplusplus
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
@ -108,7 +113,10 @@ struct aiQuatKey
|
||||||
C_STRUCT aiQuaternion mValue;
|
C_STRUCT aiQuaternion mValue;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiQuatKey(){
|
aiQuatKey()
|
||||||
|
: mTime( 0.0 )
|
||||||
|
, mValue() {
|
||||||
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Construction from a given time and key value */
|
/** Construction from a given time and key value */
|
||||||
|
@ -145,7 +153,7 @@ struct aiMeshKey
|
||||||
double mTime;
|
double mTime;
|
||||||
|
|
||||||
/** Index into the aiMesh::mAnimMeshes array of the
|
/** Index into the aiMesh::mAnimMeshes array of the
|
||||||
* mesh coresponding to the #aiMeshAnim hosting this
|
* mesh corresponding to the #aiMeshAnim hosting this
|
||||||
* key frame. The referenced anim mesh is evaluated
|
* key frame. The referenced anim mesh is evaluated
|
||||||
* according to the rules defined in the docs for #aiAnimMesh.*/
|
* according to the rules defined in the docs for #aiAnimMesh.*/
|
||||||
unsigned int mValue;
|
unsigned int mValue;
|
||||||
|
@ -204,8 +212,6 @@ enum aiAnimBehaviour
|
||||||
* time is t, use the value at (t-n) % (|m-n|).*/
|
* time is t, use the value at (t-n) % (|m-n|).*/
|
||||||
aiAnimBehaviour_REPEAT = 0x3,
|
aiAnimBehaviour_REPEAT = 0x3,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** This value is not used, it is just here to force the
|
/** This value is not used, it is just here to force the
|
||||||
* the compiler to map this enum to a 32 Bit integer */
|
* the compiler to map this enum to a 32 Bit integer */
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
|
@ -228,8 +234,7 @@ enum aiAnimBehaviour
|
||||||
* Duplicate keys don't pass the validation step. Most likely there
|
* Duplicate keys don't pass the validation step. Most likely there
|
||||||
* will be no negative time values, but they are not forbidden also ( so
|
* will be no negative time values, but they are not forbidden also ( so
|
||||||
* implementations need to cope with them! ) */
|
* implementations need to cope with them! ) */
|
||||||
struct aiNodeAnim
|
struct aiNodeAnim {
|
||||||
{
|
|
||||||
/** The name of the node affected by this animation. The node
|
/** The name of the node affected by this animation. The node
|
||||||
* must exist and it must be unique.*/
|
* must exist and it must be unique.*/
|
||||||
C_STRUCT aiString mNodeName;
|
C_STRUCT aiString mNodeName;
|
||||||
|
@ -281,16 +286,16 @@ struct aiNodeAnim
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
aiNodeAnim()
|
aiNodeAnim()
|
||||||
{
|
: mNumPositionKeys( 0 )
|
||||||
mNumPositionKeys = 0; mPositionKeys = NULL;
|
, mPositionKeys( NULL )
|
||||||
mNumRotationKeys = 0; mRotationKeys = NULL;
|
, mNumRotationKeys( 0 )
|
||||||
mNumScalingKeys = 0; mScalingKeys = NULL;
|
, mRotationKeys( NULL )
|
||||||
|
, mNumScalingKeys( 0 )
|
||||||
|
, mScalingKeys( NULL ) {
|
||||||
mPreState = mPostState = aiAnimBehaviour_DEFAULT;
|
mPreState = mPostState = aiAnimBehaviour_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
~aiNodeAnim()
|
~aiNodeAnim() {
|
||||||
{
|
|
||||||
delete [] mPositionKeys;
|
delete [] mPositionKeys;
|
||||||
delete [] mRotationKeys;
|
delete [] mRotationKeys;
|
||||||
delete [] mScalingKeys;
|
delete [] mScalingKeys;
|
||||||
|
@ -308,7 +313,7 @@ struct aiMeshAnim
|
||||||
{
|
{
|
||||||
/** Name of the mesh to be animated. An empty string is not allowed,
|
/** Name of the mesh to be animated. An empty string is not allowed,
|
||||||
* animated meshes need to be named (not necessarily uniquely,
|
* animated meshes need to be named (not necessarily uniquely,
|
||||||
* the name can basically serve as wildcard to select a group
|
* the name can basically serve as wild-card to select a group
|
||||||
* of meshes with similar animation setup)*/
|
* of meshes with similar animation setup)*/
|
||||||
C_STRUCT aiString mName;
|
C_STRUCT aiString mName;
|
||||||
|
|
||||||
|
@ -334,10 +339,9 @@ struct aiMeshAnim
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** An animation consists of keyframe data for a number of nodes. For
|
/** An animation consists of key-frame data for a number of nodes. For
|
||||||
* each node affected by the animation a separate series of data is given.*/
|
* each node affected by the animation a separate series of data is given.*/
|
||||||
struct aiAnimation
|
struct aiAnimation {
|
||||||
{
|
|
||||||
/** The name of the animation. If the modeling package this data was
|
/** The name of the animation. If the modeling package this data was
|
||||||
* exported from does support only a single animation channel, this
|
* exported from does support only a single animation channel, this
|
||||||
* name is usually empty (length is zero). */
|
* name is usually empty (length is zero). */
|
||||||
|
@ -401,15 +405,16 @@ struct aiAnimation
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Some C++ utilities for inter- and extrapolation
|
||||||
// some C++ utilities for inter- and extrapolation
|
|
||||||
namespace Assimp {
|
namespace Assimp {
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** @brief CPP-API: Utility class to simplify interpolations of various data types.
|
/**
|
||||||
|
* @brief CPP-API: Utility class to simplify interpolations of various data types.
|
||||||
*
|
*
|
||||||
* The type of interpolation is chosen automatically depending on the
|
* The type of interpolation is chosen automatically depending on the
|
||||||
* types of the arguments. */
|
* types of the arguments.
|
||||||
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct Interpolator
|
struct Interpolator
|
||||||
{
|
{
|
||||||
|
@ -445,7 +450,7 @@ struct Interpolator <unsigned int> {
|
||||||
}; // ! Interpolator <aiQuaternion>
|
}; // ! Interpolator <aiQuaternion>
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Interpolator <aiVectorKey> {
|
struct Interpolator<aiVectorKey> {
|
||||||
void operator () (aiVector3D& out,const aiVectorKey& a,
|
void operator () (aiVector3D& out,const aiVectorKey& a,
|
||||||
const aiVectorKey& b, ai_real d) const
|
const aiVectorKey& b, ai_real d) const
|
||||||
{
|
{
|
||||||
|
@ -455,7 +460,7 @@ struct Interpolator <aiVectorKey> {
|
||||||
}; // ! Interpolator <aiVectorKey>
|
}; // ! Interpolator <aiVectorKey>
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Interpolator <aiQuatKey> {
|
struct Interpolator<aiQuatKey> {
|
||||||
void operator () (aiQuaternion& out, const aiQuatKey& a,
|
void operator () (aiQuaternion& out, const aiQuatKey& a,
|
||||||
const aiQuatKey& b, ai_real d) const
|
const aiQuatKey& b, ai_real d) const
|
||||||
{
|
{
|
||||||
|
@ -465,7 +470,7 @@ struct Interpolator <aiQuatKey> {
|
||||||
}; // ! Interpolator <aiQuatKey>
|
}; // ! Interpolator <aiQuatKey>
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Interpolator <aiMeshKey> {
|
struct Interpolator<aiMeshKey> {
|
||||||
void operator () (unsigned int& out, const aiMeshKey& a,
|
void operator () (unsigned int& out, const aiMeshKey& a,
|
||||||
const aiMeshKey& b, ai_real d) const
|
const aiMeshKey& b, ai_real d) const
|
||||||
{
|
{
|
||||||
|
@ -475,9 +480,9 @@ struct Interpolator <aiMeshKey> {
|
||||||
}; // ! Interpolator <aiQuatKey>
|
}; // ! Interpolator <aiQuatKey>
|
||||||
|
|
||||||
//! @endcond
|
//! @endcond
|
||||||
|
|
||||||
} // ! end namespace Assimp
|
} // ! end namespace Assimp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
#endif // AI_ANIM_H_INC
|
#endif // AI_ANIM_H_INC
|
||||||
|
|
|
@ -56,6 +56,7 @@ SOURCE_GROUP( unit FILES
|
||||||
|
|
||||||
SET( TEST_SRCS
|
SET( TEST_SRCS
|
||||||
unit/TestIOSystem.h
|
unit/TestIOSystem.h
|
||||||
|
unit/utAnim.cpp
|
||||||
unit/AssimpAPITest.cpp
|
unit/AssimpAPITest.cpp
|
||||||
unit/utBatchLoader.cpp
|
unit/utBatchLoader.cpp
|
||||||
unit/utBlenderIntermediate.cpp
|
unit/utBlenderIntermediate.cpp
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2016, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
|
#include <assimp/anim.h>
|
||||||
|
|
||||||
|
using namespace Assimp;
|
||||||
|
|
||||||
|
class utAnim : public ::testing::Test {
|
||||||
|
// empty
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F( utAnim, aiVectorKeyCreationTest ) {
|
||||||
|
aiVectorKey defaultConstTest;
|
||||||
|
EXPECT_DOUBLE_EQ( 0.0, defaultConstTest.mTime );
|
||||||
|
|
||||||
|
aiVector3D v( 1, 2, 3 );
|
||||||
|
aiVectorKey constrWithValuesTest( 1, v );
|
||||||
|
EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime );
|
||||||
|
EXPECT_EQ( v, constrWithValuesTest.mValue );
|
||||||
|
|
||||||
|
EXPECT_NE( defaultConstTest, constrWithValuesTest );
|
||||||
|
EXPECT_TRUE( defaultConstTest != constrWithValuesTest );
|
||||||
|
defaultConstTest.mTime = 1;
|
||||||
|
constrWithValuesTest.mTime = 2;
|
||||||
|
EXPECT_TRUE( defaultConstTest < constrWithValuesTest );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F( utAnim, aiQuatKeyTest ) {
|
||||||
|
aiQuatKey defaultConstrTest;
|
||||||
|
EXPECT_DOUBLE_EQ( 0.0, defaultConstrTest.mTime );
|
||||||
|
|
||||||
|
aiQuaternion q;
|
||||||
|
aiQuatKey constrWithValuesTest( 1.0, q );
|
||||||
|
EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime );
|
||||||
|
EXPECT_EQ( q, constrWithValuesTest.mValue );
|
||||||
|
}
|
Loading…
Reference in New Issue