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
0991956693
5 changed files with 76 additions and 25 deletions
|
@ -164,6 +164,10 @@ MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* p
|
|||
normal.z = vec.z;
|
||||
|
||||
normal *= transform;
|
||||
|
||||
// renormalize because previous transforms may contain scale operations
|
||||
normal.Normalize();
|
||||
|
||||
mesh->verts[i].SetNormal( normal );
|
||||
}
|
||||
|
||||
|
@ -208,6 +212,7 @@ MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* p
|
|||
tangent.z = vec.z;
|
||||
|
||||
tangent *= transform;
|
||||
tangent.Normalize();
|
||||
|
||||
mesh->verts[i].SetTangent( tangent );
|
||||
mesh->verts[i].SetBiTangentSign( vec.w );
|
||||
|
|
|
@ -70,21 +70,10 @@ void idRenderModelGLTF::ProcessNode_r( gltfNode* modelNode, idMat4 parentTransfo
|
|||
{
|
||||
gltfMesh* targetMesh = meshList[modelNode->mesh];
|
||||
|
||||
idMat4 animTransform;
|
||||
|
||||
if( !animIds.Num() )
|
||||
{
|
||||
animTransform = nodeToWorldTransform;
|
||||
}
|
||||
else
|
||||
{
|
||||
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, animTransform * blenderToDoomTransform );
|
||||
auto* mesh = MapPolygonMesh::ConvertFromMeshGltf( prim, data, blenderToDoomTransform * nodeToWorldTransform );
|
||||
modelSurface_t surf;
|
||||
|
||||
gltfMaterial* mat = NULL;
|
||||
|
@ -833,11 +822,11 @@ idFile_Memory* idRenderModelGLTF::GetAnimBin( idStr animName , const ID_TIME_T
|
|||
|
||||
q = blenderToDoomTransform.ToMat3().ToQuat() * animBones[i][b].rotation;
|
||||
|
||||
//if( animBones[i].Num() == 1 )
|
||||
//{
|
||||
// this is not hit
|
||||
// q = -animBones[i][b].rotation;
|
||||
//}
|
||||
if( animBones[i].Num() == 1 )
|
||||
{
|
||||
// this is only hit for single bone or boneless (root is generated!) animations
|
||||
q = blenderToDoomTransform.ToMat3().ToQuat() * -animBones[i][b].rotation;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -202,6 +202,7 @@ void ResetDmapGlobals()
|
|||
dmapGlobals.mapLights.Clear();
|
||||
dmapGlobals.verbose = false;
|
||||
dmapGlobals.glview = false;
|
||||
dmapGlobals.asciiTree = false;
|
||||
dmapGlobals.noOptimize = false;
|
||||
dmapGlobals.verboseentities = false;
|
||||
dmapGlobals.noCurves = false;
|
||||
|
@ -271,6 +272,10 @@ void Dmap( const idCmdArgs& args )
|
|||
{
|
||||
dmapGlobals.glview = true;
|
||||
}
|
||||
else if( !idStr::Icmp( s, "asciiTree" ) )
|
||||
{
|
||||
dmapGlobals.asciiTree = true;
|
||||
}
|
||||
else if( !idStr::Icmp( s, "v" ) )
|
||||
{
|
||||
common->Printf( "verbose = true\n" );
|
||||
|
|
|
@ -279,6 +279,7 @@ typedef struct
|
|||
bool verbose;
|
||||
|
||||
bool glview;
|
||||
bool asciiTree; // BSP tree visualization in the .proc file
|
||||
bool noOptimize;
|
||||
bool verboseentities;
|
||||
bool noCurves;
|
||||
|
|
|
@ -358,7 +358,7 @@ static void WriteUTriangles( idFile* procFile, const srfTriangles_t* uTris, cons
|
|||
}
|
||||
|
||||
// RB begin
|
||||
static void WriteObjTriangles( idFile* objFile, const srfTriangles_t* uTris, const idVec3& offsetOrigin, const char* materialName )
|
||||
static void WriteObjTriangles( idFile* objFile, const srfTriangles_t* uTris, const idMat4& entityToWorldTransform, const char* materialName )
|
||||
{
|
||||
int col;
|
||||
int i;
|
||||
|
@ -376,9 +376,14 @@ static void WriteObjTriangles( idFile* objFile, const srfTriangles_t* uTris, con
|
|||
|
||||
dv = &uTris->verts[i];
|
||||
|
||||
vec[0] = dv->xyz[0] - offsetOrigin.x;
|
||||
vec[1] = dv->xyz[1] - offsetOrigin.y;
|
||||
vec[2] = dv->xyz[2] - offsetOrigin.z;
|
||||
//vec[0] = dv->xyz[0] - offsetOrigin.x;
|
||||
//vec[1] = dv->xyz[1] - offsetOrigin.y;
|
||||
//vec[2] = dv->xyz[2] - offsetOrigin.z;
|
||||
|
||||
idVec3 pos = ( entityToWorldTransform * idVec4( dv->xyz[0], dv->xyz[1], dv->xyz[2], 1 ) ).ToVec3();
|
||||
vec[0] = pos.x;
|
||||
vec[1] = pos.y;
|
||||
vec[2] = pos.z;
|
||||
|
||||
idVec2 st = dv->GetTexCoord();
|
||||
vec[3] = st.x;
|
||||
|
@ -577,6 +582,8 @@ static void WriteOutputSurfaces( int entityNum, int areaNum, idFile* procFile, i
|
|||
procFile->WriteFloatString( "\"%s\" ", ambient->material->GetName() );
|
||||
|
||||
uTri = ShareMapTriVerts( ambient );
|
||||
idStrStatic<256> matName( ambient->material->GetName() );
|
||||
FreeTriList( ambient );
|
||||
|
||||
CleanupUTriangles( uTri );
|
||||
WriteUTriangles( procFile, uTri, entity->originOffset );
|
||||
|
@ -584,10 +591,54 @@ static void WriteOutputSurfaces( int entityNum, int areaNum, idFile* procFile, i
|
|||
// RB
|
||||
if( objFile )
|
||||
{
|
||||
WriteObjTriangles( objFile, uTri, entity->originOffset, ambient->material->GetName() );
|
||||
}
|
||||
idMat4 entityToWorldTransform( mat3_identity, entity->originOffset );
|
||||
|
||||
FreeTriList( ambient );
|
||||
if( entityNum != 0 )
|
||||
{
|
||||
idVec3 origin;
|
||||
origin.Zero();
|
||||
|
||||
idMat3 rot;
|
||||
rot.Identity();
|
||||
|
||||
origin = entity->epairs.GetVector( "origin", "0 0 0" );
|
||||
|
||||
if( !entity->epairs.GetMatrix( "rotation", "1 0 0 0 1 0 0 0 1", rot ) )
|
||||
{
|
||||
idAngles angles;
|
||||
|
||||
if( entity->epairs.GetAngles( "angles", "0 0 0", angles ) )
|
||||
{
|
||||
if( angles.pitch != 0.0f || angles.yaw != 0.0f || angles.roll != 0.0f )
|
||||
{
|
||||
rot = angles.ToMat3();
|
||||
}
|
||||
else
|
||||
{
|
||||
rot.Identity();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float angle = entity->epairs.GetFloat( "angle" );
|
||||
if( angle != 0.0f )
|
||||
{
|
||||
rot = idAngles( 0.0f, angle, 0.0f ).ToMat3();
|
||||
}
|
||||
else
|
||||
{
|
||||
rot.Identity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
idMat4 transform( rot, origin );
|
||||
entityToWorldTransform = transform;
|
||||
}
|
||||
|
||||
WriteObjTriangles( objFile, uTri, entityToWorldTransform, matName.c_str() );
|
||||
}
|
||||
// RB end
|
||||
|
||||
R_FreeStaticTriSurf( uTri );
|
||||
|
||||
|
@ -796,7 +847,7 @@ static void WriteOutputNodes( node_t* node, idFile* procFile )
|
|||
procFile->WriteFloatString( "/* negative child numbers are areas: (-1-child) */\n" );
|
||||
|
||||
// RB: draw an extra ASCII BSP tree visualization for YouTube tutorial
|
||||
if( dmapGlobals.glview )
|
||||
if( dmapGlobals.asciiTree )
|
||||
{
|
||||
WriteVisualBSPTree( node, procFile );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue