Revision: 49802
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49802
Author:   aramis_acg
Date:     2012-08-11 13:21:12 +0000 (Sat, 11 Aug 2012)
Log Message:
-----------
- bf_assimp: solve this awkward 90 degree rotation. I had initially disabled it 
because it screw up armature and skinning, but this is not resolved.

Modified Paths:
--------------
    branches/soc-2012-bratwurst/source/blender/assimp/SceneOrientation.cpp

Modified: branches/soc-2012-bratwurst/source/blender/assimp/SceneOrientation.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/assimp/SceneOrientation.cpp      
2012-08-11 13:01:44 UTC (rev 49801)
+++ branches/soc-2012-bratwurst/source/blender/assimp/SceneOrientation.cpp      
2012-08-11 13:21:12 UTC (rev 49802)
@@ -92,9 +92,43 @@
 {
        assert(!deepRotate && "deepRotate not yet implemented");
 
+       // rotating root transform by 90 deg is only ok if there are no 
animations attached 
+       // to the root node in this case we need a new root node :-)
+       for (unsigned int i = 0; i < sc->mNumAnimations; ++i) {
+               const aiAnimation& anim = *sc->mAnimations[i];
+
+               for (unsigned int n = 0; n < anim.mNumChannels; ++n) {
+                       const aiNodeAnim& na = *anim.mChannels[n];
+
+                       if(na.mNodeName == sc->mRootNode->mName) {
+                               aiNode* newRoot = new 
aiNode("$AssimpDummyRoot$");
+
+                               newRoot->mChildren = new aiNode*[1];
+                               newRoot->mChildren[0] = sc->mRootNode;
+                               sc->mRootNode->mParent = newRoot;
+                               sc->mRootNode = newRoot;
+                               
+                               i = sc->mNumAnimations;
+                               break;
+                       }
+               }
+       }
+
        aiMatrix4x4 rot;
        aiMatrix4x4::RotationX(AI_MATH_HALF_PI,rot);
        sc->mRootNode->mTransformation = sc->mRootNode->mTransformation * rot;
+
+       // now the same transformation needs to be applied to all bone offset 
matrices
+       // for this we need the inverse which happens to be the transpose.
+       rot.Transpose();
+       for (unsigned int i = 0; i < sc->mNumMeshes; ++i) {
+               aiMesh& mesh = *sc->mMeshes[i];
+
+               for (unsigned int n = 0; n < mesh.mNumBones; ++n) {
+                       aiBone& b = *mesh.mBones[n];
+                       b.mOffsetMatrix = rot * b.mOffsetMatrix;
+               }
+       }
 }
 
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to