mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Transform entity geometry for dmap -glview .obj output into world space
This commit is contained in:
parent
d8aba3e850
commit
0ede52ba72
1 changed files with 56 additions and 7 deletions
|
@ -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;
|
||||
|
@ -586,10 +591,54 @@ static void WriteOutputSurfaces( int entityNum, int areaNum, idFile* procFile, i
|
|||
// RB
|
||||
if( objFile )
|
||||
{
|
||||
WriteObjTriangles( objFile, uTri, entity->originOffset, matName.c_str() );
|
||||
idMat4 entityToWorldTransform( mat3_identity, entity->originOffset );
|
||||
|
||||
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 );
|
||||
|
||||
|
|
Loading…
Reference in a new issue