mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Added idMat4::GetTranslation() and some comments
This commit is contained in:
parent
9f50dbc9bc
commit
891ba7478e
2 changed files with 28 additions and 7 deletions
|
@ -457,10 +457,12 @@ void ResolveLight( gltfData* data, idMapEntity* newEntity, gltfNode* node )
|
|||
|
||||
case gltfExt_KHR_lights_punctual::Spot:
|
||||
{
|
||||
// RB: this code is based on Cmd_TestLight_f which sets the light properties in world space
|
||||
idMat4 entityToWorldTransform = mat4_identity;
|
||||
gltfData::ResolveNodeMatrix( node, &entityToWorldTransform );
|
||||
float fov = tan( light->spot.outerConeAngle ) / 2 ;
|
||||
|
||||
// HarrievG: TODO cleanup this was done by try & error until it worked
|
||||
idQuat q = ( entityToWorldTransform ).ToMat3().ToQuat();
|
||||
q = idAngles( 90.0f, 0.0, -90.0f ).ToQuat() * q * idAngles( 180.0f, 180.0f, -90.0f ).ToQuat();
|
||||
idMat3 axis = q.ToMat3();
|
||||
|
@ -506,12 +508,14 @@ void ResolveEntity( gltfData* data, idMapEntity* newEntity, gltfNode* node )
|
|||
newPairs.SetDefaults( &newEntity->epairs );
|
||||
newEntity->epairs = newPairs;
|
||||
|
||||
idMat4 entityTransform = mat4_identity;
|
||||
// gather entity transform and bring it into id Tech 4 space
|
||||
gltfData::ResolveNodeMatrix( node, &entityTransform );
|
||||
idMat4 entityToWorldTransform = mat4_identity;
|
||||
gltfData::ResolveNodeMatrix( node, &entityToWorldTransform );
|
||||
|
||||
// set entity transform in a way the game and physics code understand it
|
||||
idVec3 origin = blenderToDoomTransform * node->translation;
|
||||
// RB: should be idVec3 origin = ( blenderToDoomTransform * entityToWorldTransform ).GetTranslation();
|
||||
|
||||
newEntity->epairs.SetVector( "origin", origin );
|
||||
|
||||
if( node->extensions.KHR_lights_punctual != nullptr )
|
||||
|
@ -519,15 +523,16 @@ void ResolveEntity( gltfData* data, idMapEntity* newEntity, gltfNode* node )
|
|||
ResolveLight( data, newEntity, node );
|
||||
}
|
||||
|
||||
// HarrievG: TODO cleanup this was done by try & error until it worked
|
||||
if( node->camera >= 0 && !newEntity->epairs.FindKey( "rotation" ) )
|
||||
{
|
||||
idQuat q = entityTransform.ToMat3().ToQuat();
|
||||
idQuat q = entityToWorldTransform.ToMat3().ToQuat();
|
||||
q = idAngles( 90.0f, 0.0, -90.0f ).ToQuat() * q * blenderToDoomTransform.ToMat3().ToQuat();
|
||||
newEntity->epairs.SetMatrix( "rotation", q.ToMat3() );
|
||||
}
|
||||
else if( idStr::Icmp( classname, "info_player_start" ) == 0 && !newEntity->epairs.FindKey( "rotation" ) )
|
||||
{
|
||||
idQuat q = entityTransform.ToMat3().ToQuat();
|
||||
idQuat q = entityToWorldTransform.ToMat3().ToQuat();
|
||||
q = idAngles( -90.0f, 0.0, -90.0f ).ToQuat() * q * blenderToDoomTransform.ToMat3().ToQuat();
|
||||
newEntity->epairs.SetMatrix( "rotation", q.ToMat3() );
|
||||
}
|
||||
|
@ -535,12 +540,14 @@ void ResolveEntity( gltfData* data, idMapEntity* newEntity, gltfNode* node )
|
|||
{
|
||||
//Nodes that are an instance of an collection containing a mesh that is not inline, ea; a gltfModel; static _or_ dynamic,
|
||||
//which has its transformations applied on vertex level so we do not apply it here.
|
||||
origin = blenderToDoomTransform * ( node->translation * ( entityTransform * node->matrix.Inverse() ) );
|
||||
origin = blenderToDoomTransform * ( node->translation * ( entityToWorldTransform * node->matrix.Inverse() ) );
|
||||
newEntity->epairs.SetVector( "origin", origin );
|
||||
|
||||
idQuat q = ( entityTransform * node->matrix.Inverse() ).ToMat3().ToQuat();
|
||||
idQuat q = ( entityToWorldTransform * node->matrix.Inverse() ).ToMat3().ToQuat();
|
||||
q = blenderToDoomTransform.Inverse().ToMat3().ToQuat() * q * blenderToDoomTransform.ToMat3().ToQuat();
|
||||
newEntity->epairs.SetMatrix( "rotation", q.ToMat3() );
|
||||
idMat3 rot = q.ToMat3();
|
||||
//idMat3 rot = ( blenderToDoomTransform * entityToWorldTransform ).ToMat3();
|
||||
newEntity->epairs.SetMatrix( "rotation", rot );
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -963,6 +963,7 @@ public:
|
|||
// jmarshall
|
||||
idMat3 ToMat3() const;
|
||||
// jmarshall end
|
||||
idVec3 GetTranslation() const;
|
||||
private:
|
||||
idVec4 mat[ 4 ];
|
||||
};
|
||||
|
@ -991,6 +992,19 @@ ID_INLINE idMat3 idMat4::ToMat3() const
|
|||
}
|
||||
// jmarshall end
|
||||
|
||||
// RB begin
|
||||
ID_INLINE idVec3 idMat4::GetTranslation() const
|
||||
{
|
||||
idVec3 pos;
|
||||
|
||||
pos.x = mat[ 0 ][ 3 ];
|
||||
pos.y = mat[ 1 ][ 3 ];
|
||||
pos.z = mat[ 2 ][ 3 ];
|
||||
|
||||
return pos;
|
||||
}
|
||||
// RB end
|
||||
|
||||
ID_INLINE idMat4::idMat4()
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue