BREAKING CHANGE: aiQuaternion + / aiQuaternion to aiMatrix conversion does now conform to the 'usual' quaternion conventions. See the discussion at https://sourceforge.net/projects/assimp/forums/forum/817653/topic/3442128 for all the details.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@502 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
89475c7e42
commit
35cfb90e6f
|
@ -505,6 +505,12 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,
|
|||
// Now build the transformation matrix of the node
|
||||
// ROTATION
|
||||
if (pcIn->aRotationKeys.size()){
|
||||
|
||||
// FIX to get to Assimp's quaternion conventions
|
||||
for (std::vector<aiQuatKey>::iterator it = pcIn->aRotationKeys.begin(); it != pcIn->aRotationKeys.end(); ++it) {
|
||||
(*it).mValue.w *= -1.f;
|
||||
}
|
||||
|
||||
pcOut->mTransformation = aiMatrix4x4( pcIn->aRotationKeys[0].mValue.GetMatrix() );
|
||||
}
|
||||
else if (pcIn->aCameraRollKeys.size())
|
||||
|
@ -554,7 +560,9 @@ void Discreet3DSImporter::AddNodeToGraph(aiScene* pcSOut,aiNode* pcOut,
|
|||
aiFloatKey& f = pcIn->aCameraRollKeys[i];
|
||||
|
||||
q.mTime = f.mTime;
|
||||
q.mValue = aiQuaternion(0.f,0.f,AI_DEG_TO_RAD(- f.mValue));
|
||||
|
||||
// FIX to get to Assimp quaternion conventions
|
||||
q.mValue = aiQuaternion(0.f,0.f,AI_DEG_TO_RAD( /*-*/ f.mValue));
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
|
|
|
@ -375,6 +375,9 @@ void ASEImporter::BuildAnimations()
|
|||
q.mValue = cur.Normalize();
|
||||
}
|
||||
nd->mRotationKeys[a] = q;
|
||||
|
||||
// need this to get to Assimp quaternion conventions
|
||||
nd->mRotationKeys[a].mValue.w *= -1.f;
|
||||
}
|
||||
}
|
||||
// copy scaling keys
|
||||
|
|
|
@ -507,6 +507,11 @@ void AnimResolver::ExtractAnimChannel(aiNodeAnim** out, unsigned int flags /*= 0
|
|||
{
|
||||
*out = NULL;
|
||||
|
||||
|
||||
//FIXME: crashes if more than one component is animated at different timings, to be resolved.
|
||||
return;
|
||||
|
||||
#if 0
|
||||
// If we have no envelopes, return NULL
|
||||
if (envelopes.empty()) {
|
||||
return;
|
||||
|
@ -560,6 +565,7 @@ void AnimResolver::ExtractAnimChannel(aiNodeAnim** out, unsigned int flags /*= 0
|
|||
anim->mScalingKeys = new aiVectorKey[ anim->mNumScalingKeys = keys.size() ];
|
||||
std::copy(keys.begin(),keys.end(),anim->mScalingKeys);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -246,6 +246,9 @@ void MD5Importer::AttachChilds_Mesh(int iParentID,aiNode* piParent, BoneList& bo
|
|||
aiQuaternion quat;
|
||||
MD5::ConvertQuaternion ( bones[i].mRotationQuat, quat );
|
||||
|
||||
// FIX to get to Assimp's quaternion conventions
|
||||
quat.w *= -1.f;
|
||||
|
||||
bones[i].mTransform = aiMatrix4x4 ( quat.GetMatrix());
|
||||
bones[i].mTransform.a4 = bones[i].mPositionXYZ.x;
|
||||
bones[i].mTransform.b4 = bones[i].mPositionXYZ.y;
|
||||
|
@ -612,6 +615,9 @@ void MD5Importer::LoadMD5AnimFile ()
|
|||
|
||||
MD5::ConvertQuaternion(vTemp, qKey->mValue);
|
||||
qKey->mTime = vKey->mTime = dTime;
|
||||
|
||||
// we need this to get to Assimp quaternion conventions
|
||||
qKey->mValue.w *= -1.f;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -504,6 +504,7 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData
|
|||
|
||||
nbone->mRotationKeys[c].mTime = bone->mRotKeys[c].mTime;
|
||||
nbone->mRotationKeys[c].mValue = aiQuaternion( rotmat);
|
||||
nbone->mRotationKeys[c].mValue.w *= -1.0f; // needs quat inversion
|
||||
}
|
||||
|
||||
// scaling
|
||||
|
|
|
@ -120,9 +120,9 @@ inline aiQuaternion::aiQuaternion( const aiMatrix3x3 &pRotMatrix)
|
|||
if( t > 0.001f)
|
||||
{
|
||||
float s = sqrt( t) * 2.0f;
|
||||
x = (pRotMatrix.b3 - pRotMatrix.c2) / s;
|
||||
y = (pRotMatrix.c1 - pRotMatrix.a3) / s;
|
||||
z = (pRotMatrix.a2 - pRotMatrix.b1) / s;
|
||||
x = (pRotMatrix.c2 - pRotMatrix.b3) / s;
|
||||
y = (pRotMatrix.a3 - pRotMatrix.c1) / s;
|
||||
z = (pRotMatrix.b1 - pRotMatrix.a2) / s;
|
||||
w = 0.25f * s;
|
||||
} // else we have to check several cases
|
||||
else if( pRotMatrix.a1 > pRotMatrix.b2 && pRotMatrix.a1 > pRotMatrix.c3 )
|
||||
|
@ -130,26 +130,26 @@ inline aiQuaternion::aiQuaternion( const aiMatrix3x3 &pRotMatrix)
|
|||
// Column 0:
|
||||
float s = sqrt( 1.0f + pRotMatrix.a1 - pRotMatrix.b2 - pRotMatrix.c3) * 2.0f;
|
||||
x = 0.25f * s;
|
||||
y = (pRotMatrix.a2 + pRotMatrix.b1) / s;
|
||||
z = (pRotMatrix.c1 + pRotMatrix.a3) / s;
|
||||
w = (pRotMatrix.b3 - pRotMatrix.c2) / s;
|
||||
y = (pRotMatrix.b1 + pRotMatrix.a2) / s;
|
||||
z = (pRotMatrix.a3 + pRotMatrix.c1) / s;
|
||||
w = (pRotMatrix.c2 - pRotMatrix.b3) / s;
|
||||
}
|
||||
else if( pRotMatrix.b2 > pRotMatrix.c3)
|
||||
{
|
||||
// Column 1:
|
||||
float s = sqrt( 1.0f + pRotMatrix.b2 - pRotMatrix.a1 - pRotMatrix.c3) * 2.0f;
|
||||
x = (pRotMatrix.a2 + pRotMatrix.b1) / s;
|
||||
x = (pRotMatrix.b1 + pRotMatrix.a2) / s;
|
||||
y = 0.25f * s;
|
||||
z = (pRotMatrix.b3 + pRotMatrix.c2) / s;
|
||||
w = (pRotMatrix.c1 - pRotMatrix.a3) / s;
|
||||
z = (pRotMatrix.c2 + pRotMatrix.b3) / s;
|
||||
w = (pRotMatrix.a3 - pRotMatrix.c1) / s;
|
||||
} else
|
||||
{
|
||||
// Column 2:
|
||||
float s = sqrt( 1.0f + pRotMatrix.c3 - pRotMatrix.a1 - pRotMatrix.b2) * 2.0f;
|
||||
x = (pRotMatrix.c1 + pRotMatrix.a3) / s;
|
||||
y = (pRotMatrix.b3 + pRotMatrix.c2) / s;
|
||||
x = (pRotMatrix.a3 + pRotMatrix.c1) / s;
|
||||
y = (pRotMatrix.c2 + pRotMatrix.b3) / s;
|
||||
z = 0.25f * s;
|
||||
w = (pRotMatrix.a2 - pRotMatrix.b1) / s;
|
||||
w = (pRotMatrix.b1 - pRotMatrix.a2) / s;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,13 +177,13 @@ inline aiMatrix3x3 aiQuaternion::GetMatrix() const
|
|||
{
|
||||
aiMatrix3x3 resMatrix;
|
||||
resMatrix.a1 = 1.0f - 2.0f * (y * y + z * z);
|
||||
resMatrix.a2 = 2.0f * (x * y + z * w);
|
||||
resMatrix.a3 = 2.0f * (x * z - y * w);
|
||||
resMatrix.b1 = 2.0f * (x * y - z * w);
|
||||
resMatrix.a2 = 2.0f * (x * y - z * w);
|
||||
resMatrix.a3 = 2.0f * (x * z + y * w);
|
||||
resMatrix.b1 = 2.0f * (x * y + z * w);
|
||||
resMatrix.b2 = 1.0f - 2.0f * (x * x + z * z);
|
||||
resMatrix.b3 = 2.0f * (y * z + x * w);
|
||||
resMatrix.c1 = 2.0f * (x * z + y * w);
|
||||
resMatrix.c2 = 2.0f * (y * z - x * w);
|
||||
resMatrix.b3 = 2.0f * (y * z - x * w);
|
||||
resMatrix.c1 = 2.0f * (x * z - y * w);
|
||||
resMatrix.c2 = 2.0f * (y * z + x * w);
|
||||
resMatrix.c3 = 1.0f - 2.0f * (x * x + y * y);
|
||||
|
||||
return resMatrix;
|
||||
|
|
|
@ -1 +1 @@
|
|||
#define SVNRevision 467
|
||||
#define SVNRevision 501
|
||||
|
|
Loading…
Reference in New Issue