mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Merge branch 'master' into 635-nvrhi3
This commit is contained in:
commit
ace5c7e87f
4 changed files with 34 additions and 33 deletions
|
@ -31,9 +31,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#pragma hdrstop
|
||||
|
||||
// files import as y-up. Use this transform to change the model to z-up.
|
||||
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 const idMat4 blenderToDoomTransform( idAngles( 0.0f, 0.0f, 90 ).ToMat3(), vec3_origin );
|
||||
//static const idMat4 blenderToDoomTransform = mat4_identity;
|
||||
|
||||
MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* prim, gltfData* _data , const idMat4& transform )
|
||||
{
|
||||
|
@ -55,8 +54,6 @@ MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* p
|
|||
idFile_Memory idxBin = idFile_Memory( "gltfChunkIndices",
|
||||
( const char* )( ( data->GetData( bv->buffer ) + bv->byteOffset + accessor->byteOffset ) ), bv->byteLength );
|
||||
|
||||
|
||||
|
||||
for( int i = 0; i < accessor->count; i++ )
|
||||
{
|
||||
idxBin.Read( ( void* )( &indices[i] ), accessor->typeSize );
|
||||
|
@ -309,7 +306,7 @@ static void ProcessSceneNode_r( idMapEntity* newEntity, gltfNode* node, const id
|
|||
|
||||
for( auto* prim : data->MeshList()[node->mesh]->primitives )
|
||||
{
|
||||
newEntity->AddPrimitive( MapPolygonMesh::ConvertFromMeshGltf( prim, data, nodeToEntityTransform ) );
|
||||
newEntity->AddPrimitive( MapPolygonMesh::ConvertFromMeshGltf( prim, data, blenderToDoomTransform * nodeToEntityTransform ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -328,7 +325,7 @@ static void AddMeshesToWorldspawn_r( idMapEntity* entity, gltfNode* node, const
|
|||
{
|
||||
for( auto prim : data->MeshList()[node->mesh]->primitives )
|
||||
{
|
||||
entity->AddPrimitive( MapPolygonMesh::ConvertFromMeshGltf( prim, data, nodeToWorldTransform ) );
|
||||
entity->AddPrimitive( MapPolygonMesh::ConvertFromMeshGltf( prim, data, blenderToDoomTransform * nodeToWorldTransform ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -364,7 +361,7 @@ int idMapEntity::GetEntities( gltfData* data, EntityListRef entities, int sceneI
|
|||
// account all meshes starting with "worldspawn." or "BSP" in the name
|
||||
if( idStr::Icmpn( node->name, "BSP", 3 ) == 0 || idStr::Icmpn( node->name, "worldspawn.", 11 ) == 0 )
|
||||
{
|
||||
AddMeshesToWorldspawn_r( worldspawn, node, blenderToDoomTransform, data );
|
||||
AddMeshesToWorldspawn_r( worldspawn, node, mat4_identity, data );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -389,7 +386,7 @@ int idMapEntity::GetEntities( gltfData* data, EntityListRef entities, int sceneI
|
|||
// gather entity transform and bring it into id Tech 4 space
|
||||
gltfData::ResolveNodeMatrix( node );
|
||||
|
||||
idMat4 entityToWorldTransform = blenderToDoomTransform * node->matrix;
|
||||
idMat4 entityToWorldTransform = node->matrix;
|
||||
idMat4 worldToEntityTransform = entityToWorldTransform.Inverse();
|
||||
|
||||
// set entity transform in a way the game and physics code understand it
|
||||
|
|
|
@ -976,14 +976,15 @@ ID_INLINE idMat3 idMat4::ToMat3() const
|
|||
{
|
||||
idMat3 m;
|
||||
|
||||
// RB - NOTE: idMat3 is transposed because it is column-major
|
||||
m[0][0] = mat[0][0];
|
||||
m[0][1] = mat[0][1];
|
||||
m[0][2] = mat[0][2];
|
||||
m[1][0] = mat[1][0];
|
||||
m[0][1] = mat[1][0];
|
||||
m[0][2] = mat[2][0];
|
||||
m[1][0] = mat[0][1];
|
||||
m[1][1] = mat[1][1];
|
||||
m[1][2] = mat[1][2];
|
||||
m[2][0] = mat[2][0];
|
||||
m[2][1] = mat[2][1];
|
||||
m[1][2] = mat[2][1];
|
||||
m[2][0] = mat[0][2];
|
||||
m[2][1] = mat[1][2];
|
||||
m[2][2] = mat[2][2];
|
||||
|
||||
return m;
|
||||
|
|
|
@ -48,9 +48,8 @@ idCVar gltf_AnimSampleRate( "gltf_AnimSampleRate", "24", CVAR_SYSTEM | CVAR_INTE
|
|||
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 blenderToDoomAngels = idAngles( 0.0f, 0.0f, 90 );
|
||||
//static const idMat4 blenderToDoomTransform( blenderToDoomAngels.ToMat3(), vec3_origin );
|
||||
static const idMat4 blenderToDoomTransform = mat4_identity;
|
||||
static const idMat4 blenderToDoomTransform( idAngles( 0.0f, 0.0f, 90 ).ToMat3(), vec3_origin );
|
||||
//static const idMat4 blenderToDoomTransform = mat4_identity;
|
||||
static idRenderModelGLTF* lastMeshFromFile = nullptr;
|
||||
|
||||
bool idRenderModelStatic::ConvertGltfMeshToModelsurfaces( const gltfMesh* mesh )
|
||||
|
@ -58,34 +57,34 @@ bool idRenderModelStatic::ConvertGltfMeshToModelsurfaces( const gltfMesh* mesh )
|
|||
return false;
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::ProcessNode( gltfNode* modelNode, idMat4 trans, gltfData* data )
|
||||
void idRenderModelGLTF::ProcessNode_r( gltfNode* modelNode, idMat4 parentTransform, gltfData* data )
|
||||
{
|
||||
auto& meshList = data->MeshList();
|
||||
auto& nodeList = data->NodeList();
|
||||
|
||||
gltfData::ResolveNodeMatrix( modelNode );
|
||||
|
||||
idMat4 curTrans = trans * modelNode->matrix;
|
||||
idMat4 nodeToWorldTransform = parentTransform * modelNode->matrix;
|
||||
|
||||
if( modelNode->mesh >= 0 )
|
||||
{
|
||||
gltfMesh* targetMesh = meshList[modelNode->mesh];
|
||||
|
||||
idMat4 newTrans;
|
||||
idMat4 animTransform;
|
||||
|
||||
if( !animIds.Num() )
|
||||
{
|
||||
newTrans = curTrans;
|
||||
animTransform = nodeToWorldTransform;
|
||||
}
|
||||
else
|
||||
{
|
||||
newTrans = mat4_identity;
|
||||
animTransform = mat4_identity;
|
||||
}
|
||||
|
||||
for( auto prim : targetMesh->primitives )
|
||||
{
|
||||
//ConvertFromMeshGltf should only be used for the map, ConvertGltfMeshToModelsurfaces should be used.
|
||||
auto* mesh = MapPolygonMesh::ConvertFromMeshGltf( prim, data, newTrans );
|
||||
auto* mesh = MapPolygonMesh::ConvertFromMeshGltf( prim, data, animTransform * blenderToDoomTransform );
|
||||
modelSurface_t surf;
|
||||
|
||||
gltfMaterial* mat = NULL;
|
||||
|
@ -138,7 +137,7 @@ void idRenderModelGLTF::ProcessNode( gltfNode* modelNode, idMat4 trans, gltfData
|
|||
|
||||
for( auto& child : modelNode->children )
|
||||
{
|
||||
ProcessNode( nodeList[child], curTrans, data );
|
||||
ProcessNode_r( nodeList[child], nodeToWorldTransform, data );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,7 +242,7 @@ void idRenderModelGLTF::InitFromFile( const char* fileName )
|
|||
hasAnimations = totalAnims > 0;
|
||||
model_state = hasAnimations ? DM_CACHED : DM_STATIC;
|
||||
|
||||
ProcessNode( root, mat4_identity, data );
|
||||
ProcessNode_r( root, mat4_identity, data );
|
||||
|
||||
if( surfaces.Num() <= 0 )
|
||||
{
|
||||
|
@ -538,7 +537,7 @@ idList<idJointQuat> GetPose( idList<gltfNode>& bones, idJointMat* poseMat )
|
|||
}
|
||||
|
||||
idJointQuat& pose = ret[i];
|
||||
pose.q = ( trans.ToMat3().Transpose().ToQuat() );
|
||||
pose.q = ( trans.ToMat3().ToQuat() );
|
||||
pose.t = idVec3( trans[0][3], trans[1][3], trans[2][3] );
|
||||
pose.w = pose.q.CalcW();
|
||||
}
|
||||
|
@ -830,11 +829,15 @@ idFile_Memory* idRenderModelGLTF::GetAnimBin( idStr animName , const ID_TIME_T
|
|||
{
|
||||
if( node->parent == nullptr )
|
||||
{
|
||||
q = blenderToDoomAngels.ToQuat() * animBones[i][b].rotation;
|
||||
if( animBones[i].Num() == 1 )
|
||||
{
|
||||
q = -animBones[i][b].rotation;
|
||||
}
|
||||
//q = blenderToDoomAngels.ToQuat() * animBones[i][b].rotation;
|
||||
|
||||
q = blenderToDoomTransform.ToMat3().ToQuat() * animBones[i][b].rotation;
|
||||
|
||||
//if( animBones[i].Num() == 1 )
|
||||
//{
|
||||
// this is not hit
|
||||
// q = -animBones[i][b].rotation;
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
static idFile_Memory* GetAnimBin( idStr animName, const ID_TIME_T sourceTimeStamp );
|
||||
int rootID;
|
||||
private:
|
||||
void ProcessNode( gltfNode* modelNode, idMat4 trans, gltfData* data );
|
||||
void ProcessNode_r( gltfNode* modelNode, idMat4 trans, gltfData* data );
|
||||
void UpdateSurface( const struct renderEntity_s* ent, const idJointMat* entJoints, const idJointMat* entJointsInverted, modelSurface_t* surf, const modelSurface_t& sourceSurf );
|
||||
void UpdateMd5Joints();
|
||||
|
||||
|
|
Loading…
Reference in a new issue