diff --git a/neo/renderer/Model_gltf.cpp b/neo/renderer/Model_gltf.cpp index 5590bed0..3f42932d 100644 --- a/neo/renderer/Model_gltf.cpp +++ b/neo/renderer/Model_gltf.cpp @@ -45,11 +45,12 @@ idCVar gltf_ModelSceneName( "gltf_ModelSceneName", "models", CVAR_SYSTEM , "Scen idCVar gltf_AnimSampleRate( "gltf_AnimSampleRate", "24", CVAR_SYSTEM | CVAR_INTEGER , "The frame rate of the converted md5anim" ); -static const byte GLMB_VERSION = 100; +static const byte GLMB_VERSION = 101; static const unsigned int GLMB_MAGIC = ( 'M' << 24 ) | ( 'L' << 16 ) | ( 'G' << 8 ) | GLMB_VERSION; static const char* GLTF_SnapshotName = "_GLTF_Snapshot_"; -static const idAngles axisTransformAngels = idAngles( 0.0f, 0.0f, 90 ); -static const idMat4 axisTransform( axisTransformAngels.ToMat3(), vec3_origin ); +static const idAngles blenderToDoomAngels = idAngles( 0.0f, 0.0f, 90 ); +//static const idMat4 blenderToDoomTransform( blenderToDoomAngels.ToMat3(), vec3_origin ); +static const idMat4 blenderToDoomTransform = mat4_identity; static idRenderModelGLTF* lastMeshFromFile = nullptr; bool idRenderModelStatic::ConvertGltfMeshToModelsurfaces( const gltfMesh* mesh ) @@ -533,7 +534,7 @@ idList GetPose( idList& bones, idJointMat* poseMat ) if( node->parent == nullptr ) { - node->matrix *= axisTransform; + node->matrix *= blenderToDoomTransform; } idJointQuat& pose = ret[i]; @@ -743,7 +744,7 @@ idFile_Memory* idRenderModelGLTF::GetAnimBin( idStr animName , const ID_TIME_T skin->joints.AssureSize( 1, data->GetNodeIndex( root ) ); idMat4 trans = mat4_identity; data->ResolveNodeMatrix( root, &trans ); - trans *= axisTransform.Inverse(); + trans *= blenderToDoomTransform.Inverse(); acc = new gltfAccessor(); acc->matView = new idList( 1 ); acc->matView->AssureSize( 1, trans.Inverse().Transpose() ); @@ -817,19 +818,19 @@ idFile_Memory* idRenderModelGLTF::GetAnimBin( idStr animName , const ID_TIME_T { if( node->parent == nullptr ) { - t = axisTransform * t; + t = blenderToDoomTransform * t; } componentFrames[componentFrameIndex++] = t.x; componentFrames[componentFrameIndex++] = t.y; componentFrames[componentFrameIndex++] = t.z; } + if( joint->animBits & ( ANIM_QX | ANIM_QY | ANIM_QZ ) ) { - if( node->parent == nullptr ) { - q = axisTransformAngels.ToQuat() * animBones[i][b].rotation; + q = blenderToDoomAngels.ToQuat() * animBones[i][b].rotation; if( animBones[i].Num() == 1 ) { q = -animBones[i][b].rotation; @@ -863,7 +864,7 @@ idFile_Memory* idRenderModelGLTF::GetAnimBin( idStr animName , const ID_TIME_T { if( animBones[i][b].parent == nullptr ) { - animBones[i][b].translation = axisTransform * animBones[i][b].translation; + animBones[i][b].translation = blenderToDoomTransform * animBones[i][b].translation; } }