mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 10:38:53 +00:00
Merge branch '679-gltf-map-support2' into 679-gltf-map-support
This commit is contained in:
commit
374897f750
42 changed files with 1791 additions and 1085 deletions
|
@ -66,9 +66,9 @@ void D_PageDrawer (void);
|
|||
void D_AdvanceDemo (void);
|
||||
void D_StartTitle (void);
|
||||
|
||||
#define R_OK 0x01
|
||||
#define X_OK 0x02
|
||||
#define W_OK 0x04
|
||||
//#define R_OK 0x01
|
||||
//#define X_OK 0x02
|
||||
//#define W_OK 0x04
|
||||
int access(char* name, int val);
|
||||
|
||||
|
||||
|
|
|
@ -93,29 +93,36 @@ public:
|
|||
virtual ~idCollisionModelManager() {}
|
||||
|
||||
// Loads collision models from a map file.
|
||||
virtual void LoadMap( const idMapFile* mapFile ) = 0;
|
||||
virtual void LoadMap( const idMapFile* mapFile, bool ignoreOldCollisionFile ) = 0;
|
||||
// Frees all the collision models.
|
||||
virtual void FreeMap() = 0;
|
||||
|
||||
virtual void Preload( const char* mapName ) = 0;
|
||||
|
||||
// Gets the clip handle for a model.
|
||||
virtual cmHandle_t LoadModel( const char* modelName ) = 0;
|
||||
virtual cmHandle_t LoadModel( const char* modelName, const bool precache ) = 0;
|
||||
|
||||
// Sets up a trace model for collision with other trace models.
|
||||
virtual cmHandle_t SetupTrmModel( const idTraceModel& trm, const idMaterial* material ) = 0;
|
||||
|
||||
// Creates a trace model from a collision model, returns true if succesfull.
|
||||
virtual bool TrmFromModel( const char* modelName, idTraceModel& trm ) = 0;
|
||||
|
||||
// Gets the name of a model.
|
||||
virtual const char* GetModelName( cmHandle_t model ) const = 0;
|
||||
|
||||
// Gets the bounds of a model.
|
||||
virtual bool GetModelBounds( cmHandle_t model, idBounds& bounds ) const = 0;
|
||||
|
||||
// Gets all contents flags of brushes and polygons of a model ored together.
|
||||
virtual bool GetModelContents( cmHandle_t model, int& contents ) const = 0;
|
||||
|
||||
// Gets a vertex of a model.
|
||||
virtual bool GetModelVertex( cmHandle_t model, int vertexNum, idVec3& vertex ) const = 0;
|
||||
|
||||
// Gets an edge of a model.
|
||||
virtual bool GetModelEdge( cmHandle_t model, int edgeNum, idVec3& start, idVec3& end ) const = 0;
|
||||
|
||||
// Gets a polygon of a model.
|
||||
virtual bool GetModelPolygon( cmHandle_t model, int polygonNum, idFixedWinding& winding ) const = 0;
|
||||
|
||||
|
@ -123,14 +130,17 @@ public:
|
|||
virtual void Translation( trace_t* results, const idVec3& start, const idVec3& end,
|
||||
const idTraceModel* trm, const idMat3& trmAxis, int contentMask,
|
||||
cmHandle_t model, const idVec3& modelOrigin, const idMat3& modelAxis ) = 0;
|
||||
|
||||
// Rotates a trace model and reports the first collision if any.
|
||||
virtual void Rotation( trace_t* results, const idVec3& start, const idRotation& rotation,
|
||||
const idTraceModel* trm, const idMat3& trmAxis, int contentMask,
|
||||
cmHandle_t model, const idVec3& modelOrigin, const idMat3& modelAxis ) = 0;
|
||||
|
||||
// Returns the contents touched by the trace model or 0 if the trace model is in free space.
|
||||
virtual int Contents( const idVec3& start,
|
||||
const idTraceModel* trm, const idMat3& trmAxis, int contentMask,
|
||||
cmHandle_t model, const idVec3& modelOrigin, const idMat3& modelAxis ) = 0;
|
||||
|
||||
// Stores all contact points of the trace model with the model, returns the number of contacts.
|
||||
virtual int Contacts( contactInfo_t* contacts, const int maxContacts, const idVec3& start, const idVec6& dir, const float depth,
|
||||
const idTraceModel* trm, const idMat3& trmAxis, int contentMask,
|
||||
|
@ -138,13 +148,17 @@ public:
|
|||
|
||||
// Tests collision detection.
|
||||
virtual void DebugOutput( const idVec3& origin ) = 0;
|
||||
|
||||
// Draws a model.
|
||||
virtual void DrawModel( cmHandle_t model, const idVec3& modelOrigin, const idMat3& modelAxis,
|
||||
const idVec3& viewOrigin, const float radius ) = 0;
|
||||
|
||||
// Prints model information, use -1 handle for accumulated model info.
|
||||
virtual void ModelInfo( cmHandle_t model ) = 0;
|
||||
|
||||
// Lists all loaded models.
|
||||
virtual void ListModels() = 0;
|
||||
|
||||
// Writes a collision model file for the given map entity.
|
||||
virtual bool WriteCollisionModelForMapEntity( const idMapEntity* mapEnt, const char* filename, const bool testTraceModel = true ) = 0;
|
||||
};
|
||||
|
|
|
@ -38,6 +38,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#pragma hdrstop
|
||||
|
||||
#include "CollisionModel_local.h"
|
||||
#include "renderer/Model_gltf.h"
|
||||
|
||||
#define CM_FILE_EXT "cm"
|
||||
#define CM_BINARYFILE_EXT "bcm"
|
||||
|
@ -620,9 +621,26 @@ bool idCollisionModelManagerLocal::LoadCollisionModelFile( const char* name, uns
|
|||
generatedFileName.Insert( "generated/", 0 );
|
||||
generatedFileName.SetFileExtension( CM_BINARYFILE_EXT );
|
||||
|
||||
ID_TIME_T currentTimeStamp;
|
||||
|
||||
// if we are reloading the same map, check the timestamp
|
||||
// and try to skip all the work
|
||||
ID_TIME_T currentTimeStamp = fileSystem->GetTimestamp( fileName );
|
||||
|
||||
idStr extension;
|
||||
idStr( fileName ).ExtractFileExtension( extension );
|
||||
if( ( extension.Icmp( GLTF_GLB_EXT ) == 0 ) || ( extension.Icmp( GLTF_EXT ) == 0 ) )
|
||||
{
|
||||
int id;
|
||||
idStr tmp;
|
||||
idStr file = fileName;
|
||||
gltfManager::ExtractMeshIdentifier( file, id, tmp );
|
||||
|
||||
currentTimeStamp = fileSystem->GetTimestamp( file );
|
||||
}
|
||||
else
|
||||
{
|
||||
currentTimeStamp = fileSystem->GetTimestamp( fileName );
|
||||
}
|
||||
|
||||
// see if we have a generated version of this
|
||||
bool loaded = false;
|
||||
|
|
|
@ -50,6 +50,7 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#pragma hdrstop
|
||||
|
||||
#include "CollisionModel_local.h"
|
||||
#include "renderer/Model_gltf.h"
|
||||
|
||||
#define CMODEL_BINARYFILE_EXT "bcmodel"
|
||||
|
||||
|
@ -3863,7 +3864,7 @@ cm_model_t* idCollisionModelManagerLocal::LoadRenderModel( const char* fileName
|
|||
idStr( fileName ).ExtractFileExtension( extension );
|
||||
|
||||
// RB: DAE and OBJ support
|
||||
if( ( extension.Icmp( "ase" ) != 0 ) && ( extension.Icmp( "lwo" ) != 0 ) && ( extension.Icmp( "ma" ) != 0 ) && ( extension.Icmp( "dae" ) != 0 ) && ( extension.Icmp( "obj" ) != 0 ) )
|
||||
if( ( extension.Icmp( "glb" ) != 0 ) && ( extension.Icmp( "gltf" ) != 0 ) && ( extension.Icmp( "ase" ) != 0 ) && ( extension.Icmp( "lwo" ) != 0 ) && ( extension.Icmp( "ma" ) != 0 ) && ( extension.Icmp( "dae" ) != 0 ) && ( extension.Icmp( "obj" ) != 0 ) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -4256,7 +4257,7 @@ void idCollisionModelManagerLocal::ListModels()
|
|||
idCollisionModelManagerLocal::BuildModels
|
||||
================
|
||||
*/
|
||||
void idCollisionModelManagerLocal::BuildModels( const idMapFile* mapFile )
|
||||
void idCollisionModelManagerLocal::BuildModels( const idMapFile* mapFile, bool ignoreOldCollisionFile )
|
||||
{
|
||||
int i;
|
||||
const idMapEntity* mapEnt;
|
||||
|
@ -4264,9 +4265,8 @@ void idCollisionModelManagerLocal::BuildModels( const idMapFile* mapFile )
|
|||
idTimer timer;
|
||||
timer.Start();
|
||||
|
||||
if( !LoadCollisionModelFile( mapFile->GetName(), mapFile->GetGeometryCRC() ) )
|
||||
if( ignoreOldCollisionFile || !LoadCollisionModelFile( mapFile->GetName(), mapFile->GetGeometryCRC() ) )
|
||||
{
|
||||
|
||||
if( !mapFile->GetNumEntities() )
|
||||
{
|
||||
return;
|
||||
|
@ -4340,7 +4340,7 @@ void idCollisionModelManagerLocal::Preload( const char* mapName )
|
|||
const preloadEntry_s& p = manifest.GetPreloadByIndex( i );
|
||||
if( p.resType == PRELOAD_COLLISION )
|
||||
{
|
||||
LoadModel( p.resourceName );
|
||||
LoadModel( p.resourceName, false );
|
||||
numLoaded++;
|
||||
}
|
||||
}
|
||||
|
@ -4355,7 +4355,7 @@ void idCollisionModelManagerLocal::Preload( const char* mapName )
|
|||
idCollisionModelManagerLocal::LoadMap
|
||||
================
|
||||
*/
|
||||
void idCollisionModelManagerLocal::LoadMap( const idMapFile* mapFile )
|
||||
void idCollisionModelManagerLocal::LoadMap( const idMapFile* mapFile, bool ignoreOldCollisionFile )
|
||||
{
|
||||
|
||||
if( mapFile == NULL )
|
||||
|
@ -4398,7 +4398,7 @@ void idCollisionModelManagerLocal::LoadMap( const idMapFile* mapFile )
|
|||
common->UpdateLevelLoadPacifier();
|
||||
|
||||
// build collision models
|
||||
BuildModels( mapFile );
|
||||
BuildModels( mapFile, ignoreOldCollisionFile );
|
||||
|
||||
common->UpdateLevelLoadPacifier();
|
||||
|
||||
|
@ -4544,7 +4544,7 @@ bool idCollisionModelManagerLocal::GetModelPolygon( cmHandle_t model, int polygo
|
|||
idCollisionModelManagerLocal::LoadModel
|
||||
==================
|
||||
*/
|
||||
cmHandle_t idCollisionModelManagerLocal::LoadModel( const char* modelName )
|
||||
cmHandle_t idCollisionModelManagerLocal::LoadModel( const char* modelName, const bool precache )
|
||||
{
|
||||
int handle;
|
||||
|
||||
|
@ -4564,7 +4564,23 @@ cmHandle_t idCollisionModelManagerLocal::LoadModel( const char* modelName )
|
|||
generatedFileName.AppendPath( modelName );
|
||||
generatedFileName.SetFileExtension( CMODEL_BINARYFILE_EXT );
|
||||
|
||||
ID_TIME_T sourceTimeStamp = fileSystem->GetTimestamp( modelName );
|
||||
ID_TIME_T sourceTimeStamp;
|
||||
|
||||
idStr extension;
|
||||
idStr( modelName ).ExtractFileExtension( extension );
|
||||
if( ( extension.Icmp( GLTF_GLB_EXT ) == 0 ) || ( extension.Icmp( GLTF_EXT ) == 0 ) )
|
||||
{
|
||||
int id;
|
||||
idStr tmp;
|
||||
idStr file = modelName;
|
||||
gltfManager::ExtractMeshIdentifier( file, id, tmp );
|
||||
|
||||
sourceTimeStamp = fileSystem->GetTimestamp( file );
|
||||
}
|
||||
else
|
||||
{
|
||||
sourceTimeStamp = fileSystem->GetTimestamp( modelName );
|
||||
}
|
||||
|
||||
if( models == NULL )
|
||||
{
|
||||
|
@ -4602,6 +4618,12 @@ cmHandle_t idCollisionModelManagerLocal::LoadModel( const char* modelName )
|
|||
}
|
||||
}
|
||||
|
||||
// if only precaching .cm files do not waste memory converting render models
|
||||
if( precache )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// try to load a .ASE or .LWO model and convert it to a collision model
|
||||
models[ numModels ] = LoadRenderModel( modelName );
|
||||
if( models[ numModels ] != NULL )
|
||||
|
@ -4781,7 +4803,7 @@ bool idCollisionModelManagerLocal::TrmFromModel( const char* modelName, idTraceM
|
|||
{
|
||||
cmHandle_t handle;
|
||||
|
||||
handle = LoadModel( modelName );
|
||||
handle = LoadModel( modelName, false );
|
||||
if( !handle )
|
||||
{
|
||||
common->Printf( "idCollisionModelManagerLocal::TrmFromModel: model %s not found.\n", modelName );
|
||||
|
|
|
@ -326,13 +326,13 @@ class idCollisionModelManagerLocal : public idCollisionModelManager
|
|||
{
|
||||
public:
|
||||
// load collision models from a map file
|
||||
void LoadMap( const idMapFile* mapFile );
|
||||
void LoadMap( const idMapFile* mapFile, bool ignoreOldCollisionFile );
|
||||
// frees all the collision models
|
||||
void FreeMap();
|
||||
|
||||
void Preload( const char* mapName );
|
||||
// get clip handle for model
|
||||
cmHandle_t LoadModel( const char* modelName );
|
||||
cmHandle_t LoadModel( const char* modelName, const bool precache );
|
||||
// sets up a trace model for collision with other trace models
|
||||
cmHandle_t SetupTrmModel( const idTraceModel& trm, const idMaterial* material );
|
||||
// create trace model from a collision model, returns true if succesfull
|
||||
|
@ -502,7 +502,7 @@ private: // CollisionMap_load.cpp
|
|||
void RemapEdges( cm_node_t* node, int* edgeRemap );
|
||||
void OptimizeArrays( cm_model_t* model );
|
||||
void FinishModel( cm_model_t* model );
|
||||
void BuildModels( const idMapFile* mapFile );
|
||||
void BuildModels( const idMapFile* mapFile, bool ignoreOldCollisionFile );
|
||||
cmHandle_t FindModel( const char* name );
|
||||
cm_model_t* CollisionModelForMapEntity( const idMapEntity* mapEnt ); // brush/patch model from .map
|
||||
cm_model_t* LoadRenderModel( const char* fileName ); // ASE/LWO models
|
||||
|
|
6
neo/cmake-vs2019-64bit-no-ffmpeg.bat
Normal file
6
neo/cmake-vs2019-64bit-no-ffmpeg.bat
Normal file
|
@ -0,0 +1,6 @@
|
|||
cd ..
|
||||
del /s /q build
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G "Visual Studio 16" -A x64 -DFFMPEG=OFF -DBINKDEC=ON ../neo
|
||||
pause
|
|
@ -50,7 +50,7 @@ END_CLASS
|
|||
idTarget_EndLevel::Spawn
|
||||
================
|
||||
*/
|
||||
void idTarget_EndLevel::Spawn( void )
|
||||
void idTarget_EndLevel::Spawn()
|
||||
{
|
||||
idStr guiName;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class idTarget_EndLevel : public idEntity
|
|||
public:
|
||||
CLASS_PROTOTYPE( idTarget_EndLevel );
|
||||
|
||||
void Spawn( void );
|
||||
void Spawn();
|
||||
~idTarget_EndLevel();
|
||||
|
||||
void Draw();
|
||||
|
|
|
@ -573,7 +573,7 @@ private:
|
|||
// events
|
||||
public:
|
||||
// jmarshall
|
||||
idVec3 GetOrigin( void );
|
||||
idVec3 GetOrigin();
|
||||
float DistanceTo( idEntity* ent );
|
||||
float DistanceTo( const idVec3& pos ) const;
|
||||
idStr GetNextKey( const char* prefix, const char* lastMatch );
|
||||
|
|
|
@ -976,7 +976,7 @@ void idGameLocal::LoadMap( const char* mapName, int randseed )
|
|||
mapFileName = mapFile->GetName();
|
||||
|
||||
// load the collision map
|
||||
collisionModelManager->LoadMap( mapFile );
|
||||
collisionModelManager->LoadMap( mapFile, false );
|
||||
collisionModelManager->Preload( mapName );
|
||||
|
||||
numClients = 0;
|
||||
|
@ -1894,7 +1894,7 @@ void idGameLocal::CacheDictionaryMedia( const idDict* dict )
|
|||
renderModelManager->FindModel( kv->GetValue() );
|
||||
|
||||
// precache .cm files only
|
||||
collisionModelManager->LoadModel( kv->GetValue() );
|
||||
collisionModelManager->LoadModel( kv->GetValue(), true );
|
||||
}
|
||||
}
|
||||
kv = dict->MatchPrefix( "model", kv );
|
||||
|
@ -2599,7 +2599,7 @@ idCVar g_recordTrace( "g_recordTrace", "0", CVAR_BOOL, "" );
|
|||
idGameLocal::RunSharedThink
|
||||
================
|
||||
*/
|
||||
void idGameLocal::RunSharedThink( void )
|
||||
void idGameLocal::RunSharedThink()
|
||||
{
|
||||
idEntity* ent;
|
||||
for( ent = activeEntities.Next(); ent != NULL; ent = ent->activeNode.Next() )
|
||||
|
@ -5014,7 +5014,7 @@ idCamera* idGameLocal::GetCamera() const
|
|||
idGameLocal::SkipCinematic
|
||||
=============
|
||||
*/
|
||||
bool idGameLocal::SkipCinematic( void )
|
||||
bool idGameLocal::SkipCinematic()
|
||||
{
|
||||
if( camera )
|
||||
{
|
||||
|
|
|
@ -489,7 +489,7 @@ public:
|
|||
|
||||
void SetCamera( idCamera* cam );
|
||||
idCamera* GetCamera() const;
|
||||
bool SkipCinematic( void );
|
||||
bool SkipCinematic();
|
||||
void CalcFov( float base_fov, float& fov_x, float& fov_y ) const;
|
||||
|
||||
void AddEntityToHash( const char* name, idEntity* ent );
|
||||
|
|
|
@ -851,8 +851,9 @@ void idTarget_SetModel::Spawn()
|
|||
{
|
||||
// precache the render model
|
||||
renderModelManager->FindModel( model );
|
||||
|
||||
// precache .cm files only
|
||||
collisionModelManager->LoadModel( model );
|
||||
collisionModelManager->LoadModel( model, true );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1175,7 +1175,7 @@ idMD5Anim* idAnimManager::GetAnim( const char* name )
|
|||
idStr filename = name;
|
||||
|
||||
filename.ExtractFileExtension( extension );
|
||||
if( extension != MD5_ANIM_EXT )
|
||||
if( extension != MD5_ANIM_EXT && ( extension != GLTF_EXT && extension != GLTF_GLB_EXT ) )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -3336,9 +3336,11 @@ bool idDeclModelDef::Parse( const char* text, const int textLength, bool allowBi
|
|||
}
|
||||
filename = token2;
|
||||
filename.ExtractFileExtension( extension );
|
||||
if( extension != MD5_MESH_EXT )
|
||||
bool isGltf = extension == GLTF_EXT || extension == GLTF_GLB_EXT;
|
||||
|
||||
if( extension != MD5_MESH_EXT && !isGltf )
|
||||
{
|
||||
src.Warning( "Invalid model for MD5 mesh" );
|
||||
src.Warning( "Invalid model for MD5 or GLTF mesh" );
|
||||
MakeDefault();
|
||||
return false;
|
||||
}
|
||||
|
@ -3364,27 +3366,30 @@ bool idDeclModelDef::Parse( const char* text, const int textLength, bool allowBi
|
|||
src.Warning( "Model '%s' has no joints", filename.c_str() );
|
||||
}
|
||||
|
||||
// set up the joint hierarchy
|
||||
joints.SetGranularity( 1 );
|
||||
joints.SetNum( num );
|
||||
jointParents.SetNum( num );
|
||||
channelJoints[0].SetNum( num );
|
||||
md5joints = modelHandle->GetJoints();
|
||||
md5joint = md5joints;
|
||||
for( i = 0; i < num; i++, md5joint++ )
|
||||
if( num > 0 )
|
||||
{
|
||||
joints[i].channel = ANIMCHANNEL_ALL;
|
||||
joints[i].num = static_cast<jointHandle_t>( i );
|
||||
if( md5joint->parent )
|
||||
// set up the joint hierarchy
|
||||
joints.SetGranularity( 1 );
|
||||
joints.SetNum( num );
|
||||
jointParents.SetNum( num );
|
||||
channelJoints[0].SetNum( num );
|
||||
md5joints = modelHandle->GetJoints( );
|
||||
md5joint = md5joints;
|
||||
for( i = 0; i < num; i++, md5joint++ )
|
||||
{
|
||||
joints[i].parentNum = static_cast<jointHandle_t>( md5joint->parent - md5joints );
|
||||
joints[i].channel = ANIMCHANNEL_ALL;
|
||||
joints[i].num = static_cast< jointHandle_t >( i );
|
||||
if( md5joint->parent )
|
||||
{
|
||||
joints[i].parentNum = static_cast< jointHandle_t >( md5joint->parent - md5joints );
|
||||
}
|
||||
else
|
||||
{
|
||||
joints[i].parentNum = INVALID_JOINT;
|
||||
}
|
||||
jointParents[i] = joints[i].parentNum;
|
||||
channelJoints[0][i] = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
joints[i].parentNum = INVALID_JOINT;
|
||||
}
|
||||
jointParents[i] = joints[i].parentNum;
|
||||
channelJoints[0][i] = i;
|
||||
}
|
||||
}
|
||||
else if( token == "remove" )
|
||||
|
|
|
@ -329,7 +329,7 @@ bool idClipModel::LoadModel( const char* name )
|
|||
FreeTraceModel( traceModelIndex );
|
||||
traceModelIndex = -1;
|
||||
}
|
||||
collisionModelHandle = collisionModelManager->LoadModel( name );
|
||||
collisionModelHandle = collisionModelManager->LoadModel( name, false );
|
||||
if( collisionModelHandle )
|
||||
{
|
||||
collisionModelManager->GetModelBounds( collisionModelHandle, bounds );
|
||||
|
@ -560,7 +560,7 @@ void idClipModel::Restore( idRestoreGame* savefile )
|
|||
savefile->ReadString( collisionModelName );
|
||||
if( collisionModelName.Length() )
|
||||
{
|
||||
collisionModelHandle = collisionModelManager->LoadModel( collisionModelName );
|
||||
collisionModelHandle = collisionModelManager->LoadModel( collisionModelName, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -788,7 +788,7 @@ idClipModel::CheckModel
|
|||
*/
|
||||
cmHandle_t idClipModel::CheckModel( const char* name )
|
||||
{
|
||||
return collisionModelManager->LoadModel( name );
|
||||
return collisionModelManager->LoadModel( name, false );
|
||||
}
|
||||
|
||||
|
||||
|
@ -887,9 +887,11 @@ void idClip::Init()
|
|||
memset( clipSectors, 0, MAX_SECTORS * sizeof( clipSector_t ) );
|
||||
numClipSectors = 0;
|
||||
touchCount = -1;
|
||||
|
||||
// get world map bounds
|
||||
h = collisionModelManager->LoadModel( "worldMap" );
|
||||
h = collisionModelManager->LoadModel( "worldMap", false );
|
||||
collisionModelManager->GetModelBounds( h, worldBounds );
|
||||
|
||||
// create world sectors
|
||||
CreateClipSectors_r( 0, worldBounds, maxSector );
|
||||
|
||||
|
|
|
@ -408,7 +408,7 @@ This is an out-of-sequence screen update, not the normal game rendering
|
|||
// DG: added possibility to *not* release mouse in UpdateScreen(), it fucks up the view angle for screenshots
|
||||
void idCommonLocal::UpdateScreen( bool captureToImage, bool releaseMouse )
|
||||
{
|
||||
if( insideUpdateScreen )
|
||||
if( insideUpdateScreen || com_shuttingDown )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,9 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "../renderer/Image.h"
|
||||
|
||||
|
||||
idCVar gltf_MapSceneName( "gltf_MapSceneName", "Scene", CVAR_SYSTEM , "Scene to use when d-mapping a gltf/glb" );
|
||||
|
||||
/*
|
||||
===============
|
||||
FloatCRC
|
||||
|
@ -1448,12 +1451,11 @@ idMapEntity::GetGeometryCRC
|
|||
*/
|
||||
unsigned int idMapEntity::GetGeometryCRC() const
|
||||
{
|
||||
int i;
|
||||
unsigned int crc;
|
||||
idMapPrimitive* mapPrim;
|
||||
|
||||
crc = 0;
|
||||
for( i = 0; i < GetNumPrimitives(); i++ )
|
||||
for( int i = 0; i < GetNumPrimitives(); i++ )
|
||||
{
|
||||
mapPrim = GetPrimitive( i );
|
||||
|
||||
|
@ -1574,7 +1576,7 @@ bool idMapFile::Parse( const char* filename, bool ignoreRegion, bool osPath )
|
|||
}
|
||||
|
||||
bool isGTLF = false;
|
||||
if( !src.IsLoaded( ) )
|
||||
if( !src.IsLoaded() )
|
||||
{
|
||||
// HVG: try loading a .gltf/glb second
|
||||
fullName.SetFileExtension( "glb" );
|
||||
|
@ -1674,6 +1676,11 @@ bool idMapFile::Parse( const char* filename, bool ignoreRegion, bool osPath )
|
|||
gltfParser->Load( fullName );
|
||||
idMapEntity::GetEntities( gltfParser->currentAsset, entities, 0 );
|
||||
}
|
||||
else if( isGTLF )
|
||||
{
|
||||
gltfParser->Load( fullName );
|
||||
idMapEntity::GetEntities( gltfParser->currentAsset, entities, gltfParser->currentAsset->GetSceneId( gltf_MapSceneName.GetString() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( token == "Version" )
|
||||
|
@ -2220,6 +2227,24 @@ void MapPolygonMesh::ConvertFromBrush( const idMapBrush* mapBrush, int entityNum
|
|||
st.x = ( xyz * texVec[0].ToVec3() ) + texVec[0][3];
|
||||
st.y = ( xyz * texVec[1].ToVec3() ) + texVec[1][3];
|
||||
|
||||
// support Valve 220 projection
|
||||
if( mapSide->GetProjectionType() == idMapBrushSide::PROJECTION_VALVE220 )
|
||||
{
|
||||
const idMaterial* material = declManager->FindMaterial( mapSide->GetMaterial() );
|
||||
|
||||
idVec2i texSize = mapSide->GetTextureSize();
|
||||
|
||||
idImage* image = material->GetEditorImage();
|
||||
if( image != NULL )
|
||||
{
|
||||
texSize.x = image->GetUploadWidth();
|
||||
texSize.y = image->GetUploadHeight();
|
||||
}
|
||||
|
||||
st.x /= texSize[0];
|
||||
st.y /= texSize[1];
|
||||
}
|
||||
|
||||
// flip y
|
||||
//st.y = 1.0f - st.y;
|
||||
|
||||
|
@ -2755,22 +2780,23 @@ void MapPolygonMesh::SetContents()
|
|||
|
||||
unsigned int MapPolygonMesh::GetGeometryCRC() const
|
||||
{
|
||||
int i;
|
||||
unsigned int crc;
|
||||
|
||||
crc = 0;
|
||||
unsigned int i;
|
||||
unsigned int crc = 0;
|
||||
for( i = 0; i < verts.Num(); i++ )
|
||||
{
|
||||
crc ^= FloatCRC( verts[i].xyz.x );
|
||||
crc ^= FloatCRC( verts[i].xyz.y );
|
||||
crc ^= FloatCRC( verts[i].xyz.z );
|
||||
#if 0
|
||||
crc ^= StringCRC( ( verts[i].xyz * ( i + 1 ) ).ToString() );
|
||||
#else
|
||||
crc ^= FloatCRC( verts[i].xyz.x * ( i + 1 ) );
|
||||
crc ^= FloatCRC( verts[i].xyz.y * ( i + 1 ) );
|
||||
crc ^= FloatCRC( verts[i].xyz.z * ( i + 1 ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
for( i = 0; i < polygons.Num(); i++ )
|
||||
{
|
||||
const MapPolygon& poly = polygons[i];
|
||||
|
||||
crc ^= StringCRC( poly.GetMaterial() );
|
||||
crc ^= StringCRC( poly.GetMaterial() + idStr( i ) );
|
||||
}
|
||||
|
||||
return crc;
|
||||
|
|
|
@ -349,7 +349,7 @@ public:
|
|||
|
||||
void ConvertFromBrush( const idMapBrush* brush, int entityNum, int primitiveNum );
|
||||
void ConvertFromPatch( const idMapPatch* patch, int entityNum, int primitiveNum );
|
||||
void ConvertFromMeshGltf( const gltfMesh* mesh , gltfData* data );
|
||||
static MapPolygonMesh* ConvertFromMeshGltf( const gltfMesh_Primitive* prim, gltfData* _data, idMat4 trans );
|
||||
static MapPolygonMesh* Parse( idLexer& src, const idVec3& origin, float version = CURRENT_MAP_VERSION );
|
||||
bool Write( idFile* fp, int primitiveNum, const idVec3& origin ) const;
|
||||
|
||||
|
@ -427,13 +427,13 @@ protected:
|
|||
|
||||
class idMapEntity
|
||||
{
|
||||
friend class idMapFile;
|
||||
|
||||
public:
|
||||
typedef idList<idMapEntity*, TAG_IDLIB_LIST_MAP> EntityList;
|
||||
typedef idList<idMapEntity*, TAG_IDLIB_LIST_MAP>& EntityListRef;
|
||||
typedef idList<idMapEntity*, TAG_IDLIB_LIST_MAP>* EntityListPtr;
|
||||
|
||||
friend class idMapFile;
|
||||
|
||||
public:
|
||||
idDict epairs;
|
||||
idVec3 originOffset{ vec3_origin };
|
||||
|
||||
|
|
354
neo/idlib/MapFile_gltf.cpp
Normal file
354
neo/idlib/MapFile_gltf.cpp
Normal file
|
@ -0,0 +1,354 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 2022 Harrie van Ginneken
|
||||
Copyright (C) 2022 Robert Beckebans
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
#pragma hdrstop
|
||||
|
||||
|
||||
MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* prim, gltfData* _data , idMat4 trans )
|
||||
{
|
||||
MapPolygonMesh* mesh = new MapPolygonMesh();
|
||||
gltfAccessor* accessor = _data->AccessorList()[prim->indices];
|
||||
gltfBufferView* bv = _data->BufferViewList()[accessor->bufferView];
|
||||
gltfData* data = bv->parent;
|
||||
|
||||
// files import as y-up. Use this transform to change the model to z-up.
|
||||
idMat3 rotation = idAngles( 0.0f, 0.0f, 90.0f ).ToMat3( );
|
||||
idMat4 axisTransform( rotation, vec3_origin );
|
||||
|
||||
gltfMaterial* mat = NULL;
|
||||
if( prim->material != -1 )
|
||||
{
|
||||
mat = _data->MaterialList()[prim->material];
|
||||
}
|
||||
|
||||
gltfBuffer* buff = data->BufferList()[bv->buffer];
|
||||
uint idxDataSize = sizeof( uint ) * accessor->count;
|
||||
uint* indices = ( uint* ) Mem_ClearedAlloc( idxDataSize , TAG_IDLIB_GLTF );
|
||||
|
||||
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 );
|
||||
if( bv->byteStride )
|
||||
{
|
||||
idxBin.Seek( bv->byteStride - accessor->typeSize, FS_SEEK_CUR );
|
||||
}
|
||||
}
|
||||
|
||||
for( int i = 0; i < accessor->count; i += 3 )
|
||||
{
|
||||
MapPolygon& polygon = mesh->polygons.Alloc();
|
||||
|
||||
if( mat != NULL )
|
||||
{
|
||||
polygon.SetMaterial( mat->name );
|
||||
}
|
||||
else
|
||||
{
|
||||
polygon.SetMaterial( "textures/base_wall/snpanel2rust" );
|
||||
}
|
||||
|
||||
polygon.AddIndex( indices[i + 2] );
|
||||
polygon.AddIndex( indices[i + 1] );
|
||||
polygon.AddIndex( indices[i + 0] );
|
||||
}
|
||||
|
||||
Mem_Free( indices );
|
||||
bool sizeSet = false;
|
||||
|
||||
for( auto& attrib : prim->attributes )
|
||||
{
|
||||
gltfAccessor* attrAcc = data->AccessorList()[attrib->accessorIndex];
|
||||
gltfBufferView* attrBv = data->BufferViewList()[attrAcc->bufferView];
|
||||
gltfData* attrData = attrBv->parent;
|
||||
gltfBuffer* attrbuff = attrData->BufferList()[attrBv->buffer];
|
||||
|
||||
idFile_Memory bin = idFile_Memory( "gltfChunkVertices",
|
||||
( const char* )( ( attrData->GetData( attrBv->buffer ) + attrBv->byteOffset + attrAcc->byteOffset ) ), attrBv->byteLength );
|
||||
|
||||
if( !sizeSet )
|
||||
{
|
||||
mesh->verts.AssureSize( attrAcc->count );
|
||||
sizeSet = true;
|
||||
}
|
||||
|
||||
switch( attrib->type )
|
||||
{
|
||||
case gltfMesh_Primitive_Attribute::Type::Position:
|
||||
{
|
||||
for( int i = 0; i < attrAcc->count; i++ )
|
||||
{
|
||||
idVec3 pos;
|
||||
|
||||
bin.Read( ( void* )( &pos.x ), attrAcc->typeSize );
|
||||
bin.Read( ( void* )( &pos.y ), attrAcc->typeSize );
|
||||
bin.Read( ( void* )( &pos.z ), attrAcc->typeSize );
|
||||
|
||||
pos *= trans;
|
||||
pos *= axisTransform;
|
||||
|
||||
mesh->verts[i].xyz.x = pos.x;
|
||||
mesh->verts[i].xyz.y = pos.y;
|
||||
mesh->verts[i].xyz.z = pos.z;
|
||||
|
||||
if( attrBv->byteStride )
|
||||
{
|
||||
bin.Seek( attrBv->byteStride - ( 3 * attrAcc->typeSize ), FS_SEEK_CUR );
|
||||
}
|
||||
|
||||
idRandom rnd( i );
|
||||
int r = rnd.RandomInt( 255 ), g = rnd.RandomInt( 255 ), b = rnd.RandomInt( 255 );
|
||||
|
||||
//vtxData[i].abgr = 0xff000000 + ( b << 16 ) + ( g << 8 ) + r;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case gltfMesh_Primitive_Attribute::Type::Normal:
|
||||
{
|
||||
idVec3 vec;
|
||||
for( int i = 0; i < attrAcc->count; i++ )
|
||||
{
|
||||
idVec3 vec;
|
||||
bin.Read( ( void* )( &vec.x ), attrAcc->typeSize );
|
||||
bin.Read( ( void* )( &vec.y ), attrAcc->typeSize );
|
||||
bin.Read( ( void* )( &vec.z ), attrAcc->typeSize );
|
||||
if( attrBv->byteStride )
|
||||
{
|
||||
bin.Seek( attrBv->byteStride - ( attrib->elementSize * attrAcc->typeSize ), FS_SEEK_CUR );
|
||||
}
|
||||
|
||||
idVec3 normal;
|
||||
|
||||
normal.x = vec.x;
|
||||
normal.y = vec.y;
|
||||
normal.z = vec.z;
|
||||
|
||||
normal *= axisTransform;
|
||||
mesh->verts[i].SetNormal( normal );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case gltfMesh_Primitive_Attribute::Type::TexCoord0:
|
||||
{
|
||||
idVec2 vec;
|
||||
for( int i = 0; i < attrAcc->count; i++ )
|
||||
{
|
||||
bin.Read( ( void* )( &vec.x ), attrAcc->typeSize );
|
||||
bin.Read( ( void* )( &vec.y ), attrAcc->typeSize );
|
||||
if( attrBv->byteStride )
|
||||
{
|
||||
bin.Seek( attrBv->byteStride - ( attrib->elementSize * attrAcc->typeSize ), FS_SEEK_CUR );
|
||||
}
|
||||
|
||||
//vec.y = 1.0f - vec.y;
|
||||
mesh->verts[i].SetTexCoord( vec );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case gltfMesh_Primitive_Attribute::Type::Tangent:
|
||||
{
|
||||
idVec4 vec;
|
||||
for( int i = 0; i < attrAcc->count; i++ )
|
||||
{
|
||||
bin.Read( ( void* )( &vec.x ), attrAcc->typeSize );
|
||||
bin.Read( ( void* )( &vec.y ), attrAcc->typeSize );
|
||||
bin.Read( ( void* )( &vec.z ), attrAcc->typeSize );
|
||||
bin.Read( ( void* )( &vec.w ), attrAcc->typeSize );
|
||||
if( attrBv->byteStride )
|
||||
{
|
||||
bin.Seek( attrBv->byteStride - ( attrib->elementSize * attrAcc->typeSize ), FS_SEEK_CUR );
|
||||
}
|
||||
|
||||
idVec3 tangent;
|
||||
|
||||
tangent.x = vec.x;
|
||||
tangent.y = vec.y;
|
||||
tangent.z = vec.z;
|
||||
|
||||
tangent *= axisTransform;
|
||||
|
||||
mesh->verts[i].SetTangent( tangent );
|
||||
mesh->verts[i].SetBiTangentSign( vec.w );
|
||||
}
|
||||
break;
|
||||
}
|
||||
//case gltfMesh_Primitive_Attribute::Type::Weight:
|
||||
//{
|
||||
// for ( int i = 0; i < attrAcc->count; i++ ) {
|
||||
// bin.Read( ( void * ) ( &vtxData[i].weight.x ), attrAcc->typeSize );
|
||||
// bin.Read( ( void * ) ( &vtxData[i].weight.y ), attrAcc->typeSize );
|
||||
// bin.Read( ( void * ) ( &vtxData[i].weight.z ), attrAcc->typeSize );
|
||||
// bin.Read( ( void * ) ( &vtxData[i].weight.w ), attrAcc->typeSize );
|
||||
// if ( attrBv->byteStride )
|
||||
// bin.Seek( attrBv->byteStride - ( attrib->elementSize * attrAcc->typeSize ), FS_SEEK_CUR );
|
||||
// }
|
||||
// break;
|
||||
//}
|
||||
//case gltfMesh_Primitive_Attribute::Type::Indices:
|
||||
//{
|
||||
// for ( int i = 0; i < attrAcc->count; i++ ) {
|
||||
// bin.Read( ( void * ) ( &vtxData[i].boneIndex.x ), attrAcc->typeSize );
|
||||
// bin.Read( ( void * ) ( &vtxData[i].boneIndex.y ), attrAcc->typeSize );
|
||||
// bin.Read( ( void * ) ( &vtxData[i].boneIndex.z ), attrAcc->typeSize );
|
||||
// bin.Read( ( void * ) ( &vtxData[i].boneIndex.w ), attrAcc->typeSize );
|
||||
// if ( attrBv->byteStride )
|
||||
// bin.Seek( attrBv->byteStride - ( attrib->elementSize * attrAcc->typeSize ), FS_SEEK_CUR );
|
||||
// }
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
mesh->SetContents();
|
||||
return mesh;
|
||||
}
|
||||
|
||||
void ProcessSceneNode( idMapEntity* newEntity, gltfNode* node, idMat4 trans, gltfData* data , bool staticMesh = false )
|
||||
{
|
||||
auto& nodeList = data->NodeList();
|
||||
|
||||
gltfData::ResolveNodeMatrix( node );
|
||||
idMat4 curTrans = trans * node->matrix;
|
||||
|
||||
idDict newPairs = node->extras.strPairs;
|
||||
newPairs.SetDefaults( &newEntity->epairs );
|
||||
newEntity->epairs = newPairs;
|
||||
|
||||
const char* classname = newEntity->epairs.GetString( "classname" );
|
||||
const char* model = newEntity->epairs.GetString( "model" );
|
||||
|
||||
bool isFuncStaticMesh = staticMesh || ( idStr::Icmp( classname, "func_static" ) == 0 ) && ( idStr::Icmp( model, node->name ) == 0 );
|
||||
|
||||
for( auto& child : node->children )
|
||||
{
|
||||
ProcessSceneNode( newEntity, nodeList[child], curTrans, data, isFuncStaticMesh );
|
||||
}
|
||||
|
||||
if( isFuncStaticMesh && node->mesh != -1 )
|
||||
{
|
||||
for( auto prim : data->MeshList()[node->mesh]->primitives )
|
||||
{
|
||||
newEntity->AddPrimitive( MapPolygonMesh::ConvertFromMeshGltf( prim, data , curTrans ) );
|
||||
}
|
||||
}
|
||||
|
||||
if( node->name.Length() )
|
||||
{
|
||||
newEntity->epairs.Set( "name", node->name );
|
||||
}
|
||||
|
||||
#if 0
|
||||
for( int i = 0; i < newEntity->epairs.GetNumKeyVals(); i++ )
|
||||
{
|
||||
const idKeyValue* kv = newEntity->epairs.GetKeyVal( i );
|
||||
|
||||
idLib::Printf( "entity[ %s ] key = '%s' value = '%s'\n", node->name.c_str(), kv->GetKey().c_str(), kv->GetValue().c_str() );
|
||||
}
|
||||
#endif
|
||||
idVec3 origin;
|
||||
|
||||
origin.x = node->translation.x;
|
||||
origin.y = node->translation.y;
|
||||
origin.z = node->translation.z;
|
||||
|
||||
// files import as y-up. Use this transform to change the model to z-up.
|
||||
idMat3 rotation = idAngles( 0.0f, 0.0f, 90.0f ).ToMat3( );
|
||||
idMat4 axisTransform( rotation, vec3_origin );
|
||||
|
||||
origin *= axisTransform;
|
||||
|
||||
newEntity->epairs.Set( "origin", origin.ToString() );
|
||||
}
|
||||
|
||||
void Map_AddMeshes( idMapEntity* _Entity, gltfNode* _Node, idMat4& _Trans, gltfData* _Data )
|
||||
{
|
||||
gltfData::ResolveNodeMatrix( _Node );
|
||||
idMat4 curTrans = _Trans * _Node->matrix;
|
||||
|
||||
if( _Node->mesh != -1 )
|
||||
{
|
||||
for( auto prim : _Data->MeshList( )[_Node->mesh]->primitives )
|
||||
{
|
||||
_Entity->AddPrimitive( MapPolygonMesh::ConvertFromMeshGltf( prim, _Data, curTrans ) );
|
||||
}
|
||||
}
|
||||
|
||||
for( auto& child : _Node->children )
|
||||
{
|
||||
Map_AddMeshes( _Entity, _Data->NodeList( )[child], curTrans, _Data );
|
||||
}
|
||||
};
|
||||
|
||||
int idMapEntity::GetEntities( gltfData* data, EntityListRef entities, int sceneID )
|
||||
{
|
||||
idMapEntity* worldspawn = new( TAG_IDLIB_GLTF ) idMapEntity();
|
||||
entities.Append( worldspawn );
|
||||
|
||||
bool wpSet = false;
|
||||
|
||||
int entityCount = 0;
|
||||
for( auto& nodeID : data->SceneList()[sceneID]->nodes )
|
||||
{
|
||||
auto* node = data->NodeList()[nodeID];
|
||||
const char* classname = node->extras.strPairs.GetString( "classname" );
|
||||
|
||||
bool isWorldSpawn = idStr::Icmp( classname, "worldspawn" ) == 0;
|
||||
if( isWorldSpawn )
|
||||
{
|
||||
assert( !wpSet );
|
||||
worldspawn->epairs.Copy( node->extras.strPairs );
|
||||
wpSet = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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 )
|
||||
{
|
||||
Map_AddMeshes( worldspawn, node, mat4_identity, data );
|
||||
}
|
||||
else
|
||||
{
|
||||
idMapEntity* newEntity = new( TAG_IDLIB_GLTF ) idMapEntity();
|
||||
entities.Append( newEntity );
|
||||
|
||||
ProcessSceneNode( newEntity, node, mat4_identity, data );
|
||||
|
||||
entityCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return entityCount;
|
||||
}
|
|
@ -206,7 +206,7 @@ public:
|
|||
struct Iterator
|
||||
{
|
||||
_type_* p;
|
||||
_type_& operator*( )
|
||||
_type_& operator*()
|
||||
{
|
||||
return *p;
|
||||
}
|
||||
|
@ -214,19 +214,19 @@ public:
|
|||
{
|
||||
return p != rhs.p;
|
||||
}
|
||||
void operator ++( )
|
||||
void operator ++()
|
||||
{
|
||||
++p;
|
||||
}
|
||||
};
|
||||
|
||||
auto begin( ) const // const version
|
||||
auto begin() const // const version
|
||||
{
|
||||
return Iterator{list};
|
||||
};
|
||||
auto end( ) const // const version
|
||||
auto end() const // const version
|
||||
{
|
||||
return Iterator{list + Num( )};
|
||||
return Iterator{list + Num()};
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
|
@ -1,3 +1,31 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 2022 Harrie van Ginneken
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
#pragma hdrstop
|
||||
#include "gltfExtras.h"
|
||||
|
@ -6,7 +34,6 @@ extern idCVar gltf_parseVerbose;
|
|||
|
||||
void gltfExtra_Scatter::parse( idToken& token, idLexer* parser )
|
||||
{
|
||||
|
||||
parser->UnreadToken( &token );
|
||||
|
||||
gltfItemArray scatterInfo;
|
||||
|
@ -16,7 +43,6 @@ void gltfExtra_Scatter::parse( idToken& token, idLexer* parser )
|
|||
|
||||
void gltfExtra_cvar::parse( idToken& token, idLexer* parser )
|
||||
{
|
||||
|
||||
parser->UnreadToken( &token );
|
||||
gltfItemArray cvarInfo;
|
||||
idStr n, t, v, d;
|
||||
|
|
|
@ -1,3 +1,31 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 2022 Harrie van Ginneken
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "gltfParser.h"
|
||||
|
||||
#ifndef gltfExtraParser
|
||||
|
@ -7,7 +35,7 @@
|
|||
gltfExtra_##className( idStr Name ) : name( Name ){ item = nullptr; } \
|
||||
virtual void parse( idToken &token ){parse(token,nullptr);} \
|
||||
virtual void parse( idToken &token , idLexer * parser ); \
|
||||
virtual idStr &Name( ) { return name; } \
|
||||
virtual idStr &Name() { return name; } \
|
||||
private: \
|
||||
idStr name;}
|
||||
#pragma endregion
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,31 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 2022 Harrie van Ginneken
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "containers/StrList.h"
|
||||
#include <functional>
|
||||
|
@ -11,7 +39,7 @@ struct parsable
|
|||
public:
|
||||
virtual void parse( idToken& token ) = 0;
|
||||
virtual void parse( idToken& token , idLexer* parser ) {};
|
||||
virtual idStr& Name( ) = 0;
|
||||
virtual idStr& Name() = 0;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
@ -40,7 +68,7 @@ public:
|
|||
{
|
||||
*item = token;
|
||||
};
|
||||
virtual idStr& Name( )
|
||||
virtual idStr& Name()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
@ -59,7 +87,7 @@ public:
|
|||
parser->UnreadToken( &token );
|
||||
parser->ParseBracedSection( object );
|
||||
}
|
||||
virtual idStr& Name( )
|
||||
virtual idStr& Name()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
@ -77,7 +105,7 @@ public:
|
|||
item = nullptr;
|
||||
}
|
||||
virtual void parse( idToken& token ) ;
|
||||
virtual idStr& Name( )
|
||||
virtual idStr& Name()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
@ -106,7 +134,7 @@ public:
|
|||
*item = token;
|
||||
Convert();
|
||||
};
|
||||
virtual idStr& Name( )
|
||||
virtual idStr& Name()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
@ -118,7 +146,7 @@ public:
|
|||
}
|
||||
// read data from uri file, and push it at end of current data buffer for this GLTF File
|
||||
// bufferView will be set accordingly to the generated buffer.
|
||||
bool Convert( );
|
||||
bool Convert();
|
||||
private:
|
||||
idStr name;
|
||||
int* bufferView;
|
||||
|
@ -132,7 +160,7 @@ class gltfItem_##className : public parsable, public parseType<ptype> \
|
|||
{public: \
|
||||
gltfItem_##className( idStr Name ) : name( Name ){ item = nullptr; } \
|
||||
virtual void parse( idToken &token ); \
|
||||
virtual idStr &Name( ) { return name; } \
|
||||
virtual idStr &Name() { return name; } \
|
||||
void Set( ptype *type, idLexer *lexer ) { parseType::Set( type ); parser = lexer; } \
|
||||
private: \
|
||||
idStr name; \
|
||||
|
@ -178,13 +206,13 @@ class gltfItem_##className : public parsable, public parseType<type> \
|
|||
{public: \
|
||||
gltfItem_##className( idStr Name ) : name( Name ){ item = nullptr; } \
|
||||
virtual void parse( idToken &token ) { function } \
|
||||
virtual idStr &Name( ) { return name; } \
|
||||
virtual idStr &Name() { return name; } \
|
||||
private: \
|
||||
idStr name;}
|
||||
#pragma endregion
|
||||
|
||||
gltfItemClass( integer, int, *item = token.GetIntValue( ); );
|
||||
gltfItemClass( number, float, *item = token.GetFloatValue( ); );
|
||||
gltfItemClass( integer, int, *item = token.GetIntValue(); );
|
||||
gltfItemClass( number, float, *item = token.GetFloatValue(); );
|
||||
gltfItemClass( boolean, bool, if( token.Icmp( "true" ) == 0 ) *item = true; else
|
||||
{
|
||||
if( token.Icmp( "false" ) == 0 )
|
||||
|
@ -201,18 +229,18 @@ gltfItemClass( boolean, bool, if( token.Icmp( "true" ) == 0 ) *item = true; else
|
|||
class gltfItemArray
|
||||
{
|
||||
public:
|
||||
~gltfItemArray( )
|
||||
~gltfItemArray()
|
||||
{
|
||||
items.DeleteContents( true );
|
||||
}
|
||||
gltfItemArray( ) { };
|
||||
gltfItemArray() { };
|
||||
int Num()
|
||||
{
|
||||
return items.Num();
|
||||
}
|
||||
void AddItemDef( parsable* item )
|
||||
{
|
||||
items.Alloc( ) = item;
|
||||
items.Alloc() = item;
|
||||
}
|
||||
int Fill( idLexer* lexer , idDict* strPairs );
|
||||
int Parse( idLexer* lexer , bool forwardLexer = false );
|
||||
|
@ -235,7 +263,7 @@ class gltfPropertyArray;
|
|||
class gltfPropertyItem
|
||||
{
|
||||
public:
|
||||
gltfPropertyItem( ) : array( nullptr ) { }
|
||||
gltfPropertyItem() : array( nullptr ) { }
|
||||
gltfPropertyArray* array;
|
||||
idToken item;
|
||||
};
|
||||
|
@ -244,12 +272,12 @@ class gltfPropertyArray
|
|||
{
|
||||
public:
|
||||
gltfPropertyArray( idLexer* Parser, bool AoS = true );
|
||||
~gltfPropertyArray( );
|
||||
~gltfPropertyArray();
|
||||
struct Iterator
|
||||
{
|
||||
gltfPropertyArray* array;
|
||||
gltfPropertyItem* p;
|
||||
gltfPropertyItem& operator*( )
|
||||
gltfPropertyItem& operator*()
|
||||
{
|
||||
return *p;
|
||||
}
|
||||
|
@ -257,10 +285,10 @@ public:
|
|||
{
|
||||
return p != rhs.p;
|
||||
}
|
||||
void operator ++( );
|
||||
void operator ++();
|
||||
};
|
||||
gltfPropertyArray::Iterator begin( );
|
||||
gltfPropertyArray::Iterator end( );
|
||||
gltfPropertyArray::Iterator begin();
|
||||
gltfPropertyArray::Iterator end();
|
||||
private:
|
||||
bool iterating;
|
||||
bool dirty;
|
||||
|
@ -283,9 +311,10 @@ public:
|
|||
|
||||
//current/last loaded gltf asset and index offsets
|
||||
gltfData* currentAsset;
|
||||
idStr currentFile;
|
||||
private:
|
||||
void SetNodeParent( gltfNode* node, gltfNode* parent = nullptr );
|
||||
//void CreateBgfxData( );
|
||||
//void CreateBgfxData();
|
||||
|
||||
void Parse_ASSET( idToken& token );
|
||||
void Parse_CAMERAS( idToken& token );
|
||||
|
@ -312,10 +341,15 @@ private:
|
|||
|
||||
idLexer parser;
|
||||
idToken token;
|
||||
idStr currentFile;
|
||||
|
||||
bool buffersDone;
|
||||
bool bufferViewsDone;
|
||||
};
|
||||
|
||||
class gltfManager
|
||||
{
|
||||
public:
|
||||
static bool ExtractMeshIdentifier( idStr& filename , int& meshId, idStr& meshName );
|
||||
};
|
||||
|
||||
extern GLTF_Parser* gltfParser;
|
|
@ -1,3 +1,31 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 2022 Harrie van Ginneken
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "containers/StrList.h"
|
||||
#include <functional>
|
||||
|
@ -59,7 +87,7 @@ struct gltf_accessor_component_type_map
|
|||
class gltfExtra
|
||||
{
|
||||
public:
|
||||
gltfExtra( ) { }
|
||||
gltfExtra() { }
|
||||
//entire extra json scope
|
||||
idStr json;
|
||||
//str:str pairs of each item
|
||||
|
@ -72,7 +100,7 @@ class gltfExt_KHR_lights_punctual;
|
|||
class gltfExtensions
|
||||
{
|
||||
public:
|
||||
gltfExtensions( ) { }
|
||||
gltfExtensions() { }
|
||||
idList<gltfExt_KHR_lights_punctual*> KHR_lights_punctual;
|
||||
};
|
||||
|
||||
|
@ -85,7 +113,7 @@ public:
|
|||
class gltfNode_Extensions
|
||||
{
|
||||
public:
|
||||
gltfNode_Extensions( ) :
|
||||
gltfNode_Extensions() :
|
||||
KHR_lights_punctual( nullptr ) { }
|
||||
gltfNode_KHR_lights_punctual* KHR_lights_punctual;
|
||||
};
|
||||
|
@ -94,7 +122,7 @@ class gltfExt_KHR_materials_pbrSpecularGlossiness;
|
|||
class gltfMaterial_Extensions
|
||||
{
|
||||
public:
|
||||
gltfMaterial_Extensions( ) :
|
||||
gltfMaterial_Extensions() :
|
||||
KHR_materials_pbrSpecularGlossiness( nullptr ) { }
|
||||
gltfExt_KHR_materials_pbrSpecularGlossiness* KHR_materials_pbrSpecularGlossiness;
|
||||
};
|
||||
|
@ -103,7 +131,7 @@ public:
|
|||
class gltfNode
|
||||
{
|
||||
public:
|
||||
gltfNode( ) : camera( -1 ), skin( -1 ), matrix( mat4_zero ),
|
||||
gltfNode() : camera( -1 ), skin( -1 ), matrix( mat4_zero ),
|
||||
mesh( -1 ), rotation( 0.f, 0.f, 0.f, 1.f ), scale( 1.f, 1.f, 1.f ),
|
||||
translation( vec3_zero ), parent( nullptr ), dirty( true ) { }
|
||||
int camera;
|
||||
|
@ -133,7 +161,7 @@ struct gltfCameraNodePtrs
|
|||
class gltfScene
|
||||
{
|
||||
public:
|
||||
gltfScene( ) { }
|
||||
gltfScene() { }
|
||||
idList<int> nodes;
|
||||
idStr name;
|
||||
idStr extensions;
|
||||
|
@ -165,7 +193,7 @@ public:
|
|||
Count
|
||||
};
|
||||
|
||||
gltfMesh_Primitive_Attribute( ) : accessorIndex( -1 ), elementSize( 0 ), type( gltfMesh_Primitive_Attribute::Type::Count ) { }
|
||||
gltfMesh_Primitive_Attribute() : accessorIndex( -1 ), elementSize( 0 ), type( gltfMesh_Primitive_Attribute::Type::Count ) { }
|
||||
idStr attributeSemantic;
|
||||
int accessorIndex;
|
||||
uint elementSize;
|
||||
|
@ -183,7 +211,7 @@ struct gltf_mesh_attribute_map
|
|||
class gltfMesh_Primitive
|
||||
{
|
||||
public:
|
||||
gltfMesh_Primitive( ) : indices( -1 ), material( -1 ), mode( -1 ) { }
|
||||
gltfMesh_Primitive() : indices( -1 ), material( -1 ), mode( -1 ) { }
|
||||
idList<gltfMesh_Primitive_Attribute*> attributes;
|
||||
int indices;
|
||||
int material;
|
||||
|
@ -196,7 +224,7 @@ public:
|
|||
class gltfMesh
|
||||
{
|
||||
public:
|
||||
gltfMesh( ) { };
|
||||
gltfMesh() { };
|
||||
|
||||
idList<gltfMesh_Primitive*> primitives; // gltfMesh_Primitive[1,*]
|
||||
idList<double> weights; // number[1,*]
|
||||
|
@ -208,7 +236,7 @@ public:
|
|||
class gltfCamera_Orthographic
|
||||
{
|
||||
public:
|
||||
gltfCamera_Orthographic( ) : xmag( 0.0f ), ymag( 0.0f ), zfar( 0.0f ), znear( 0.0f ) { };
|
||||
gltfCamera_Orthographic() : xmag( 0.0f ), ymag( 0.0f ), zfar( 0.0f ), znear( 0.0f ) { };
|
||||
float xmag;
|
||||
float ymag;
|
||||
float zfar;
|
||||
|
@ -220,7 +248,7 @@ public:
|
|||
class gltfCamera_Perspective
|
||||
{
|
||||
public:
|
||||
gltfCamera_Perspective( ) : aspectRatio( 0.0f ), yfov( 0.0f ), zfar( 0.0f ), znear( 0.0f ) { };
|
||||
gltfCamera_Perspective() : aspectRatio( 0.0f ), yfov( 0.0f ), zfar( 0.0f ), znear( 0.0f ) { };
|
||||
float aspectRatio;
|
||||
float yfov;
|
||||
float zfar;
|
||||
|
@ -232,7 +260,7 @@ public:
|
|||
class gltfCamera
|
||||
{
|
||||
public:
|
||||
gltfCamera( ) { };
|
||||
gltfCamera() { };
|
||||
gltfCamera_Orthographic orthographic;
|
||||
gltfCamera_Perspective perspective;
|
||||
idStr type;
|
||||
|
@ -244,7 +272,7 @@ public:
|
|||
class gltfAnimation_Channel_Target
|
||||
{
|
||||
public:
|
||||
gltfAnimation_Channel_Target( ) : node( -1 ), TRS( gltfTRS::count ) { };
|
||||
gltfAnimation_Channel_Target() : node( -1 ), TRS( gltfTRS::count ) { };
|
||||
int node;
|
||||
idStr path;
|
||||
idStr extensions;
|
||||
|
@ -287,7 +315,7 @@ public:
|
|||
class gltfAnimation_Channel
|
||||
{
|
||||
public:
|
||||
gltfAnimation_Channel( ) : sampler( -1 ) { };
|
||||
gltfAnimation_Channel() : sampler( -1 ) { };
|
||||
int sampler;
|
||||
gltfAnimation_Channel_Target target;
|
||||
idStr extensions;
|
||||
|
@ -297,7 +325,7 @@ public:
|
|||
class gltfAnimation_Sampler
|
||||
{
|
||||
public:
|
||||
gltfAnimation_Sampler( ) : input( -1 ), interpolation( "LINEAR" ), output( -1 ), intType( gltfInterpType::count ) { };
|
||||
gltfAnimation_Sampler() : input( -1 ), interpolation( "LINEAR" ), output( -1 ), intType( gltfInterpType::count ) { };
|
||||
int input;
|
||||
idStr interpolation;
|
||||
int output;
|
||||
|
@ -336,7 +364,7 @@ public:
|
|||
class gltfAnimation
|
||||
{
|
||||
public:
|
||||
gltfAnimation( ) : maxTime( 0.0f ), numFrames( 0 ) { };
|
||||
gltfAnimation() : maxTime( 0.0f ), numFrames( 0 ) { };
|
||||
idList<gltfAnimation_Channel*> channels;
|
||||
idList<gltfAnimation_Sampler*> samplers;
|
||||
idStr name;
|
||||
|
@ -368,7 +396,7 @@ public:
|
|||
{
|
||||
return false;
|
||||
}
|
||||
const idVec3& TotalMovementDelta( void ) const
|
||||
const idVec3& TotalMovementDelta() const
|
||||
{
|
||||
static idVec3 temp;
|
||||
return temp;
|
||||
|
@ -382,7 +410,7 @@ public:
|
|||
class gltfAccessor_Sparse_Values
|
||||
{
|
||||
public:
|
||||
gltfAccessor_Sparse_Values( ) : bufferView( -1 ), byteOffset( -1 ) { };
|
||||
gltfAccessor_Sparse_Values() : bufferView( -1 ), byteOffset( -1 ) { };
|
||||
int bufferView;
|
||||
int byteOffset;
|
||||
idStr extensions;
|
||||
|
@ -392,7 +420,7 @@ public:
|
|||
class gltfAccessor_Sparse_Indices
|
||||
{
|
||||
public:
|
||||
gltfAccessor_Sparse_Indices( ) : bufferView( -1 ), byteOffset( -1 ), componentType( -1 ) { };
|
||||
gltfAccessor_Sparse_Indices() : bufferView( -1 ), byteOffset( -1 ), componentType( -1 ) { };
|
||||
int bufferView;
|
||||
int byteOffset;
|
||||
int componentType;
|
||||
|
@ -403,7 +431,7 @@ public:
|
|||
class gltfAccessor_Sparse
|
||||
{
|
||||
public:
|
||||
gltfAccessor_Sparse( ) : count( -1 ) { };
|
||||
gltfAccessor_Sparse() : count( -1 ) { };
|
||||
int count;
|
||||
gltfAccessor_Sparse_Indices indices;
|
||||
gltfAccessor_Sparse_Values values;
|
||||
|
@ -414,7 +442,7 @@ public:
|
|||
class gltfAccessor
|
||||
{
|
||||
public:
|
||||
gltfAccessor( ) : bufferView( -1 ), byteOffset( 0 ), componentType( -1 ), normalized( false ), count( -1 ) ,
|
||||
gltfAccessor() : bufferView( -1 ), byteOffset( 0 ), componentType( -1 ), normalized( false ), count( -1 ) ,
|
||||
floatView( nullptr ), vecView( nullptr ), quatView( nullptr ), matView( nullptr ) { }
|
||||
int bufferView;
|
||||
int byteOffset;
|
||||
|
@ -440,7 +468,7 @@ public:
|
|||
class gltfBufferView
|
||||
{
|
||||
public:
|
||||
gltfBufferView( ) : buffer( -1 ), byteLength( -1 ), byteStride( 0 ), byteOffset( 0 ), target( -1 ) { };
|
||||
gltfBufferView() : buffer( -1 ), byteLength( -1 ), byteStride( 0 ), byteOffset( 0 ), target( -1 ) { };
|
||||
int buffer;
|
||||
int byteLength;
|
||||
int byteStride;
|
||||
|
@ -456,7 +484,7 @@ public:
|
|||
class gltfBuffer
|
||||
{
|
||||
public:
|
||||
gltfBuffer( ) : byteLength( -1 ), parent( nullptr ) { };
|
||||
gltfBuffer() : byteLength( -1 ), parent( nullptr ) { };
|
||||
idStr uri;
|
||||
int byteLength;
|
||||
idStr name;
|
||||
|
@ -469,7 +497,7 @@ public:
|
|||
class gltfSampler
|
||||
{
|
||||
public:
|
||||
gltfSampler( ) : magFilter( 0 ), minFilter( 0 ), wrapS( 10497 ), wrapT( 10497 ) { };
|
||||
gltfSampler() : magFilter( 0 ), minFilter( 0 ), wrapS( 10497 ), wrapT( 10497 ) { };
|
||||
int magFilter;
|
||||
int minFilter;
|
||||
int wrapS;
|
||||
|
@ -484,7 +512,7 @@ public:
|
|||
class gltfImage
|
||||
{
|
||||
public:
|
||||
gltfImage( ) : bufferView( -1 ) { }
|
||||
gltfImage() : bufferView( -1 ) { }
|
||||
idStr uri;
|
||||
idStr mimeType;
|
||||
int bufferView;
|
||||
|
@ -496,7 +524,7 @@ public:
|
|||
class gltfSkin
|
||||
{
|
||||
public:
|
||||
gltfSkin( ) : inverseBindMatrices( -1 ), skeleton( -1 ), name( "unnamedSkin" ) { };
|
||||
gltfSkin() : inverseBindMatrices( -1 ), skeleton( -1 ), name( "unnamedSkin" ) { };
|
||||
int inverseBindMatrices;
|
||||
int skeleton;
|
||||
idList<int> joints; // integer[1,*]
|
||||
|
@ -509,7 +537,7 @@ class gltfExt_KHR_texture_transform;
|
|||
class gltfTexture_Info_Extensions
|
||||
{
|
||||
public:
|
||||
gltfTexture_Info_Extensions( ) :
|
||||
gltfTexture_Info_Extensions() :
|
||||
KHR_texture_transform( nullptr ) { }
|
||||
gltfExt_KHR_texture_transform* KHR_texture_transform;
|
||||
};
|
||||
|
@ -517,7 +545,7 @@ public:
|
|||
class gltfOcclusionTexture_Info
|
||||
{
|
||||
public:
|
||||
gltfOcclusionTexture_Info( ) : index( -1 ), texCoord( 0 ), strength( 1.0f ) { }
|
||||
gltfOcclusionTexture_Info() : index( -1 ), texCoord( 0 ), strength( 1.0f ) { }
|
||||
int index;
|
||||
int texCoord;
|
||||
float strength;
|
||||
|
@ -528,7 +556,7 @@ public:
|
|||
class gltfNormalTexture_Info
|
||||
{
|
||||
public:
|
||||
gltfNormalTexture_Info( ) : index( -1 ), texCoord( 0 ), scale( 1.0f ) { }
|
||||
gltfNormalTexture_Info() : index( -1 ), texCoord( 0 ), scale( 1.0f ) { }
|
||||
int index;
|
||||
int texCoord;
|
||||
float scale;
|
||||
|
@ -539,7 +567,7 @@ public:
|
|||
class gltfTexture_Info
|
||||
{
|
||||
public:
|
||||
gltfTexture_Info( ) : index( -1 ), texCoord( 0 ) { }
|
||||
gltfTexture_Info() : index( -1 ), texCoord( 0 ) { }
|
||||
int index;
|
||||
int texCoord;
|
||||
gltfTexture_Info_Extensions extensions;
|
||||
|
@ -550,7 +578,7 @@ public:
|
|||
class gltfTexture
|
||||
{
|
||||
public:
|
||||
gltfTexture( ) : sampler( -1 ), source( -1 ) { }
|
||||
gltfTexture() : sampler( -1 ), source( -1 ) { }
|
||||
int sampler;
|
||||
int source;
|
||||
idStr name;
|
||||
|
@ -561,7 +589,7 @@ public:
|
|||
class gltfMaterial_pbrMetallicRoughness
|
||||
{
|
||||
public:
|
||||
gltfMaterial_pbrMetallicRoughness( ) : baseColorFactor( vec4_one ), metallicFactor( 1.0f ), roughnessFactor( 1.0f ) { }
|
||||
gltfMaterial_pbrMetallicRoughness() : baseColorFactor( vec4_one ), metallicFactor( 1.0f ), roughnessFactor( 1.0f ) { }
|
||||
idVec4 baseColorFactor;
|
||||
gltfTexture_Info baseColorTexture;
|
||||
float metallicFactor;
|
||||
|
@ -582,7 +610,7 @@ public:
|
|||
count
|
||||
};
|
||||
|
||||
gltfMaterial( ) : emissiveFactor( vec3_zero ), alphaMode( "OPAQUE" ), alphaCutoff( 0.5f ), doubleSided( false ) { }
|
||||
gltfMaterial() : emissiveFactor( vec3_zero ), alphaMode( "OPAQUE" ), alphaCutoff( 0.5f ), doubleSided( false ) { }
|
||||
gltfMaterial_pbrMetallicRoughness pbrMetallicRoughness;
|
||||
gltfNormalTexture_Info normalTexture;
|
||||
gltfOcclusionTexture_Info occlusionTexture;
|
||||
|
@ -618,7 +646,7 @@ public:
|
|||
class gltfAsset
|
||||
{
|
||||
public:
|
||||
gltfAsset( ) { }
|
||||
gltfAsset() { }
|
||||
idStr copyright;
|
||||
idStr generator;
|
||||
idStr version;
|
||||
|
@ -632,7 +660,7 @@ public:
|
|||
class gltfExtensionsUsed
|
||||
{
|
||||
public:
|
||||
gltfExtensionsUsed( ) { }
|
||||
gltfExtensionsUsed() { }
|
||||
idStr extension;
|
||||
};
|
||||
|
||||
|
@ -641,7 +669,7 @@ public:
|
|||
class gltfExt_KHR_materials_pbrSpecularGlossiness
|
||||
{
|
||||
public:
|
||||
gltfExt_KHR_materials_pbrSpecularGlossiness( ) { }
|
||||
gltfExt_KHR_materials_pbrSpecularGlossiness() { }
|
||||
idVec4 diffuseFactor;
|
||||
gltfTexture_Info diffuseTexture;
|
||||
idVec3 specularFactor;
|
||||
|
@ -656,7 +684,7 @@ public:
|
|||
class gltfExt_KHR_lights_punctual_spot
|
||||
{
|
||||
public:
|
||||
gltfExt_KHR_lights_punctual_spot( ) : innerConeAngle( 0.0f ), outerConeAngle( idMath::ONEFOURTH_PI ) { }
|
||||
gltfExt_KHR_lights_punctual_spot() : innerConeAngle( 0.0f ), outerConeAngle( idMath::ONEFOURTH_PI ) { }
|
||||
float innerConeAngle;
|
||||
float outerConeAngle;
|
||||
idStr extensions;
|
||||
|
@ -669,7 +697,7 @@ typedef gltfExt_KHR_lights_punctual_spot spot;
|
|||
class gltfExt_KHR_lights_punctual
|
||||
{
|
||||
public:
|
||||
gltfExt_KHR_lights_punctual( ) : color( vec3_one ), intensity( 1.0f ), range( -1.0f ), intType( -1 ) { }
|
||||
gltfExt_KHR_lights_punctual() : color( vec3_one ), intensity( 1.0f ), range( -1.0f ), intType( -1 ) { }
|
||||
idVec3 color;
|
||||
float intensity;
|
||||
spot spot;
|
||||
|
@ -704,7 +732,7 @@ public:
|
|||
class gltfExt_KHR_texture_transform
|
||||
{
|
||||
public:
|
||||
gltfExt_KHR_texture_transform( ) : offset( vec2_zero ), rotation( 0.0f ), scale( vec2_one ), texCoord( -1 ), index( 0 ), resolved( false ) { }
|
||||
gltfExt_KHR_texture_transform() : offset( vec2_zero ), rotation( 0.0f ), scale( vec2_one ), texCoord( -1 ), index( 0 ), resolved( false ) { }
|
||||
idVec2 offset;
|
||||
float rotation;
|
||||
idVec2 scale;
|
||||
|
@ -720,7 +748,7 @@ public:
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
//// For these to function you need to add an private idList<gltf{name}*> {target}
|
||||
#define GLTFCACHEITEM(name,target) \
|
||||
gltf##name * name ( ) { target.AssureSizeAlloc( target.Num()+1,idListNewElement<gltf##name>); return target[target.Num()-1];} \
|
||||
gltf##name * name () { target.AssureSizeAlloc( target.Num()+1,idListNewElement<gltf##name>); return target[target.Num()-1];} \
|
||||
const inline idList<gltf##name*> & ##name##List() { return target; }
|
||||
|
||||
|
||||
|
@ -732,8 +760,8 @@ const inline idList<gltf##name*> & ##name##List() { return target; }
|
|||
class gltfData
|
||||
{
|
||||
public:
|
||||
gltfData( ) : fileNameHash( 0 ), json( nullptr ), data( nullptr ), totalChunks( -1 ) { };
|
||||
~gltfData( );
|
||||
gltfData() : fileNameHash( 0 ), json( nullptr ), data( nullptr ), totalChunks( -1 ) { };
|
||||
~gltfData();
|
||||
byte* AddData( int size, int* bufferID = nullptr );
|
||||
byte* GetJsonData( int& size )
|
||||
{
|
||||
|
@ -747,13 +775,13 @@ public:
|
|||
void FileName( const idStr& file )
|
||||
{
|
||||
fileName = file;
|
||||
fileNameHash = fileDataHash.GenerateKey( file.c_str( ) );
|
||||
fileNameHash = fileDataHash.GenerateKey( file.c_str() );
|
||||
}
|
||||
int FileNameHash( )
|
||||
int FileNameHash()
|
||||
{
|
||||
return fileNameHash;
|
||||
}
|
||||
idStr& FileName( )
|
||||
idStr& FileName()
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
|
@ -763,21 +791,21 @@ public:
|
|||
//add data from filename
|
||||
static gltfData* Data( idStr& fileName )
|
||||
{
|
||||
dataList.AssureSizeAlloc( dataList.Num( ) + 1, idListNewElement<gltfData> );
|
||||
dataList[dataList.Num( ) - 1]->FileName( fileName );
|
||||
fileDataHash.Add( fileDataHash.GenerateKey( fileName ), dataList.Num( ) - 1 );
|
||||
return dataList[dataList.Num( ) - 1];
|
||||
dataList.AssureSizeAlloc( dataList.Num() + 1, idListNewElement<gltfData> );
|
||||
dataList[dataList.Num() - 1]->FileName( fileName );
|
||||
fileDataHash.Add( fileDataHash.GenerateKey( fileName ), dataList.Num() - 1 );
|
||||
return dataList[dataList.Num() - 1];
|
||||
}
|
||||
//find data;
|
||||
static gltfData* Data( const char* filename )
|
||||
{
|
||||
return dataList[fileDataHash.First( fileDataHash.GenerateKey( filename ) )];
|
||||
}
|
||||
static const idList<gltfData*>& DataList( )
|
||||
static const idList<gltfData*>& DataList()
|
||||
{
|
||||
return dataList;
|
||||
}
|
||||
static void ClearData( )
|
||||
static void ClearData()
|
||||
{
|
||||
idLib::Warning( "TODO! DATA NOT FREED" );
|
||||
}
|
||||
|
@ -802,7 +830,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
for( int i = 0; i < nodes.Num( ); i++ )
|
||||
for( int i = 0; i < nodes.Num(); i++ )
|
||||
{
|
||||
if( nodes[i]->camera != -1 && nodes[i]->camera == camId )
|
||||
{
|
||||
|
@ -813,6 +841,135 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
gltfNode* GetNode( gltfScene* scene , gltfMesh* mesh , int* id = nullptr )
|
||||
{
|
||||
assert( scene );
|
||||
assert( mesh );
|
||||
|
||||
auto& nodeList = scene->nodes;
|
||||
int nodeCnt = 0;
|
||||
for( auto& nodeId : nodeList )
|
||||
{
|
||||
|
||||
if( nodes[nodeId]->mesh != -1 &&*& meshes[nodes[nodeId]->mesh] == mesh )
|
||||
{
|
||||
if( id != nullptr )
|
||||
{
|
||||
*id = nodeCnt;
|
||||
}
|
||||
|
||||
return nodes[nodeId];
|
||||
}
|
||||
nodeCnt++;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gltfNode* GetNode( gltfScene* scene, idStr name )
|
||||
{
|
||||
assert( scene );
|
||||
assert( name[0] );
|
||||
|
||||
auto& nodeList = scene->nodes;
|
||||
for( auto& nodeId : nodeList )
|
||||
{
|
||||
if( nodes[nodeId]->name == name )
|
||||
{
|
||||
return nodes[nodeId];
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gltfNode* GetNode( idStr sceneName, int id, idStr* name = nullptr )
|
||||
{
|
||||
int sceneId = GetSceneId( sceneName );
|
||||
if( sceneId < 0 || sceneId > scenes.Num( ) )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gltfScene* scene = scenes[sceneId];
|
||||
|
||||
assert( scene );
|
||||
assert( id >= 0 );
|
||||
|
||||
auto& nodeList = scene->nodes;
|
||||
for( auto& nodeId : nodeList )
|
||||
{
|
||||
if( nodeId == id )
|
||||
{
|
||||
if( name != nullptr )
|
||||
{
|
||||
*name = nodes[nodeId]->name;
|
||||
}
|
||||
|
||||
return nodes[nodeId];
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gltfNode* GetNode( idStr sceneName, idStr name , int* id = nullptr )
|
||||
{
|
||||
int sceneId = GetSceneId( sceneName );
|
||||
if( sceneId < 0 || sceneId > scenes.Num() )
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gltfScene* scene = scenes[sceneId];
|
||||
|
||||
assert( scene );
|
||||
assert( name[0] );
|
||||
|
||||
auto& nodeList = scene->nodes;
|
||||
for( auto& nodeId : nodeList )
|
||||
{
|
||||
if( nodes[nodeId]->name.Icmp( name ) == 0 )
|
||||
{
|
||||
if( id != nullptr )
|
||||
{
|
||||
*id = nodeId;
|
||||
}
|
||||
|
||||
return nodes[nodeId];
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool HasAnimation( int nodeID )
|
||||
{
|
||||
for( auto anim : animations )
|
||||
{
|
||||
for( auto channel : anim->channels )
|
||||
{
|
||||
if( channel->target.node == nodeID )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int GetSceneId( idStr sceneName ) const
|
||||
{
|
||||
for( int i = 0; i < scenes.Num(); i++ )
|
||||
{
|
||||
if( scenes[i]->name == sceneName )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
idMat4 GetViewMatrix( int camId ) const
|
||||
{
|
||||
//if (cameraManager->HasOverideID(camId) )
|
||||
|
@ -826,7 +983,7 @@ public:
|
|||
idList<gltfNode*> hierachy( 2 );
|
||||
gltfNode* parent = nullptr;
|
||||
|
||||
for( int i = 0; i < nodes.Num( ); i++ )
|
||||
for( int i = 0; i < nodes.Num(); i++ )
|
||||
{
|
||||
if( nodes[i]->camera != -1 && nodes[i]->camera == camId )
|
||||
{
|
||||
|
@ -840,7 +997,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
for( int i = hierachy.Num( ) - 1; i >= 0; i-- )
|
||||
for( int i = hierachy.Num() - 1; i >= 0; i-- )
|
||||
{
|
||||
ResolveNodeMatrix( hierachy[i] );
|
||||
result *= hierachy[i]->matrix;
|
||||
|
@ -848,6 +1005,7 @@ public:
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
//Please note : assumes all nodes are _not_ dirty!
|
||||
idMat4 GetLightMatrix( int lightId ) const
|
||||
{
|
||||
|
@ -857,7 +1015,7 @@ public:
|
|||
gltfNode* parent = nullptr;
|
||||
hierachy.SetGranularity( 2 );
|
||||
|
||||
for( int i = 0; i < nodes.Num( ); i++ )
|
||||
for( int i = 0; i < nodes.Num(); i++ )
|
||||
{
|
||||
if( nodes[i]->extensions.KHR_lights_punctual && nodes[i]->extensions.KHR_lights_punctual->light == lightId )
|
||||
{
|
||||
|
@ -871,7 +1029,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
for( int i = hierachy.Num( ) - 1; i >= 0; i-- )
|
||||
for( int i = hierachy.Num() - 1; i >= 0; i-- )
|
||||
{
|
||||
result *= hierachy[i]->matrix;
|
||||
}
|
||||
|
@ -896,7 +1054,7 @@ public:
|
|||
0, 0, 0, 1
|
||||
);
|
||||
|
||||
node->matrix = idMat4( mat3_identity, node->translation ) * node->rotation.ToMat4( ).Transpose( ) * scaleMat;
|
||||
node->matrix = idMat4( mat3_identity, node->translation ) * node->rotation.ToMat4().Transpose() * scaleMat;
|
||||
|
||||
node->dirty = false;
|
||||
}
|
||||
|
@ -916,7 +1074,7 @@ public:
|
|||
}
|
||||
parent = parent->parent;
|
||||
}
|
||||
for( int i = hierachy.Num( ) - 1; i >= 0; i-- )
|
||||
for( int i = hierachy.Num() - 1; i >= 0; i-- )
|
||||
{
|
||||
*mat *= hierachy[i]->matrix;
|
||||
}
|
||||
|
@ -931,7 +1089,7 @@ public:
|
|||
idList<float>& GetAccessorView( gltfAccessor* accessor );
|
||||
idList<idMat4>& GetAccessorViewMat( gltfAccessor* accessor );
|
||||
|
||||
int& DefaultScene( )
|
||||
int& DefaultScene()
|
||||
{
|
||||
return scene;
|
||||
}
|
||||
|
@ -962,22 +1120,22 @@ private:
|
|||
int totalChunks;
|
||||
|
||||
idList<gltfBuffer*> buffers;
|
||||
idList<gltfImage*> images;
|
||||
idList<gltfData*> assetData;
|
||||
idList<gltfSampler*> samplers;
|
||||
idList<gltfImage*> images;
|
||||
idList<gltfData*> assetData;
|
||||
idList<gltfSampler*> samplers;
|
||||
idList<gltfBufferView*> bufferViews;
|
||||
idList<gltfTexture*> textures;
|
||||
idList<gltfAccessor*> accessors;
|
||||
idList<gltfTexture*> textures;
|
||||
idList<gltfAccessor*> accessors;
|
||||
idList<gltfExtensionsUsed*> extensionsUsed;
|
||||
idList<gltfMesh*> meshes;
|
||||
int scene;
|
||||
idList<gltfScene*> scenes;
|
||||
idList<gltfNode*> nodes;
|
||||
idList<gltfMesh*> meshes;
|
||||
int scene;
|
||||
idList<gltfScene*> scenes;
|
||||
idList<gltfNode*> nodes;
|
||||
idList<gltfCamera*> cameras;
|
||||
idList<gltfMaterial*> materials;
|
||||
idList<gltfMaterial*> materials;
|
||||
idList<gltfExtensions*> extensions;
|
||||
idList<gltfAnimation*> animations;
|
||||
idList<gltfSkin*> skins;
|
||||
idList<gltfAnimation*> animations;
|
||||
idList<gltfSkin*> skins;
|
||||
};
|
||||
|
||||
#undef GLTFCACHEITEM
|
|
@ -961,7 +961,7 @@ public:
|
|||
float* ToFloatPtr();
|
||||
const char* ToString( int precision = 2 ) const;
|
||||
// jmarshall
|
||||
idMat3 ToMat3( void ) const;
|
||||
idMat3 ToMat3() const;
|
||||
// jmarshall end
|
||||
private:
|
||||
idVec4 mat[ 4 ];
|
||||
|
@ -972,7 +972,7 @@ extern idMat4 mat4_identity;
|
|||
#define mat4_default mat4_identity
|
||||
|
||||
// jmarshall
|
||||
ID_INLINE idMat3 idMat4::ToMat3( void ) const
|
||||
ID_INLINE idMat3 idMat4::ToMat3() const
|
||||
{
|
||||
idMat3 m;
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ bool AssertFailed( const char* file, int line, const char* expression );
|
|||
|
||||
//====================== assert in release mode =======================
|
||||
|
||||
#define idassert( x ) { (( void )0); }
|
||||
#define idassert( x ) { ( ( void )0 ); }
|
||||
|
||||
#undef assert
|
||||
|
||||
|
|
|
@ -355,7 +355,7 @@ public:
|
|||
return ( contentVector.size() > 0 ) ;
|
||||
}
|
||||
|
||||
const typename Content<_T>::Vector& GetContents( ) const
|
||||
const typename Content<_T>::Vector& GetContents() const
|
||||
{
|
||||
|
||||
return contentVector;
|
||||
|
|
|
@ -2813,7 +2813,7 @@ fill_input_buffer( j_decompress_ptr cinfo )
|
|||
*/
|
||||
|
||||
#ifdef USE_NEWER_JPEG
|
||||
METHODDEF( void )
|
||||
METHODDEF()
|
||||
#else
|
||||
METHODDEF void
|
||||
#endif
|
||||
|
@ -2841,7 +2841,7 @@ init_source( j_decompress_ptr cinfo )
|
|||
*/
|
||||
|
||||
#ifdef USE_NEWER_JPEG
|
||||
METHODDEF( void )
|
||||
METHODDEF()
|
||||
#else
|
||||
METHODDEF void
|
||||
#endif
|
||||
|
@ -2881,7 +2881,7 @@ skip_input_data( j_decompress_ptr cinfo, long num_bytes )
|
|||
*/
|
||||
|
||||
#ifdef USE_NEWER_JPEG
|
||||
METHODDEF( void )
|
||||
METHODDEF()
|
||||
#else
|
||||
METHODDEF void
|
||||
#endif
|
||||
|
@ -2892,7 +2892,7 @@ term_source( j_decompress_ptr cinfo )
|
|||
}
|
||||
|
||||
#ifdef USE_NEWER_JPEG
|
||||
GLOBAL( void )
|
||||
GLOBAL()
|
||||
#else
|
||||
GLOBAL void
|
||||
#endif
|
||||
|
|
|
@ -239,11 +239,11 @@ struct stencilStage_t
|
|||
// (if either Pass, Fail or ZFail is set to replace).
|
||||
byte ref = 0;
|
||||
|
||||
// An 8 bit mask as an 0–255 integer, used when comparing the reference value with the contents of the buffer
|
||||
// An 8 bit mask as an 0<EFBFBD>255 integer, used when comparing the reference value with the contents of the buffer
|
||||
// (referenceValue & readMask) comparisonFunction (stencilBufferValue & readMask).
|
||||
byte readMask = 255;
|
||||
|
||||
// An 8 bit mask as an 0–255 integer, used when writing to the buffer.Note that, like other write masks,
|
||||
// An 8 bit mask as an 0<EFBFBD>255 integer, used when writing to the buffer.Note that, like other write masks,
|
||||
// it specifies which bits of stencil buffer will be affected by write
|
||||
// (i.e.WriteMask 0 means that no bits are affected and not that 0 will be written).
|
||||
byte writeMask = 255;
|
||||
|
|
|
@ -178,7 +178,7 @@ void idRenderModelStatic::List() const
|
|||
totalTris += surf->geometry->numIndexes / 3;
|
||||
totalVerts += surf->geometry->numVerts;
|
||||
}
|
||||
common->Printf( "%c%4ik %3i %4i %4i %s", closed, totalBytes / 1024, NumSurfaces(), totalVerts, totalTris, Name() );
|
||||
common->Printf( "%c%4ik %3i %4i %4i '%s'", closed, totalBytes / 1024, NumSurfaces(), totalVerts, totalTris, Name() );
|
||||
|
||||
if( IsDynamicModel() == DM_CACHED )
|
||||
{
|
||||
|
|
|
@ -360,12 +360,11 @@ idRenderModel* idRenderModelManagerLocal::GetModel( const char* _modelName, bool
|
|||
if( ( extension.Icmp( GLTF_GLB_EXT ) == 0 ) || ( extension.Icmp( GLTF_EXT ) == 0 ) )
|
||||
{
|
||||
model = new( TAG_MODEL ) idRenderModelGLTF;
|
||||
|
||||
// RB: Collada DAE and Wavefront OBJ
|
||||
}
|
||||
else if( ( extension.Icmp( "dae" ) == 0 ) || ( extension.Icmp( "obj" ) == 0 ) // RB: Collada DAE and Wavefront OBJ
|
||||
|| ( extension.Icmp( "ase" ) == 0 ) || ( extension.Icmp( "lwo" ) == 0 )
|
||||
|| ( extension.Icmp( "flt" ) == 0 ) || ( extension.Icmp( "ma" ) == 0 ) )
|
||||
|| ( extension.Icmp( "flt" ) == 0 ) || ( extension.Icmp( "ma" ) == 0 ) )
|
||||
{
|
||||
model = new( TAG_MODEL ) idRenderModelStatic;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,69 +1,86 @@
|
|||
/*
|
||||
===========================================================================
|
||||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 2022 Harrie van Ginneken
|
||||
|
||||
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
||||
|
||||
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
||||
|
||||
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
||||
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Model_local.h"
|
||||
|
||||
class gltfManager
|
||||
{
|
||||
public:
|
||||
static bool ExtractMeshIdentifier( idStr& filename , int& meshId, idStr& meshName );
|
||||
};
|
||||
|
||||
|
||||
class idGltfMesh
|
||||
{
|
||||
public:
|
||||
idGltfMesh( gltfMesh* _mesh, gltfData* _data ) : mesh( _mesh ), data( _data ) {};
|
||||
|
||||
idGltfMesh( ) {};
|
||||
idGltfMesh( gltfMesh* _mesh, gltfData* _data );
|
||||
private:
|
||||
gltfMesh* mesh;
|
||||
gltfData* data;
|
||||
idMD5Mesh md5Mesh;
|
||||
};
|
||||
|
||||
class idRenderModelGLTF : public idRenderModelStatic
|
||||
{
|
||||
public:
|
||||
void InitFromFile( const char* fileName ) override;
|
||||
bool LoadBinaryModel( idFile* file, const ID_TIME_T sourceTimeStamp ) override;
|
||||
void WriteBinaryModel( idFile* file, ID_TIME_T* _timeStamp = NULL ) const override;
|
||||
bool SupportsBinaryModel( ) override;
|
||||
void ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp = NULL ) override;
|
||||
void PartialInitFromFile( const char* fileName ) override;
|
||||
void PurgeModel( ) override;
|
||||
void Reset( ) override;
|
||||
void LoadModel( ) override;
|
||||
bool IsLoaded( ) override;
|
||||
void SetLevelLoadReferenced( bool referenced ) override;
|
||||
bool IsLevelLoadReferenced( ) override;
|
||||
void TouchData( ) override;
|
||||
void CreateBuffers( nvrhi::ICommandList* commandList ) override;
|
||||
void InitEmpty( const char* name ) override;
|
||||
void AddSurface( modelSurface_t surface ) override;
|
||||
void FinishSurfaces( bool useMikktspace ) override;
|
||||
void FreeVertexCache( ) override;
|
||||
const char* Name( ) const override;
|
||||
void Print( ) const override;
|
||||
void List( ) const override;
|
||||
int Memory( ) const override;
|
||||
ID_TIME_T Timestamp( ) const override;
|
||||
int NumSurfaces( ) const override;
|
||||
int NumBaseSurfaces( ) const override;
|
||||
const modelSurface_t* Surface( int surfaceNum ) const override;
|
||||
srfTriangles_t* AllocSurfaceTriangles( int numVerts, int numIndexes ) const override;
|
||||
void FreeSurfaceTriangles( srfTriangles_t* tris ) const override;
|
||||
bool IsStaticWorldModel( ) const override;
|
||||
dynamicModel_t IsDynamicModel( ) const override;
|
||||
bool IsDefaultModel( ) const override;
|
||||
bool IsReloadable( ) const override;
|
||||
idRenderModel* InstantiateDynamicModel( const struct renderEntity_s* ent, const viewDef_t* view, idRenderModel* cachedModel ) override;
|
||||
int NumJoints( ) const override;
|
||||
const idMD5Joint* GetJoints( ) const override;
|
||||
jointHandle_t GetJointHandle( const char* name ) const override;
|
||||
const char* GetJointName( jointHandle_t handle ) const override;
|
||||
const idJointQuat* GetDefaultPose( ) const override;
|
||||
int NearestJoint( int surfaceNum, int a, int b, int c ) const override;
|
||||
idBounds Bounds( const struct renderEntity_s* ent ) const override;
|
||||
void ReadFromDemoFile( class idDemoFile* f ) override;
|
||||
void WriteToDemoFile( class idDemoFile* f ) override;
|
||||
float DepthHack( ) const override;
|
||||
bool ModelHasDrawingSurfaces( ) const override;
|
||||
bool ModelHasInteractingSurfaces( ) const override;
|
||||
bool ModelHasShadowCastingSurfaces( ) const override;
|
||||
virtual void InitFromFile( const char* fileName );
|
||||
virtual bool LoadBinaryModel( idFile* file, const ID_TIME_T sourceTimeStamp );
|
||||
virtual void WriteBinaryModel( idFile* file, ID_TIME_T* _timeStamp = NULL ) const;
|
||||
virtual dynamicModel_t IsDynamicModel() const;
|
||||
virtual idBounds Bounds( const struct renderEntity_s* ent ) const;
|
||||
virtual void Print() const;
|
||||
virtual void List() const;
|
||||
virtual void TouchData();
|
||||
virtual void PurgeModel();
|
||||
virtual void LoadModel();
|
||||
virtual int Memory() const;
|
||||
virtual idRenderModel* InstantiateDynamicModel( const struct renderEntity_s* ent, const viewDef_t* view, idRenderModel* cachedModel );
|
||||
virtual int NumJoints() const;
|
||||
virtual const idMD5Joint* GetJoints() const;
|
||||
virtual jointHandle_t GetJointHandle( const char* name ) const;
|
||||
virtual const char* GetJointName( jointHandle_t handle ) const;
|
||||
virtual const idJointQuat* GetDefaultPose() const;
|
||||
virtual int NearestJoint( int surfaceNum, int a, int b, int c ) const;
|
||||
virtual bool SupportsBinaryModel() override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void MakeMD5Mesh() ;
|
||||
private:
|
||||
void ProcessNode( gltfNode* modelNode, idMat4 trans, gltfData* data );
|
||||
void UpdateSurface( const struct renderEntity_s* ent, idMat4 trans, modelSurface_t* surf );
|
||||
int rootID;
|
||||
|
||||
gltfData* data;
|
||||
gltfNode* root;
|
||||
bool fileExclusive;
|
||||
bool hasAnimations;
|
||||
idList<int> animIds;
|
||||
idList<idGltfMesh, TAG_MODEL> meshes;
|
||||
dynamicModel_t model_state;
|
||||
idMat4 prevTrans;
|
||||
idList<gltfNode*, TAG_MODEL> SkeletonNodes;
|
||||
};
|
|
@ -181,6 +181,7 @@ protected:
|
|||
class idMD5Mesh
|
||||
{
|
||||
friend class idRenderModelMD5;
|
||||
friend class idRenderModelGLTF;
|
||||
|
||||
public:
|
||||
idMD5Mesh();
|
||||
|
@ -215,6 +216,7 @@ private:
|
|||
|
||||
class idRenderModelMD5 : public idRenderModelStatic
|
||||
{
|
||||
friend class idRenderModelGLTF;
|
||||
public:
|
||||
void InitFromFile( const char* fileName ) override;
|
||||
bool LoadBinaryModel( idFile* file, const ID_TIME_T sourceTimeStamp ) override;
|
||||
|
|
|
@ -125,6 +125,12 @@ objModel_t* OBJ_Parse( const char* fileName, const char* objFileBuffer, int leng
|
|||
idStr line;
|
||||
src.ReadRestOfLine( line );
|
||||
}
|
||||
else if( token == "l" )
|
||||
{
|
||||
// We don't support lines
|
||||
idStr line;
|
||||
src.ReadRestOfLine( line );
|
||||
}
|
||||
else if( token == "o" || token == "g" )
|
||||
{
|
||||
idStr line;
|
||||
|
|
|
@ -609,7 +609,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
" *\n"
|
||||
" * The shader has three passes, chained together as follows:\n"
|
||||
" *\n"
|
||||
" * |input|------------------·\n"
|
||||
" * |input|------------------\n"
|
||||
" * v |\n"
|
||||
" * [ SMAA*EdgeDetection ] |\n"
|
||||
" * v |\n"
|
||||
|
@ -619,7 +619,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
" * v |\n"
|
||||
" * |blendTex| |\n"
|
||||
" * v |\n"
|
||||
" * [ SMAANeighborhoodBlending ] <------·\n"
|
||||
" * [ SMAANeighborhoodBlending ] <------\n"
|
||||
" * v\n"
|
||||
" * |output|\n"
|
||||
" *\n"
|
||||
|
@ -2072,7 +2072,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
"}\n"
|
||||
"\n"
|
||||
"// Fresnel term F( v, h )\n"
|
||||
"// Fnone( v, h ) = F(0°) = specularColor\n"
|
||||
"// Fnone( v, h ) = F(0) = specularColor\n"
|
||||
"half3 Fresnel_Schlick( half3 specularColor, half vDotN )\n"
|
||||
"{\n"
|
||||
" return specularColor + ( 1.0 - specularColor ) * pow( 1.0 - vDotN, 5.0 );\n"
|
||||
|
|
|
@ -631,7 +631,7 @@ void idSoundHardware_XAudio2::Shutdown()
|
|||
{
|
||||
XAUDIO2_PERFORMANCE_DATA perfData;
|
||||
pXAudio2->GetPerformanceData( &perfData );
|
||||
idLib::Printf( "Final pXAudio2 performanceData: Voices: %d/%d CPU: %.2f%% Mem: %dkb\n", perfData.ActiveSourceVoiceCount, perfData.TotalSourceVoiceCount, perfData.AudioCyclesSinceLastQuery / ( float )perfData.TotalCyclesSinceLastQuery, perfData.MemoryUsageInBytes / 1024 );
|
||||
//idLib::Printf( "Final pXAudio2 performanceData: Voices: %d/%d CPU: %.2f%% Mem: %dkb\n", perfData.ActiveSourceVoiceCount, perfData.TotalSourceVoiceCount, perfData.AudioCyclesSinceLastQuery / ( float )perfData.TotalCyclesSinceLastQuery, perfData.MemoryUsageInBytes / 1024 );
|
||||
pXAudio2->Release();
|
||||
pXAudio2 = NULL;
|
||||
}
|
||||
|
|
|
@ -1708,8 +1708,12 @@ sysEvent_t Sys_GetEvent()
|
|||
common->Warning( "unknown user event %u", ev.user.code );
|
||||
}
|
||||
continue; // just handle next event
|
||||
|
||||
case SDL_KEYMAPCHANGED:
|
||||
continue; // just handle next event
|
||||
|
||||
default:
|
||||
common->Warning( "unknown event %u", ev.type );
|
||||
common->Warning( "unknown event %u = %#x", ev.type, ev.type );
|
||||
continue; // just handle next event
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ typedef enum D3_PROCESS_DPI_AWARENESS
|
|||
void Sys_SetDPIAwareness()
|
||||
{
|
||||
// For Vista, Win7 and Win8
|
||||
BOOL( WINAPI * SetProcessDPIAware )( void ) = NULL;
|
||||
BOOL( WINAPI * SetProcessDPIAware )() = NULL;
|
||||
|
||||
/* Win8.1 and later */
|
||||
HRESULT( WINAPI * SetProcessDpiAwareness )( D3_PROCESS_DPI_AWARENESS dpiAwareness ) = NULL;
|
||||
|
@ -111,7 +111,7 @@ void Sys_SetDPIAwareness()
|
|||
HINSTANCE userDLL = LoadLibrary( "USER32.DLL" );
|
||||
if( userDLL )
|
||||
{
|
||||
SetProcessDPIAware = ( BOOL( WINAPI* )( void ) ) GetProcAddress( userDLL, "SetProcessDPIAware" );
|
||||
SetProcessDPIAware = ( BOOL( WINAPI* )() ) GetProcAddress( userDLL, "SetProcessDPIAware" );
|
||||
}
|
||||
|
||||
HINSTANCE shcoreDLL = LoadLibrary( "SHCORE.DLL" );
|
||||
|
@ -713,7 +713,7 @@ Sys_GogBasePath
|
|||
*/
|
||||
static char gogPathBuffer[MAX_OSPATH] = { 0 };
|
||||
|
||||
static const char* Sys_GogBasePath( void )
|
||||
static const char* Sys_GogBasePath()
|
||||
{
|
||||
#ifdef GOGPATH_ID
|
||||
HKEY gogRegKey;
|
||||
|
|
|
@ -409,6 +409,14 @@ void Dmap( const idCmdArgs& args )
|
|||
idStr generated = va( "generated/%s.bproc", dmapGlobals.mapFileBase );
|
||||
fileSystem->RemoveFile( generated.c_str() );
|
||||
|
||||
// delete any old generated binary cm files
|
||||
generated = va( "generated/%s.bcm", dmapGlobals.mapFileBase );
|
||||
fileSystem->RemoveFile( generated.c_str() );
|
||||
|
||||
// delete any old ASCII collision files
|
||||
idStr::snPrintf( path, sizeof( path ), "%s.cm", dmapGlobals.mapFileBase );
|
||||
fileSystem->RemoveFile( path );
|
||||
|
||||
//
|
||||
// start from scratch
|
||||
//
|
||||
|
@ -448,17 +456,16 @@ void Dmap( const idCmdArgs& args )
|
|||
|
||||
if( !leaked )
|
||||
{
|
||||
|
||||
if( !noCM )
|
||||
{
|
||||
|
||||
// make sure the collision model manager is not used by the game
|
||||
cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect" );
|
||||
|
||||
// create the collision map
|
||||
start = Sys_Milliseconds();
|
||||
|
||||
collisionModelManager->LoadMap( dmapGlobals.dmapFile );
|
||||
// write always a fresh .cm file
|
||||
collisionModelManager->LoadMap( dmapGlobals.dmapFile, true );
|
||||
collisionModelManager->FreeMap();
|
||||
|
||||
end = Sys_Milliseconds();
|
||||
|
|
|
@ -492,19 +492,22 @@ static int ParsePolygonMesh( const MapPolygonMesh* mesh, int primitiveNum, int n
|
|||
|
||||
// TODO use WindingToTriList instead ?
|
||||
|
||||
for( int j = 1; j < indexes.Num() - 1; j++ )
|
||||
//for( int j = indexes.Num() -2; j >= 1; j-- )
|
||||
if( indexes.Num() == 3 )
|
||||
{
|
||||
// RB: glTF2 workflow insists to use triangles instead of n-gons or quads
|
||||
mapTri_t* tri = AllocTri();
|
||||
|
||||
#if 1
|
||||
tri->v[0] = verts[ indexes[ j + 1] ];
|
||||
tri->v[1] = verts[ indexes[ j + 0] ];
|
||||
tri->v[0] = verts[ indexes[ 2 ] ];
|
||||
tri->v[1] = verts[ indexes[ 1 ] ];
|
||||
tri->v[2] = verts[ indexes[ 0 ] ];
|
||||
#else
|
||||
tri->v[2] = verts[ indexes[ j + 1] ];
|
||||
tri->v[1] = verts[ indexes[ j + 0] ];
|
||||
tri->v[0] = verts[ indexes[ 0 ] ];
|
||||
|
||||
#if 0
|
||||
idLib::Printf( "indices: ( %i %i %i )\n", indexes[ 0 ], indexes[ 1 ], indexes[ 2 ] );
|
||||
|
||||
idLib::Printf( "verts: ( %i %i %i ) ( %i %i %i ) ( %i %i %i )\n",
|
||||
int( tri->v[0].xyz.x ), int( tri->v[0].xyz.y ), int( tri->v[0].xyz.z ),
|
||||
int( tri->v[1].xyz.x ), int( tri->v[1].xyz.y ), int( tri->v[1].xyz.z ),
|
||||
int( tri->v[2].xyz.x ), int( tri->v[2].xyz.y ), int( tri->v[2].xyz.z ) );
|
||||
#endif
|
||||
|
||||
idPlane plane;
|
||||
|
@ -531,6 +534,41 @@ static int ParsePolygonMesh( const MapPolygonMesh* mesh, int primitiveNum, int n
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( int j = 1; j < indexes.Num() - 1; j++ )
|
||||
{
|
||||
mapTri_t* tri = AllocTri();
|
||||
|
||||
tri->v[0] = verts[ indexes[ j + 1] ];
|
||||
tri->v[1] = verts[ indexes[ j + 0] ];
|
||||
tri->v[2] = verts[ indexes[ 0 ] ];
|
||||
|
||||
idPlane plane;
|
||||
plane.FromPoints( tri->v[0].xyz, tri->v[1].xyz, tri->v[2].xyz );
|
||||
|
||||
bool fixedDegeneracies = false;
|
||||
tri->planeNum = FindFloatPlane( plane, &fixedDegeneracies );
|
||||
|
||||
tri->polygonId = numPolygons + i;
|
||||
|
||||
tri->material = mat;
|
||||
tri->next = prim->bsptris;
|
||||
prim->bsptris = tri;
|
||||
|
||||
tri->originalMapMesh = mesh;
|
||||
|
||||
// set merge groups if needed, to prevent multiple sides from being
|
||||
// merged into a single surface in the case of gui shaders, mirrors, and autosprites
|
||||
if( mat->IsDiscrete() )
|
||||
{
|
||||
for( tri = prim->bsptris ; tri ; tri = tri->next )
|
||||
{
|
||||
tri->mergeGroup = ( void* )mesh;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mesh->GetNumPolygons();
|
||||
|
|
Loading…
Reference in a new issue