• Advertisement

Sung Woo Yeo

Member
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

1 Neutral

About Sung Woo Yeo

  • Rank
    Newbie

Personal Information

  • Interests
    Education
    Programming

Social

  • Github
    https://github.com/yeosu0107
  1. Use assimp for skeletal animation HELP!

    Hey Guys I've completely fixed everything! It's matter about transpos matrix Previously, I applied transpos function to the bone offset and mTranslation of the node (that is, i applied transpos when I read aiMatrix4x4) but after trying many different things, I found it to be wrong Exactly, there is an aiMatrix4x4 which should apply transpos and aiMatrix4x4 should not apply In my case, I applied transpos only result of transformation This is my codes void LoadAnimation::ReadNodeHeirarchy(float AnimationTime, const aiNode * pNode, const XMMATRIX& ParentTransform) { string NodeName(pNode->mName.data); const aiAnimation* pAnim = m_pScene->mAnimations[0]; XMMATRIX NodeTransformation = XMMATRIX(&pNode->mTransformation.a1); //I just read aiMatrix4x4 (aiMatrix to XMMATRIX format) const aiNodeAnim* pNodeAnim = FindNodeAnim(pAnim, NodeName); XMMATRIX anim = XMMatrixIdentity(); if (pNodeAnim) { aiVector3D s; CalcInterpolatedScaling(s, AnimationTime, pNodeAnim); XMMATRIX ScalingM = XMMatrixScaling(s.x, s.y, s.z); aiQuaternion q; CalcInterpolatedRotation(q, AnimationTime, pNodeAnim); XMMATRIX RotationM = XMMatrixRotationQuaternion(XMVectorSet(q.x, q.y, q.z, q.w)); aiVector3D t; CalcInterpolatedPosition(t, AnimationTime, pNodeAnim); XMMATRIX TranslationM = XMMatrixTranslation(t.x, t.y, t.z); NodeTransformation = ScalingM * RotationM * TranslationM; NodeTransformation = XMMatrixTranspose(NodeTransformation); //I applied transpos } XMMATRIX GlobalTransformation = ParentTransform * NodeTransformation; for (auto& p : m_Bones) { if (p.first == NodeName) { p.second.FinalTransformation = m_GlobalInverse * GlobalTransformation * p.second.BoneOffset; break; } } for (UINT i = 0; i < pNode->mNumChildren; ++i) { ReadNodeHeirarchy(AnimationTime, pNode->mChildren[i], GlobalTransformation); } } If I read bone offset and mTransformation about node(aiMatrix4x4), I simply transformed it into XMMATRIX format // XMMATRIX(&aiMatrix4x4.a1) second, If current node is a node belonging to the animation channel, and S R T transformation is performed, transpos is applied to the transformation The important this is that we don't apply the transpos to the parent nodes matrix (if parent node conduct transpos function, there is a risk that it will be performed twice) This is the result PS. I hope this post helps people using directX and assimp assimp library has some bugs that some models using fbx format are broken I know that the assimp team is fixing it I was able to observe that, in general, if the viewer provided by assimp show broken results, my result are also broken.
  2. Use assimp for skeletal animation HELP!

    You inspired me! thanks I ignored the animation imported from assimp and just tried rotation the bones and As a result, I found the axis of rotaion to be strange. As I predicted above, the axis was applied differently from the original (the center of the second mesh) So many of the advice and functions we've got from above seem to have been inadequately applied And i have one question Maybe i misunderstood, Are you telling me not to apply all animations from root node? I think that read all child nodes from the root node and multiply the transformations( rot, scaling, shifting) and if current node is bone, apply the multiplied transformation value up to now It is wrong???
  3. Use assimp for skeletal animation HELP!

    I accept the idea of testin with a simple model so got simple models of two bone first It is ideal result It has a blue circle with its aixs of rotation (com up and down around the axis) but my result ( fix transpos ploblem and GlobalTransformation and etc...) is like this the axis is center of the cube it also come up and down but different axis give completely different results I attach my modified codes 1. load bone data void LoadModel::InitBones(UINT index, const aiMesh* pMesh) { for (UINT i = 0; i < pMesh->mNumBones; ++i) { int BoneIndex = -1; string BoneName(pMesh->mBones[i]->mName.data); int tmpIndex = 0; for (const auto& p : m_Bones) { if (p.first == BoneName) { BoneIndex = tmpIndex; break; } tmpIndex++; } if (BoneIndex < 0) { BoneIndex = (int)m_Bones.size(); Bone bone; bone.BoneOffset = aiMatrixToXMMatrix(pMesh->mBones[BoneIndex]->mOffsetMatrix); m_Bones.emplace_back(make_pair(BoneName, bone)); } const aiBone* pBone = pMesh->mBones[BoneIndex]; for (UINT b = 0; b < pBone->mNumWeights; ++b) { UINT vertexID = pBone->mWeights[b].mVertexId; float weight = pBone->mWeights[b].mWeight; m_meshes[index].m_vertices[vertexID].AddBoneData(BoneIndex, weight); } } } 2. ReadNodeHeirarchy void LoadAnimation::ReadNodeHeirarchy(float AnimationTime, const aiNode * pNode, const XMMATRIX& ParentTransform) { string NodeName(pNode->mName.data); const aiAnimation* pAnim = m_pScene->mAnimations[0]; XMMATRIX NodeTransformation = aiMatrixToXMMatrix(pNode->mTransformation); const aiNodeAnim* pNodeAnim = FindNodeAnim(pAnim, NodeName); if (pNodeAnim) { aiVector3D s; CalcInterpolatedScaling(s, AnimationTime, pNodeAnim); XMMATRIX ScalingM = XMMatrixScaling(s.x, s.y, s.z); aiQuaternion q; CalcInterpolatedRotation(q, AnimationTime, pNodeAnim); XMMATRIX RotationM = XMMatrixRotationQuaternion(XMVectorSet(q.x, q.y, q.z, q.w)); aiVector3D t; CalcInterpolatedPosition(t, AnimationTime, pNodeAnim); XMMATRIX TranslationM = XMMatrixTranslation(t.x, t.y, t.z); NodeTransformation = ScalingM * RotationM * TranslationM; } XMMATRIX GlobalTransformation = NodeTransformation * ParentTransform; for (auto& p : m_Bones) { if (p.first == NodeName) { p.second.FinalTransformation = m_GlobalInverse * GlobalTransformation * p.second.BoneOffset; break; } } for (UINT i = 0; i < pNode->mNumChildren; ++i) { ReadNodeHeirarchy(AnimationTime, pNode->mChildren[i], GlobalTransformation); } } aiMatrixToXMMatrix function is like your(Ivan Terziev) function i want you to take a look at it very thanks!
  4. Use assimp for skeletal animation HELP!

    Thanks for your response I have some questions First you say that I shouldn't be transposing matrices when read them from assimp, but I think that assimp is opengl format so would i have to do transpose to get the correct col/row ? Actually, I tried removing transpos function when using assimp to read my model, but the result is very bad (It was completely disassembled) second I agree that you told me to do S * R * T because I saw it in my book when i was studying but strangely the result of S * R * T and T * R * S were same, so i didn't fix it hmmm..... assimp is very useful library to load fbx format but load anmation, it's very hardly... I don't have enough English skills to read it so you would be inconvenient to read it Thank you for your faithful reply!
  5. Use assimp for skeletal animation HELP!

    First thank for your Idea I don't know when quaternion is xyzw or wxyz Many articles just tell them to be careful It is very difficult...
  6. Use assimp for skeletal animation HELP!

    thank you for your answer I'll take your idea and try to test it wiht a simple model
  7. Use assimp for skeletal animation HELP!

    first Thank you for your answer I have some questions for you. you told me to count 'BoneOffset * GlobalTransformation * m_blobalInverse' but if I calculate that equation, the model is completyely broken And I use this function to load XMMATRIX from aiMatirx4x4 XMMATRIX(&pNode->mTransformation.a1); 'pNode->mTransformation' is type aiMatrix4x4 I think it is no ploblem because XMMATRIX can put the argument values of the array please, I want you to tell me what method you used thank you
  8. Guys, I've spent a lot of time to load skeletal animation but It is very difficult... I refer to http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html but I didn't get the results I wanted Please Help Me This is my codes void LoadAnimation::BoneTransform(float time, vector<XMFLOAT4X4>& transforms) { XMMATRIX Identity = XMMatrixIdentity(); float TicksPerSecond = (float)(m_pScene->mAnimations[0]->mTicksPerSecond != 0 ? m_pScene->mAnimations[0]->mTicksPerSecond : 25.0f); float TimeInTicks = time*TicksPerSecond; float AnimationTime = fmod(TimeInTicks, (float)m_pScene->mAnimations[0]->mDuration); ReadNodeHeirarchy(AnimationTime, m_pScene->mRootNode, Identity); transforms.resize(m_NumBones); for (int i = 0; i < m_NumBones; ++i) { XMStoreFloat4x4(&transforms[i], m_Bones[i].second.FinalTransformation); } } void LoadAnimation::ReadNodeHeirarchy(float AnimationTime, const aiNode * pNode, const XMMATRIX& ParentTransform) { string NodeName(pNode->mName.data); const aiAnimation* pAnim = m_pScene->mAnimations[0]; XMMATRIX NodeTransformation = XMMATRIX(&pNode->mTransformation.a1); const aiNodeAnim* pNodeAnim = FindNodeAnim(pAnim, NodeName); if (pNodeAnim) { aiVector3D scaling; CalcInterpolatedScaling(scaling, AnimationTime, pNodeAnim); XMMATRIX ScalingM = XMMatrixScaling(scaling.x, scaling.y, scaling.z); ScalingM = XMMatrixTranspose(ScalingM); aiQuaternion q; CalcInterpolatedRotation(q, AnimationTime, pNodeAnim); XMMATRIX RotationM = XMMatrixRotationQuaternion(XMVectorSet(q.x, q.y, q.z, q.w)); RotationM = XMMatrixTranspose(RotationM); aiVector3D t; CalcInterpolatedPosition(t, AnimationTime, pNodeAnim); XMMATRIX TranslationM = XMMatrixTranslation(t.x, t.y, t.z); TranslationM = XMMatrixTranspose(TranslationM); NodeTransformation = TranslationM * RotationM * ScalingM; } XMMATRIX GlobalTransformation = ParentTransform * NodeTransformation; int tmp = 0; for (auto& p : m_Bones) { if (p.first == NodeName) { p.second.FinalTransformation = XMMatrixTranspose( m_GlobalInverse * GlobalTransformation * p.second.BoneOffset); break; } tmp += 1; } for (UINT i = 0; i < pNode->mNumChildren; ++i) { ReadNodeHeirarchy(AnimationTime, pNode->mChildren[i], GlobalTransformation); } } CalcInterp~ function and Find~ function are like a tutorial (http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html) I think that I'm doing the multiplication wrong but I don't know where it went wrong If you want, i wall post other codes. here is my result (hands are stretched, legs are strange) and it is ideal result
  • Advertisement