Merge pull request #2249 from wxyu247/dev

Update SMDImporter
pull/2219/head^2
Kim Kulling 2018-12-01 09:42:41 +01:00 committed by GitHub
commit 9cc277607d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 388 additions and 453 deletions

View File

@ -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);
aiMatrix4x4().FromEulerAnglesXYZ(joints[i].rotation).Transpose();
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;
q.mValue = aiQuaternion(aiMatrix3x3(aiMatrix4x4().FromEulerAnglesXYZ((*it).rotation)*
// XXX it seems our matrix&quaternion code has faults in its conversion routines -- aiMatrix4x4().FromEulerAnglesXYZ((*rot).value)));
// 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());
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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

View File

@ -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 cx = std::cos(x);
TReal sr = std::sin( x ); TReal sx = std::sin(x);
TReal cp = std::cos( y ); TReal cy = std::cos(y);
TReal sp = std::sin( y ); TReal sy = std::sin(y);
TReal cy = std::cos( z ); TReal cz = std::cos(z);
TReal sy = std::sin( z ); TReal sz = std::sin(z);
_this.a1 = cp*cy ; // mz*my*mx
_this.a2 = cp*sy; _this.a1 = cz * cy;
_this.a3 = -sp ; _this.a2 = cz * sy * sx - sz * cx;
_this.a3 = sz * sx + cz * sy * cx;
TReal srsp = sr*sp; _this.b1 = sz * cy;
TReal crsp = cr*sp; _this.b2 = cz * cx + sz * sy * sx;
_this.b3 = sz * sy * cx - cz * sx;
_this.b1 = srsp*cy-cr*sy ; _this.c1 = -sy;
_this.b2 = srsp*sy+cr*cy ; _this.c2 = cy * sx;
_this.b3 = sr*cp ; _this.c3 = cy * cx;
_this.c1 = crsp*cy+sr*sy ;
_this.c2 = crsp*sy-sr*cy ;
_this.c3 = cr*cp ;
return *this; return *this;
} }