Browse Source

Merge pull request #2249 from wxyu247/dev

Update SMDImporter
Kim Kulling 6 years ago
parent
commit
9cc277607d
5 changed files with 329 additions and 362 deletions
  1. 3 7
      code/MS3DLoader.cpp
  2. 295 326
      code/SMDLoader.cpp
  3. 6 8
      code/SMDLoader.h
  4. 6 0
      include/assimp/config.h.in
  5. 19 21
      include/assimp/matrix4x4.inl

+ 3 - 7
code/MS3DLoader.cpp

@@ -181,8 +181,7 @@ void MS3DImporter :: CollectChildJoints(const std::vector<TempJoint>& joints,
             ch->mParent = nd;
             ch->mParent = nd;
 
 
             ch->mTransformation = aiMatrix4x4::Translation(joints[i].position,aiMatrix4x4()=aiMatrix4x4())*
             ch->mTransformation = aiMatrix4x4::Translation(joints[i].position,aiMatrix4x4()=aiMatrix4x4())*
-                // XXX actually, I don't *know* why we need the inverse here. Probably column vs. row order?
-                aiMatrix4x4().FromEulerAnglesXYZ(joints[i].rotation).Transpose();
+                aiMatrix4x4().FromEulerAnglesXYZ(joints[i].rotation);
 
 
             const aiMatrix4x4 abs = absTrafo*ch->mTransformation;
             const aiMatrix4x4 abs = absTrafo*ch->mTransformation;
             for(unsigned int a = 0; a < mScene->mNumMeshes; ++a) {
             for(unsigned int a = 0; a < mScene->mNumMeshes; ++a) {
@@ -639,11 +638,8 @@ void MS3DImporter::InternReadFile( const std::string& pFile,
                     aiQuatKey& q = nd->mRotationKeys[nd->mNumRotationKeys++];
                     aiQuatKey& q = nd->mRotationKeys[nd->mNumRotationKeys++];
 
 
                     q.mTime = (*rot).time*animfps;
                     q.mTime = (*rot).time*animfps;
-
-                    // XXX it seems our matrix&quaternion code has faults in its conversion routines --
-                    // aiQuaternion(x,y,z) seems to besomething different as quat(matrix.fromeuler(x,y,z)).
-                    q.mValue = aiQuaternion(aiMatrix3x3(aiMatrix4x4().FromEulerAnglesXYZ((*rot).value)*
-                        aiMatrix4x4().FromEulerAnglesXYZ((*it).rotation)).Transpose());
+                    q.mValue = aiQuaternion(aiMatrix3x3(aiMatrix4x4().FromEulerAnglesXYZ((*it).rotation)*
+                        aiMatrix4x4().FromEulerAnglesXYZ((*rot).value)));
                 }
                 }
             }
             }
 
 

File diff suppressed because it is too large
+ 295 - 326
code/SMDLoader.cpp


+ 6 - 8
code/SMDLoader.h

@@ -219,6 +219,7 @@ protected:
     /** Parse the SMD file and create the output scene
     /** Parse the SMD file and create the output scene
     */
     */
     void ParseFile();
     void ParseFile();
+    void ReadSmd(const std::string &pFile, IOSystem* pIOHandler);
 
 
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Parse the triangles section of the SMD file
     /** Parse the triangles section of the SMD file
@@ -289,13 +290,6 @@ protected:
      */
      */
     unsigned int GetTextureIndex(const std::string& filename);
     unsigned int GetTextureIndex(const std::string& filename);
 
 
-    // -------------------------------------------------------------------
-    /** Computes absolute bone transformations
-     * All output transformations are in worldspace.
-     */
-    void ComputeAbsoluteBoneTransformations();
-
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Parse a line in the skeleton section
     /** Parse a line in the skeleton section
      */
      */
@@ -344,7 +338,9 @@ protected:
      */
      */
     void CreateOutputMeshes();
     void CreateOutputMeshes();
     void CreateOutputNodes();
     void CreateOutputNodes();
-    void CreateOutputAnimations();
+    void CreateOutputAnimations(const std::string &pFile, IOSystem* pIOHandler);
+    void CreateOutputAnimation(int index, const std::string &name);
+    void GetAnimationFileList(const std::string &pFile, IOSystem* pIOHandler, std::vector<std::tuple<std::string, std::string>>& outList);
     void CreateOutputMaterials();
     void CreateOutputMaterials();
 
 
 
 
@@ -413,6 +409,8 @@ private:
      */
      */
     unsigned int iLineNumber;
     unsigned int iLineNumber;
 
 
+    bool bLoadAnimationList = true;
+    bool noSkeletonMesh = false;
 };
 };
 
 
 } // end of namespace Assimp
 } // end of namespace Assimp

+ 6 - 0
include/assimp/config.h.in

@@ -673,6 +673,12 @@ enum aiComponent
 #define AI_CONFIG_IMPORT_SMD_KEYFRAME       "IMPORT_SMD_KEYFRAME"
 #define AI_CONFIG_IMPORT_SMD_KEYFRAME       "IMPORT_SMD_KEYFRAME"
 #define AI_CONFIG_IMPORT_UNREAL_KEYFRAME    "IMPORT_UNREAL_KEYFRAME"
 #define AI_CONFIG_IMPORT_UNREAL_KEYFRAME    "IMPORT_UNREAL_KEYFRAME"
 
 
+// ---------------------------------------------------------------------------
+/** Smd load multiple animations
+ *
+ *  Property type: bool. Default value: true.
+ */
+#define AI_CONFIG_IMPORT_SMD_LOAD_ANIMATION_LIST "IMPORT_SMD_LOAD_ANIMATION_LIST"
 
 
 // ---------------------------------------------------------------------------
 // ---------------------------------------------------------------------------
 /** @brief  Configures the AC loader to collect all surfaces which have the
 /** @brief  Configures the AC loader to collect all surfaces which have the

+ 19 - 21
include/assimp/matrix4x4.inl

@@ -527,27 +527,25 @@ inline aiMatrix4x4t<TReal>& aiMatrix4x4t<TReal>::FromEulerAnglesXYZ(TReal x, TRe
 {
 {
     aiMatrix4x4t<TReal>& _this = *this;
     aiMatrix4x4t<TReal>& _this = *this;
 
 
-    TReal cr = std::cos( x );
-    TReal sr = std::sin( x );
-    TReal cp = std::cos( y );
-    TReal sp = std::sin( y );
-    TReal cy = std::cos( z );
-    TReal sy = std::sin( z );
-
-    _this.a1 = cp*cy ;
-    _this.a2 = cp*sy;
-    _this.a3 = -sp ;
-
-    TReal srsp = sr*sp;
-    TReal crsp = cr*sp;
-
-    _this.b1 = srsp*cy-cr*sy ;
-    _this.b2 = srsp*sy+cr*cy ;
-    _this.b3 = sr*cp ;
-
-    _this.c1 =  crsp*cy+sr*sy ;
-    _this.c2 =  crsp*sy-sr*cy ;
-    _this.c3 = cr*cp ;
+    TReal cx = std::cos(x);
+    TReal sx = std::sin(x);
+    TReal cy = std::cos(y);
+    TReal sy = std::sin(y);
+    TReal cz = std::cos(z);
+    TReal sz = std::sin(z);
+
+    // mz*my*mx
+    _this.a1 = cz * cy;
+    _this.a2 = cz * sy * sx - sz * cx;
+    _this.a3 = sz * sx + cz * sy * cx;
+
+    _this.b1 = sz * cy;
+    _this.b2 = cz * cx + sz * sy * sx;
+    _this.b3 = sz * sy * cx - cz * sx;
+
+    _this.c1 = -sy;
+    _this.c2 = cy * sx;
+    _this.c3 = cy * cx;
 
 
     return *this;
     return *this;
 }
 }

Some files were not shown because too many files changed in this diff