- renamed "bone" anims and associated structures to generic "node" anims. Breaking change, sorry for that.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@166 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
ulfjorensen 2008-09-30 13:05:48 +00:00
parent 832f9cf672
commit 8925813026
15 changed files with 140 additions and 145 deletions

View File

@ -222,8 +222,8 @@ void ASEImporter::BuildAnimations()
this->pcScene->mNumAnimations = 1; this->pcScene->mNumAnimations = 1;
this->pcScene->mAnimations = new aiAnimation*[1]; this->pcScene->mAnimations = new aiAnimation*[1];
aiAnimation* pcAnim = this->pcScene->mAnimations[0] = new aiAnimation(); aiAnimation* pcAnim = this->pcScene->mAnimations[0] = new aiAnimation();
pcAnim->mNumBones = iNum; pcAnim->mNumChannels = iNum;
pcAnim->mBones = new aiBoneAnim*[iNum]; pcAnim->mChannels = new aiNodeAnim*[iNum];
pcAnim->mTicksPerSecond = this->mParser->iFrameSpeed * this->mParser->iTicksPerFrame; pcAnim->mTicksPerSecond = this->mParser->iFrameSpeed * this->mParser->iTicksPerFrame;
iNum = 0; iNum = 0;
@ -233,36 +233,36 @@ void ASEImporter::BuildAnimations()
if ((*i).bSkip)continue; if ((*i).bSkip)continue;
if ((*i).mAnim.akeyPositions.size() > 1 || (*i).mAnim.akeyRotations.size() > 1) if ((*i).mAnim.akeyPositions.size() > 1 || (*i).mAnim.akeyRotations.size() > 1)
{ {
aiBoneAnim* pcBoneAnim = pcAnim->mBones[iNum++] = new aiBoneAnim(); aiNodeAnim* pcNodeAnim = pcAnim->mChannels[iNum++] = new aiNodeAnim();
pcBoneAnim->mBoneName.Set((*i).mName); pcNodeAnim->mNodeName.Set((*i).mName);
// copy position keys // copy position keys
if ((*i).mAnim.akeyPositions.size() > 1 ) if ((*i).mAnim.akeyPositions.size() > 1 )
{ {
pcBoneAnim->mNumPositionKeys = (unsigned int) (*i).mAnim.akeyPositions.size(); pcNodeAnim->mNumPositionKeys = (unsigned int) (*i).mAnim.akeyPositions.size();
pcBoneAnim->mPositionKeys = new aiVectorKey[pcBoneAnim->mNumPositionKeys]; pcNodeAnim->mPositionKeys = new aiVectorKey[pcNodeAnim->mNumPositionKeys];
::memcpy(pcBoneAnim->mPositionKeys,&(*i).mAnim.akeyPositions[0], ::memcpy(pcNodeAnim->mPositionKeys,&(*i).mAnim.akeyPositions[0],
pcBoneAnim->mNumPositionKeys * sizeof(aiVectorKey)); pcNodeAnim->mNumPositionKeys * sizeof(aiVectorKey));
for (unsigned int qq = 0; qq < pcBoneAnim->mNumPositionKeys;++qq) for (unsigned int qq = 0; qq < pcNodeAnim->mNumPositionKeys;++qq)
{ {
double dTime = pcBoneAnim->mPositionKeys[qq].mTime; double dTime = pcNodeAnim->mPositionKeys[qq].mTime;
pcAnim->mDuration = std::max(pcAnim->mDuration,dTime); pcAnim->mDuration = std::max(pcAnim->mDuration,dTime);
} }
} }
// copy rotation keys // copy rotation keys
if ((*i).mAnim.akeyRotations.size() > 1 ) if ((*i).mAnim.akeyRotations.size() > 1 )
{ {
pcBoneAnim->mNumRotationKeys = (unsigned int) (*i).mAnim.akeyPositions.size(); pcNodeAnim->mNumRotationKeys = (unsigned int) (*i).mAnim.akeyPositions.size();
pcBoneAnim->mRotationKeys = new aiQuatKey[pcBoneAnim->mNumPositionKeys]; pcNodeAnim->mRotationKeys = new aiQuatKey[pcNodeAnim->mNumPositionKeys];
::memcpy(pcBoneAnim->mRotationKeys,&(*i).mAnim.akeyRotations[0], ::memcpy(pcNodeAnim->mRotationKeys,&(*i).mAnim.akeyRotations[0],
pcBoneAnim->mNumRotationKeys * sizeof(aiQuatKey)); pcNodeAnim->mNumRotationKeys * sizeof(aiQuatKey));
for (unsigned int qq = 0; qq < pcBoneAnim->mNumRotationKeys;++qq) for (unsigned int qq = 0; qq < pcNodeAnim->mNumRotationKeys;++qq)
{ {
double dTime = pcBoneAnim->mRotationKeys[qq].mTime; double dTime = pcNodeAnim->mRotationKeys[qq].mTime;
pcAnim->mDuration = std::max(pcAnim->mDuration,dTime); pcAnim->mDuration = std::max(pcAnim->mDuration,dTime);
} }
} }

View File

@ -97,11 +97,11 @@ void ConvertToLHProcess::Execute( aiScene* pScene)
for( unsigned int a = 0; a < pScene->mNumAnimations; a++) for( unsigned int a = 0; a < pScene->mNumAnimations; a++)
{ {
aiAnimation* anim = pScene->mAnimations[a]; aiAnimation* anim = pScene->mAnimations[a];
for( unsigned int b = 0; b < anim->mNumBones; b++) for( unsigned int b = 0; b < anim->mNumChannels; b++)
{ {
aiBoneAnim* boneAnim = anim->mBones[b]; aiNodeAnim* nodeAnim = anim->mChannels[b];
if( strcmp( boneAnim->mBoneName.data, pScene->mRootNode->mName.data) == 0) if( strcmp( nodeAnim->mNodeName.data, pScene->mRootNode->mName.data) == 0)
ProcessAnimation( boneAnim); ProcessAnimation( nodeAnim);
} }
} }
DefaultLogger::get()->debug("ConvertToLHProcess finished"); DefaultLogger::get()->debug("ConvertToLHProcess finished");
@ -139,7 +139,7 @@ void ConvertToLHProcess::ProcessMesh( aiMesh* pMesh)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Converts the given animation to LH coordinates. // Converts the given animation to LH coordinates.
void ConvertToLHProcess::ProcessAnimation( aiBoneAnim* pAnim) void ConvertToLHProcess::ProcessAnimation( aiNodeAnim* pAnim)
{ {
// position keys // position keys
for( unsigned int a = 0; a < pAnim->mNumPositionKeys; a++) for( unsigned int a = 0; a < pAnim->mNumPositionKeys; a++)

View File

@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BaseProcess.h" #include "BaseProcess.h"
struct aiMesh; struct aiMesh;
struct aiBoneAnim; struct aiNodeAnim;
namespace Assimp namespace Assimp
{ {
@ -114,7 +114,7 @@ protected:
* work in local space and can therefore be left untouched. * work in local space and can therefore be left untouched.
* @param pAnim The bone animation to transform * @param pAnim The bone animation to transform
*/ */
void ProcessAnimation( aiBoneAnim* pAnim); void ProcessAnimation( aiNodeAnim* pAnim);
//! true if the transformation matrix for the OGL-to-DX is //! true if the transformation matrix for the OGL-to-DX is
//! directly used to transform all vertices. //! directly used to transform all vertices.

View File

@ -713,10 +713,10 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const
in.animations += sizeof(aiAnimation); in.animations += sizeof(aiAnimation);
// add all bone anims // add all bone anims
for (unsigned int a = 0; a < pc->mNumBones;++a) for (unsigned int a = 0; a < pc->mNumChannels; ++a)
{ {
const aiBoneAnim* pc2 = pc->mBones[i]; const aiNodeAnim* pc2 = pc->mChannels[i];
in.animations += sizeof(aiBoneAnim); in.animations += sizeof(aiNodeAnim);
in.animations += pc2->mNumPositionKeys * sizeof(aiVectorKey); in.animations += pc2->mNumPositionKeys * sizeof(aiVectorKey);
in.animations += pc2->mNumScalingKeys * sizeof(aiVectorKey); in.animations += pc2->mNumScalingKeys * sizeof(aiVectorKey);
in.animations += pc2->mNumRotationKeys * sizeof(aiQuatKey); in.animations += pc2->mNumRotationKeys * sizeof(aiQuatKey);

View File

@ -470,17 +470,17 @@ void MD5Importer::LoadMD5AnimFile ()
pScene->mNumAnimations = 1; pScene->mNumAnimations = 1;
pScene->mAnimations = new aiAnimation*[1]; pScene->mAnimations = new aiAnimation*[1];
aiAnimation* anim = pScene->mAnimations[0] = new aiAnimation(); aiAnimation* anim = pScene->mAnimations[0] = new aiAnimation();
anim->mNumBones = (unsigned int)animParser.mAnimatedBones.size(); anim->mNumChannels = (unsigned int)animParser.mAnimatedBones.size();
anim->mBones = new aiBoneAnim*[anim->mNumBones]; anim->mChannels = new aiNodeAnim*[anim->mNumChannels];
for (unsigned int i = 0; i < anim->mNumBones;++i) for (unsigned int i = 0; i < anim->mNumChannels;++i)
{ {
aiBoneAnim* bone = anim->mBones[i] = new aiBoneAnim(); aiNodeAnim* node = anim->mChannels[i] = new aiNodeAnim();
bone->mBoneName = aiString( animParser.mAnimatedBones[i].mName ); node->mNodeName = aiString( animParser.mAnimatedBones[i].mName );
// allocate storage for the keyframes // allocate storage for the keyframes
bone->mNumPositionKeys = bone->mNumRotationKeys = (unsigned int)animParser.mFrames.size(); node->mNumPositionKeys = node->mNumRotationKeys = (unsigned int)animParser.mFrames.size();
bone->mPositionKeys = new aiVectorKey[bone->mNumPositionKeys]; node->mPositionKeys = new aiVectorKey[node->mNumPositionKeys];
bone->mRotationKeys = new aiQuatKey[bone->mNumPositionKeys]; node->mRotationKeys = new aiQuatKey[node->mNumPositionKeys];
} }
// 1 tick == 1 frame // 1 tick == 1 frame
@ -493,12 +493,12 @@ void MD5Importer::LoadMD5AnimFile ()
if (!(*iter).mValues.empty()) if (!(*iter).mValues.empty())
{ {
// now process all values in there ... read all joints // now process all values in there ... read all joints
aiBoneAnim** pcAnimBone = anim->mBones; aiNodeAnim** pcAnimNode = anim->mChannels;
MD5::BaseFrameDesc* pcBaseFrame = &animParser.mBaseFrames[0]; MD5::BaseFrameDesc* pcBaseFrame = &animParser.mBaseFrames[0];
for (AnimBoneList::const_iterator for (AnimBoneList::const_iterator
iter2 = animParser.mAnimatedBones.begin(), iter2 = animParser.mAnimatedBones.begin(),
iterEnd2 = animParser.mAnimatedBones.end(); iterEnd2 = animParser.mAnimatedBones.end();
iter2 != iterEnd2;++iter2,++pcAnimBone,++pcBaseFrame) iter2 != iterEnd2;++iter2,++pcAnimNode,++pcBaseFrame)
{ {
if((*iter2).iFirstKeyIndex >= (*iter).mValues.size()) if((*iter2).iFirstKeyIndex >= (*iter).mValues.size())
{ {
@ -508,7 +508,7 @@ void MD5Importer::LoadMD5AnimFile ()
} }
const float* fpCur = &(*iter).mValues[(*iter2).iFirstKeyIndex]; const float* fpCur = &(*iter).mValues[(*iter2).iFirstKeyIndex];
aiBoneAnim* pcCurAnimBone = *pcAnimBone; aiNodeAnim* pcCurAnimBone = *pcAnimNode;
aiVectorKey* vKey = pcCurAnimBone->mPositionKeys++; aiVectorKey* vKey = pcCurAnimBone->mPositionKeys++;
// translation on the x axis // translation on the x axis
@ -557,11 +557,11 @@ void MD5Importer::LoadMD5AnimFile ()
} }
// undo our offset computations // undo our offset computations
for (unsigned int i = 0; i < anim->mNumBones;++i) for (unsigned int i = 0; i < anim->mNumChannels;++i)
{ {
aiBoneAnim* bone = anim->mBones[i]; aiNodeAnim* node = anim->mChannels[i];
bone->mPositionKeys -= bone->mNumPositionKeys; node->mPositionKeys -= node->mNumPositionKeys;
bone->mRotationKeys -= bone->mNumPositionKeys; node->mRotationKeys -= node->mNumPositionKeys;
} }
} }

View File

@ -1734,12 +1734,12 @@ void MDLImporter::BuildOutputAnims_3DGS_MDL7(
pcAnim->mDuration = std::max(pcAnim->mDuration, (double) pcAnim->mDuration = std::max(pcAnim->mDuration, (double)
apcBonesOut[i]->pkeyPositions[qq].mTime); apcBonesOut[i]->pkeyPositions[qq].mTime);
} }
++pcAnim->mNumBones; ++pcAnim->mNumChannels;
} }
} }
if (pcAnim->mDuration) if (pcAnim->mDuration)
{ {
pcAnim->mBones = new aiBoneAnim*[pcAnim->mNumBones]; pcAnim->mChannels = new aiNodeAnim*[pcAnim->mNumChannels];
unsigned int iCnt = 0; unsigned int iCnt = 0;
for (uint32_t i = 0; i < pcHeader->bones_num;++i) for (uint32_t i = 0; i < pcHeader->bones_num;++i)
@ -1748,24 +1748,24 @@ void MDLImporter::BuildOutputAnims_3DGS_MDL7(
{ {
const MDL::IntBone_MDL7* const intBone = apcBonesOut[i]; const MDL::IntBone_MDL7* const intBone = apcBonesOut[i];
aiBoneAnim* const pcBoneAnim = pcAnim->mBones[iCnt++] = new aiBoneAnim(); aiNodeAnim* const pcNodeAnim = pcAnim->mChannels[iCnt++] = new aiNodeAnim();
pcBoneAnim->mBoneName = aiString( intBone->mName ); pcNodeAnim->mNodeName = aiString( intBone->mName );
// allocate enough storage for all keys // allocate enough storage for all keys
pcBoneAnim->mNumPositionKeys = (unsigned int)intBone->pkeyPositions.size(); pcNodeAnim->mNumPositionKeys = (unsigned int)intBone->pkeyPositions.size();
pcBoneAnim->mNumScalingKeys = (unsigned int)intBone->pkeyPositions.size(); pcNodeAnim->mNumScalingKeys = (unsigned int)intBone->pkeyPositions.size();
pcBoneAnim->mNumRotationKeys = (unsigned int)intBone->pkeyPositions.size(); pcNodeAnim->mNumRotationKeys = (unsigned int)intBone->pkeyPositions.size();
pcBoneAnim->mPositionKeys = new aiVectorKey[pcBoneAnim->mNumPositionKeys]; pcNodeAnim->mPositionKeys = new aiVectorKey[pcNodeAnim->mNumPositionKeys];
pcBoneAnim->mScalingKeys = new aiVectorKey[pcBoneAnim->mNumPositionKeys]; pcNodeAnim->mScalingKeys = new aiVectorKey[pcNodeAnim->mNumPositionKeys];
pcBoneAnim->mRotationKeys = new aiQuatKey[pcBoneAnim->mNumPositionKeys]; pcNodeAnim->mRotationKeys = new aiQuatKey[pcNodeAnim->mNumPositionKeys];
// copy all keys // copy all keys
for (unsigned int qq = 0; qq < pcBoneAnim->mNumPositionKeys;++qq) for (unsigned int qq = 0; qq < pcNodeAnim->mNumPositionKeys;++qq)
{ {
pcBoneAnim->mPositionKeys[qq] = intBone->pkeyPositions[qq]; pcNodeAnim->mPositionKeys[qq] = intBone->pkeyPositions[qq];
pcBoneAnim->mScalingKeys[qq] = intBone->pkeyScalings[qq]; pcNodeAnim->mScalingKeys[qq] = intBone->pkeyScalings[qq];
pcBoneAnim->mRotationKeys[qq] = intBone->pkeyRotations[qq]; pcNodeAnim->mRotationKeys[qq] = intBone->pkeyRotations[qq];
} }
} }
} }

View File

@ -176,10 +176,10 @@ void OptimizeGraphProcess::FindLockedNodes(aiNode* node)
for (unsigned int i = 0; i < pScene->mNumAnimations;++i) for (unsigned int i = 0; i < pScene->mNumAnimations;++i)
{ {
aiAnimation* pani = pScene->mAnimations[i]; aiAnimation* pani = pScene->mAnimations[i];
for (unsigned int a = 0; a < pani->mNumBones;++a) for (unsigned int a = 0; a < pani->mNumChannels;++a)
{ {
aiBoneAnim* pba = pani->mBones[a]; aiNodeAnim* pba = pani->mChannels[a];
if (pba->mBoneName == node->mName) if (pba->mNodeName == node->mName)
{ {
// this node is locked // this node is locked
node->mNumChildren |= AI_OG_UINT_MSB; node->mNumChildren |= AI_OG_UINT_MSB;

View File

@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/** @file Implementation of the RAW importer class */ /** @file Implementation of the RAW importer class */
// internal headers // internal headers
#include "RAWLoader.h" #include "RawLoader.h"
#include "MaterialSystem.h" #include "MaterialSystem.h"
#include "ParsingUtils.h" #include "ParsingUtils.h"
#include "fast_atof.h" #include "fast_atof.h"

View File

@ -535,10 +535,10 @@ void SMDImporter::CreateOutputAnimations()
aiAnimation*& anim = this->pScene->mAnimations[0] = new aiAnimation(); aiAnimation*& anim = this->pScene->mAnimations[0] = new aiAnimation();
anim->mDuration = this->dLengthOfAnim; anim->mDuration = this->dLengthOfAnim;
anim->mNumBones = iNumBones; anim->mNumChannels = iNumBones;
anim->mTicksPerSecond = 25.0; // FIXME: is this correct? anim->mTicksPerSecond = 25.0; // FIXME: is this correct?
aiBoneAnim** pp = anim->mBones = new aiBoneAnim*[anim->mNumBones]; aiNodeAnim** pp = anim->mChannels = new aiNodeAnim*[anim->mNumChannels];
// now build valid keys // now build valid keys
unsigned int a = 0; unsigned int a = 0;
@ -548,12 +548,10 @@ void SMDImporter::CreateOutputAnimations()
{ {
if (!(*i).bIsUsed)continue; if (!(*i).bIsUsed)continue;
aiBoneAnim* p = pp[a] = new aiBoneAnim(); aiNodeAnim* p = pp[a] = new aiNodeAnim();
// copy the name of the bone // copy the name of the bone
p->mBoneName.length = (*i).mName.length(); p->mNodeName.Set( i->mName);
::memcpy(p->mBoneName.data,(*i).mName.c_str(),p->mBoneName.length);
p->mBoneName.data[p->mBoneName.length] = '\0';
p->mNumRotationKeys = (unsigned int) (*i).sAnim.asKeys.size(); p->mNumRotationKeys = (unsigned int) (*i).sAnim.asKeys.size();
if (p->mNumRotationKeys) if (p->mNumRotationKeys)

View File

@ -418,24 +418,24 @@ void ValidateDSProcess::Validate( const aiAnimation* pAnimation)
this->Validate(&pAnimation->mName); this->Validate(&pAnimation->mName);
// validate all materials // validate all materials
if (pAnimation->mNumBones) if (pAnimation->mNumChannels)
{ {
if (!pAnimation->mBones) if (!pAnimation->mChannels)
{ {
this->ReportError("aiAnimation::mBones is NULL (aiAnimation::mNumBones is %i)", this->ReportError("aiAnimation::mChannels is NULL (aiAnimation::mNumChannels is %i)",
pAnimation->mBones); pAnimation->mNumChannels);
} }
for (unsigned int i = 0; i < pAnimation->mNumBones;++i) for (unsigned int i = 0; i < pAnimation->mNumChannels;++i)
{ {
if (!pAnimation->mBones[i]) if (!pAnimation->mChannels[i])
{ {
this->ReportError("aiAnimation::mBones[%i] is NULL (aiAnimation::mNumBones is %i)", this->ReportError("aiAnimation::mChannels[%i] is NULL (aiAnimation::mNumChannels is %i)",
i,pAnimation->mNumBones); i, pAnimation->mNumChannels);
} }
this->Validate(pAnimation, pAnimation->mBones[i]); this->Validate(pAnimation, pAnimation->mChannels[i]);
} }
} }
else this->ReportError("aiAnimation::mNumBones is 0. At least one bone animation channel must be there."); else this->ReportError("aiAnimation::mNumChannels is 0. At least one node animation channel must be there.");
// Animation duration is allowed to be zero in cases where the anim contains only a single key frame. // Animation duration is allowed to be zero in cases where the anim contains only a single key frame.
// if (!pAnimation->mDuration)this->ReportError("aiAnimation::mDuration is zero"); // if (!pAnimation->mDuration)this->ReportError("aiAnimation::mDuration is zero");
@ -653,9 +653,9 @@ void ValidateDSProcess::Validate( const aiTexture* pTexture)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void ValidateDSProcess::Validate( const aiAnimation* pAnimation, void ValidateDSProcess::Validate( const aiAnimation* pAnimation,
const aiBoneAnim* pBoneAnim) const aiNodeAnim* pNodeAnim)
{ {
this->Validate(&pBoneAnim->mBoneName); this->Validate(&pNodeAnim->mNodeName);
#if 0 #if 0
// check whether there is a bone with this name ... // check whether there is a bone with this name ...
@ -665,103 +665,103 @@ void ValidateDSProcess::Validate( const aiAnimation* pAnimation,
aiMesh* mesh = this->mScene->mMeshes[i]; aiMesh* mesh = this->mScene->mMeshes[i];
for (unsigned int a = 0; a < mesh->mNumBones;++a) for (unsigned int a = 0; a < mesh->mNumBones;++a)
{ {
if (mesh->mBones[a]->mName == pBoneAnim->mBoneName) if (mesh->mBones[a]->mName == pNodeAnim->mBoneName)
goto __break_out; goto __break_out;
} }
} }
__break_out: __break_out:
if (i == this->mScene->mNumMeshes) if (i == this->mScene->mNumMeshes)
{ {
this->ReportWarning("aiBoneAnim::mBoneName is \"%s\". However, no bone with this name was found", this->ReportWarning("aiNodeAnim::mBoneName is \"%s\". However, no bone with this name was found",
pBoneAnim->mBoneName.data); pNodeAnim->mBoneName.data);
} }
if (!pBoneAnim->mNumPositionKeys && !pBoneAnim->mNumRotationKeys && !pBoneAnim->mNumScalingKeys) if (!pNodeAnim->mNumPositionKeys && !pNodeAnim->mNumRotationKeys && !pNodeAnim->mNumScalingKeys)
{ {
this->ReportWarning("A bone animation channel has no keys"); this->ReportWarning("A bone animation channel has no keys");
} }
#endif #endif
// otherwise check whether one of the keys exceeds the total duration of the animation // otherwise check whether one of the keys exceeds the total duration of the animation
if (pBoneAnim->mNumPositionKeys) if (pNodeAnim->mNumPositionKeys)
{ {
if (!pBoneAnim->mPositionKeys) if (!pNodeAnim->mPositionKeys)
{ {
this->ReportError("aiBoneAnim::mPositionKeys is NULL (aiBoneAnim::mNumPositionKeys is %i)", this->ReportError("aiNodeAnim::mPositionKeys is NULL (aiNodeAnim::mNumPositionKeys is %i)",
pBoneAnim->mNumPositionKeys); pNodeAnim->mNumPositionKeys);
} }
double dLast = -0.1; double dLast = -0.1;
for (unsigned int i = 0; i < pBoneAnim->mNumPositionKeys;++i) for (unsigned int i = 0; i < pNodeAnim->mNumPositionKeys;++i)
{ {
if (pBoneAnim->mPositionKeys[i].mTime > pAnimation->mDuration) if (pNodeAnim->mPositionKeys[i].mTime > pAnimation->mDuration)
{ {
this->ReportError("aiBoneAnim::mPositionKeys[%i].mTime (%.5f) is larger " this->ReportError("aiNodeAnim::mPositionKeys[%i].mTime (%.5f) is larger "
"than aiAnimation::mDuration (which is %.5f)",i, "than aiAnimation::mDuration (which is %.5f)",i,
(float)pBoneAnim->mPositionKeys[i].mTime, (float)pNodeAnim->mPositionKeys[i].mTime,
(float)pAnimation->mDuration); (float)pAnimation->mDuration);
} }
if (pBoneAnim->mPositionKeys[i].mTime <= dLast) if (pNodeAnim->mPositionKeys[i].mTime <= dLast)
{ {
this->ReportWarning("aiBoneAnim::mPositionKeys[%i].mTime (%.5f) is smaller " this->ReportWarning("aiNodeAnim::mPositionKeys[%i].mTime (%.5f) is smaller "
"than aiAnimation::mPositionKeys[%i] (which is %.5f)",i, "than aiAnimation::mPositionKeys[%i] (which is %.5f)",i,
(float)pBoneAnim->mPositionKeys[i].mTime, (float)pNodeAnim->mPositionKeys[i].mTime,
i-1, (float)dLast); i-1, (float)dLast);
} }
dLast = pBoneAnim->mPositionKeys[i].mTime; dLast = pNodeAnim->mPositionKeys[i].mTime;
} }
} }
// rotation keys // rotation keys
if (pBoneAnim->mNumRotationKeys) if (pNodeAnim->mNumRotationKeys)
{ {
if (!pBoneAnim->mRotationKeys) if (!pNodeAnim->mRotationKeys)
{ {
this->ReportError("aiBoneAnim::mRotationKeys is NULL (aiBoneAnim::mNumRotationKeys is %i)", this->ReportError("aiNodeAnim::mRotationKeys is NULL (aiNodeAnim::mNumRotationKeys is %i)",
pBoneAnim->mNumRotationKeys); pNodeAnim->mNumRotationKeys);
} }
double dLast = -0.1; double dLast = -0.1;
for (unsigned int i = 0; i < pBoneAnim->mNumRotationKeys;++i) for (unsigned int i = 0; i < pNodeAnim->mNumRotationKeys;++i)
{ {
if (pBoneAnim->mRotationKeys[i].mTime > pAnimation->mDuration) if (pNodeAnim->mRotationKeys[i].mTime > pAnimation->mDuration)
{ {
this->ReportError("aiBoneAnim::mRotationKeys[%i].mTime (%.5f) is larger " this->ReportError("aiNodeAnim::mRotationKeys[%i].mTime (%.5f) is larger "
"than aiAnimation::mDuration (which is %.5f)",i, "than aiAnimation::mDuration (which is %.5f)",i,
(float)pBoneAnim->mRotationKeys[i].mTime, (float)pNodeAnim->mRotationKeys[i].mTime,
(float)pAnimation->mDuration); (float)pAnimation->mDuration);
} }
if (pBoneAnim->mRotationKeys[i].mTime <= dLast) if (pNodeAnim->mRotationKeys[i].mTime <= dLast)
{ {
this->ReportWarning("aiBoneAnim::mRotationKeys[%i].mTime (%.5f) is smaller " this->ReportWarning("aiNodeAnim::mRotationKeys[%i].mTime (%.5f) is smaller "
"than aiAnimation::mRotationKeys[%i] (which is %.5f)",i, "than aiAnimation::mRotationKeys[%i] (which is %.5f)",i,
(float)pBoneAnim->mRotationKeys[i].mTime, (float)pNodeAnim->mRotationKeys[i].mTime,
i-1, (float)dLast); i-1, (float)dLast);
} }
dLast = pBoneAnim->mRotationKeys[i].mTime; dLast = pNodeAnim->mRotationKeys[i].mTime;
} }
} }
// scaling keys // scaling keys
if (pBoneAnim->mNumScalingKeys) if (pNodeAnim->mNumScalingKeys)
{ {
if (!pBoneAnim->mScalingKeys) if (!pNodeAnim->mScalingKeys)
{ {
this->ReportError("aiBoneAnim::mScalingKeys is NULL (aiBoneAnim::mNumScalingKeys is %i)", this->ReportError("aiNodeAnim::mScalingKeys is NULL (aiNodeAnim::mNumScalingKeys is %i)",
pBoneAnim->mNumScalingKeys); pNodeAnim->mNumScalingKeys);
} }
double dLast = -0.1; double dLast = -0.1;
for (unsigned int i = 0; i < pBoneAnim->mNumScalingKeys;++i) for (unsigned int i = 0; i < pNodeAnim->mNumScalingKeys;++i)
{ {
if (pBoneAnim->mScalingKeys[i].mTime > pAnimation->mDuration) if (pNodeAnim->mScalingKeys[i].mTime > pAnimation->mDuration)
{ {
this->ReportError("aiBoneAnim::mScalingKeys[%i].mTime (%.5f) is larger " this->ReportError("aiNodeAnim::mScalingKeys[%i].mTime (%.5f) is larger "
"than aiAnimation::mDuration (which is %.5f)",i, "than aiAnimation::mDuration (which is %.5f)",i,
(float)pBoneAnim->mScalingKeys[i].mTime, (float)pNodeAnim->mScalingKeys[i].mTime,
(float)pAnimation->mDuration); (float)pAnimation->mDuration);
} }
if (pBoneAnim->mScalingKeys[i].mTime <= dLast) if (pNodeAnim->mScalingKeys[i].mTime <= dLast)
{ {
this->ReportWarning("aiBoneAnim::mScalingKeys[%i].mTime (%.5f) is smaller " this->ReportWarning("aiNodeAnim::mScalingKeys[%i].mTime (%.5f) is smaller "
"than aiAnimation::mScalingKeys[%i] (which is %.5f)",i, "than aiAnimation::mScalingKeys[%i] (which is %.5f)",i,
(float)pBoneAnim->mScalingKeys[i].mTime, (float)pNodeAnim->mScalingKeys[i].mTime,
i-1, (float)dLast); i-1, (float)dLast);
} }
dLast = pBoneAnim->mScalingKeys[i].mTime; dLast = pNodeAnim->mScalingKeys[i].mTime;
} }
} }
} }

View File

@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct aiBone; struct aiBone;
struct aiMesh; struct aiMesh;
struct aiAnimation; struct aiAnimation;
struct aiBoneAnim; struct aiNodeAnim;
struct aiTexture; struct aiTexture;
struct aiMaterial; struct aiMaterial;
struct aiNode; struct aiNode;
@ -152,7 +152,7 @@ protected:
* @param pBoneAnim Input bone animation * @param pBoneAnim Input bone animation
*/ */
void Validate( const aiAnimation* pAnimation, void Validate( const aiAnimation* pAnimation,
const aiBoneAnim* pBoneAnim); const aiNodeAnim* pBoneAnim);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Validates a node and all of its subnodes /** Validates a node and all of its subnodes

View File

@ -420,15 +420,15 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData
// duration will be determined by the maximum length // duration will be determined by the maximum length
nanim->mDuration = 0; nanim->mDuration = 0;
nanim->mTicksPerSecond = pData->mAnimTicksPerSecond; nanim->mTicksPerSecond = pData->mAnimTicksPerSecond;
nanim->mNumBones = (unsigned int)anim->mAnims.size(); nanim->mNumChannels = (unsigned int)anim->mAnims.size();
nanim->mBones = new aiBoneAnim*[nanim->mNumBones]; nanim->mChannels = new aiNodeAnim*[nanim->mNumChannels];
for( unsigned int b = 0; b < anim->mAnims.size(); b++) for( unsigned int b = 0; b < anim->mAnims.size(); b++)
{ {
const XFile::AnimBone* bone = anim->mAnims[b]; const XFile::AnimBone* bone = anim->mAnims[b];
aiBoneAnim* nbone = new aiBoneAnim; aiNodeAnim* nbone = new aiNodeAnim;
nbone->mBoneName.Set( bone->mBoneName); nbone->mNodeName.Set( bone->mBoneName);
nanim->mBones[b] = nbone; nanim->mChannels[b] = nbone;
// apply the LH->RH conversion if the animation affects the root bone // apply the LH->RH conversion if the animation affects the root bone
bool isRootAnim = (bone->mBoneName == pScene->mRootNode->mName.data); bool isRootAnim = (bone->mBoneName == pScene->mRootNode->mName.data);

View File

@ -69,14 +69,11 @@ struct aiQuatKey
/** Describes the animation of a single node. The name specifies the bone/node which is affected by this /** Describes the animation of a single node. The name specifies the bone/node which is affected by this
* animation channel. The keyframes are given in three separate series of values, one each for * animation channel. The keyframes are given in three separate series of values, one each for
* position, rotation and scaling. * position, rotation and scaling.
* <br>
* NOTE: The name "BoneAnim" is misleading. This structure is also used to describe
* the animation of regular nodes on the node graph. They needn't be nodes.
*/ */
struct aiBoneAnim struct aiNodeAnim
{ {
/** The name of the bone affected by this animation. */ /** The name of the node affected by this animation. */
C_STRUCT aiString mBoneName; C_STRUCT aiString mNodeName;
/** The number of position keys */ /** The number of position keys */
unsigned int mNumPositionKeys; unsigned int mNumPositionKeys;
@ -100,14 +97,14 @@ struct aiBoneAnim
C_STRUCT aiVectorKey* mScalingKeys; C_STRUCT aiVectorKey* mScalingKeys;
#ifdef __cplusplus #ifdef __cplusplus
aiBoneAnim() aiNodeAnim()
{ {
mNumPositionKeys = 0; mPositionKeys = NULL; mNumPositionKeys = 0; mPositionKeys = NULL;
mNumRotationKeys= 0; mRotationKeys = NULL; mNumRotationKeys= 0; mRotationKeys = NULL;
mNumScalingKeys = 0; mScalingKeys = NULL; mNumScalingKeys = 0; mScalingKeys = NULL;
} }
~aiBoneAnim() ~aiNodeAnim()
{ {
if (mNumPositionKeys) if (mNumPositionKeys)
delete [] mPositionKeys; delete [] mPositionKeys;
@ -119,7 +116,7 @@ struct aiBoneAnim
#endif // __cplusplus #endif // __cplusplus
}; };
/** An animation consists of keyframe data for a number of bones. For each bone affected by the animation /** An animation consists of keyframe data for a number of nodes. For each node affected by the animation
* a separate series of data is given. * a separate series of data is given.
*/ */
struct aiAnimation struct aiAnimation
@ -134,28 +131,28 @@ struct aiAnimation
/** Ticks per second. 0 if not specified in the imported file */ /** Ticks per second. 0 if not specified in the imported file */
double mTicksPerSecond; double mTicksPerSecond;
/** The number of bone animation channels. Each channel affects a single bone. */ /** The number of bone animation channels. Each channel affects a single node. */
unsigned int mNumBones; unsigned int mNumChannels;
/** The bone animation channels. Each channel affects a single bone. The array /** The node animation channels. Each channel affects a single node. The array
* is mNumBones in size. * is mNumChannels in size.
*/ */
C_STRUCT aiBoneAnim** mBones; C_STRUCT aiNodeAnim** mChannels;
#ifdef __cplusplus #ifdef __cplusplus
aiAnimation() aiAnimation()
{ {
mDuration = 0; mDuration = 0;
mTicksPerSecond = 0; mTicksPerSecond = 0;
mNumBones = 0; mBones = NULL; mNumChannels = 0; mChannels = NULL;
} }
~aiAnimation() ~aiAnimation()
{ {
if (mNumBones) if (mNumChannels)
{ {
for( unsigned int a = 0; a < mNumBones; a++) for( unsigned int a = 0; a < mNumChannels; a++)
delete mBones[a]; delete mChannels[a];
delete [] mBones; delete [] mChannels;
} }
} }
#endif // __cplusplus #endif // __cplusplus

View File

@ -45,7 +45,7 @@ void JNIEnvironment::_assimp::_BoneAnim::Initialize()
JNIEnvironment::Get()->ThrowNativeError("Unable to load all fields of class assimp.BoneAnim"); JNIEnvironment::Get()->ThrowNativeError("Unable to load all fields of class assimp.BoneAnim");
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void JNIEnvironment::_assimp::_BoneAnim::Fill(jobject obj,const aiBoneAnim* pcSrc) void JNIEnvironment::_assimp::_BoneAnim::Fill(jobject obj,const aiNodeAnim* pcSrc)
{ {
JNIEnv* pc = JNIEnvironment::Get()->GetThread()->m_pcEnv; JNIEnv* pc = JNIEnvironment::Get()->GetThread()->m_pcEnv;

View File

@ -335,7 +335,7 @@ public:
struct _BoneAnim : public _Base struct _BoneAnim : public _Base
{ {
void Initialize(); void Initialize();
AIJ_SET_INPUT_TYPE(aiBoneAnim); AIJ_SET_INPUT_TYPE(aiNodeAnim);
//! Represents the JNI interface to class assimp.BoneAnim.KeyFrame<quak> //! Represents the JNI interface to class assimp.BoneAnim.KeyFrame<quak>
struct _KeyFrame struct _KeyFrame