mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-25 02:52:12 +00:00
- hierarchical bsp/worldmodel loading
- gltf support for model def. Looks up item within the "models" scene of the target gltf!
This commit is contained in:
parent
b147183658
commit
e5ecb219e5
10 changed files with 338 additions and 306 deletions
|
@ -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;
|
||||
}
|
||||
|
@ -4564,7 +4565,23 @@ cmHandle_t idCollisionModelManagerLocal::LoadModel( const char* modelName, const
|
|||
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 )
|
||||
{
|
||||
|
|
|
@ -1671,7 +1671,7 @@ bool idMapFile::Parse( const char* filename, bool ignoreRegion, bool osPath )
|
|||
else if( isGTLF )
|
||||
{
|
||||
gltfParser->Load( fullName );
|
||||
idMapEntity::GetEntities( gltfParser->currentAsset, entities, 0 );
|
||||
idMapEntity::GetEntities( gltfParser->currentAsset, entities, gltfParser->currentAsset->GetSceneId( "Scene" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -349,7 +349,7 @@ public:
|
|||
|
||||
void ConvertFromBrush( const idMapBrush* brush, int entityNum, int primitiveNum );
|
||||
void ConvertFromPatch( const idMapPatch* patch, int entityNum, int primitiveNum );
|
||||
static MapPolygonMesh* ConvertFromMeshGltf( const gltfMesh_Primitive* prim, 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 };
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
static const unsigned int gltfChunk_Type_JSON = 0x4E4F534A; //1313821514
|
||||
static const unsigned int gltfChunk_Type_BIN = 0x004E4942; //5130562
|
||||
|
||||
idCVar gltf_parseVerbose( "gltf_parseVerbose", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "print gltf json data while parsing" );
|
||||
idCVar gltfParser_PrefixNodeWithID( "gltfParser_PrefixNodeWithID", "0", CVAR_SYSTEM | CVAR_BOOL, "The node's id is prefixed to the node's name during load" );
|
||||
//
|
||||
//gltf_sampler_wrap_type_map s_samplerWrapTypeMap[] = {
|
||||
|
@ -136,8 +137,6 @@ idList<gltfData*> gltfData::dataList;
|
|||
idHashIndex gltfData::fileDataHash;
|
||||
gltfItemArray* gltfItem_Extra::items = new gltfItemArray();
|
||||
|
||||
idCVar gltf_parseVerbose( "gltf_parseVerbose", "0", CVAR_RENDERER | CVAR_ARCHIVE | CVAR_BOOL, "print gltf json data while parsing" );
|
||||
|
||||
//Helper macros for gltf data deserialize
|
||||
//NOTE: gltfItems that deviate from the default SET(T*) function cannot be handled with itemref macro.
|
||||
// target must be an gltfArrayItem.
|
||||
|
@ -416,7 +415,7 @@ void gltfItem_Extra::parse( idToken& token )
|
|||
parser->UnreadToken( &token );
|
||||
parser->ParseBracedSectionExact( item->json );
|
||||
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( item->json, item->json.Size( ), "gltfItem_Extra", 0 );
|
||||
items->Fill( &lexer, &item->strPairs );
|
||||
lexer.Reset();
|
||||
|
@ -446,7 +445,7 @@ void gltfItem_animation_sampler::parse( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfAnimation_Sampler", 0 );
|
||||
|
||||
item->AssureSizeAlloc( item->Num( ) + 1, idListNewElement<gltfAnimation_Sampler> );
|
||||
|
@ -503,7 +502,7 @@ void gltfItem_animation_channel::parse( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfAnimation_Channel", 0 );
|
||||
|
||||
|
||||
|
@ -538,7 +537,7 @@ void gltfItem_mesh_primitive::parse( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfItem_mesh_primitiveB", 0 );
|
||||
|
||||
|
||||
|
@ -1021,7 +1020,7 @@ void gltfItem_KHR_lights_punctual::parse( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfNode_light", 0 );
|
||||
|
||||
item->KHR_lights_punctual.AssureSizeAlloc(
|
||||
|
@ -1137,7 +1136,7 @@ void GLTF_Parser::Parse_SCENES( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfScene", 0 );
|
||||
|
||||
gltfScene* gltfscene = currentAsset->Scene();
|
||||
|
@ -1167,7 +1166,7 @@ void GLTF_Parser::Parse_CAMERAS( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfCamera", 0 );
|
||||
|
||||
gltfCamera* item = currentAsset->Camera( );
|
||||
|
@ -1208,7 +1207,7 @@ void GLTF_Parser::Parse_NODES( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfNode", 0 );
|
||||
|
||||
gltfNode* gltfnode = currentAsset->Node( );
|
||||
|
@ -1253,7 +1252,7 @@ void GLTF_Parser::Parse_MATERIALS( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfMaterial", 0 );
|
||||
|
||||
gltfMaterial* gltfmaterial = currentAsset->Material( );
|
||||
|
@ -1292,7 +1291,7 @@ void GLTF_Parser::Parse_MESHES( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfMesh", 0 );
|
||||
|
||||
gltfMesh* gltfmesh = currentAsset->Mesh( );
|
||||
|
@ -1322,7 +1321,7 @@ void GLTF_Parser::Parse_TEXTURES( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfTexture", 0 );
|
||||
|
||||
gltfTexture* gltftexture = currentAsset->Texture( );
|
||||
|
@ -1362,7 +1361,7 @@ void GLTF_Parser::Parse_IMAGES( idToken& token )
|
|||
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str(), prop.item.Size(), "gltfImage", 0 );
|
||||
|
||||
gltfImage* image = currentAsset->Image();
|
||||
|
@ -1403,7 +1402,7 @@ void GLTF_Parser::Parse_ACCESSORS( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfAccessor", 0 );
|
||||
|
||||
gltfAccessor* item = currentAsset->Accessor();
|
||||
|
@ -1445,7 +1444,7 @@ void GLTF_Parser::Parse_BUFFERVIEWS( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfBufferView", 0 );
|
||||
|
||||
gltfBufferView* gltfBV = currentAsset->BufferView();
|
||||
|
@ -1481,7 +1480,7 @@ void GLTF_Parser::Parse_SAMPLERS( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfSampler", 0 );
|
||||
|
||||
gltfSampler* gltfSampl = currentAsset->Sampler();
|
||||
|
@ -1513,7 +1512,7 @@ void GLTF_Parser::Parse_BUFFERS( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfBuffer", 0 );
|
||||
|
||||
gltfBuffer* gltfBuf = currentAsset->Buffer( );
|
||||
|
@ -1544,7 +1543,7 @@ void GLTF_Parser::Parse_ANIMATIONS( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfAnimation", 0 );
|
||||
|
||||
gltfAnimation* gltfanim = currentAsset->Animation( );
|
||||
|
@ -1578,7 +1577,7 @@ void GLTF_Parser::Parse_SKINS( idToken& token )
|
|||
gltfPropertyArray array = gltfPropertyArray( &parser );
|
||||
for( auto& prop : array )
|
||||
{
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( prop.item.c_str( ), prop.item.Size( ), "gltfSkin", 0 );
|
||||
|
||||
gltfSkin* gltfSkin = currentAsset->Skin( );
|
||||
|
@ -1607,7 +1606,7 @@ void GLTF_Parser::Parse_EXTENSIONS( idToken& token )
|
|||
//GLTFARRAYITEM( extensions, KHR_materials_pbrSpecularGlossiness, gltfItem_KHR_materials_pbrSpecularGlossiness );
|
||||
GLTFARRAYITEM( extensions, KHR_lights_punctual, gltfItem_KHR_lights_punctual );
|
||||
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS | LEXFL_ALLOWPATHNAMES );
|
||||
idLexer lexer( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( json.c_str( ), json.Size( ), "Extensions", 0 );
|
||||
gltfExtensions* gltfextension = currentAsset->Extensions();
|
||||
//KHR_materials_pbrSpecularGlossiness->Set( &gltfextensions, &lexer );
|
||||
|
@ -1923,7 +1922,7 @@ bool GLTF_Parser::loadGLB( idStr filename )
|
|||
length -= read;
|
||||
if( chunk_type == gltfChunk_Type_JSON )
|
||||
{
|
||||
currentFile = filename + "[JSON CHUNK]";
|
||||
currentFile = filename ;
|
||||
parser.LoadMemory( ( const char* )data, chunk_length, "gltfJson", 0 );
|
||||
}
|
||||
else if( !chunkCount )
|
||||
|
|
|
@ -283,6 +283,7 @@ public:
|
|||
|
||||
//current/last loaded gltf asset and index offsets
|
||||
gltfData* currentAsset;
|
||||
idStr currentFile;
|
||||
private:
|
||||
void SetNodeParent( gltfNode* node, gltfNode* parent = nullptr );
|
||||
//void CreateBgfxData( );
|
||||
|
@ -312,7 +313,6 @@ private:
|
|||
|
||||
idLexer parser;
|
||||
idToken token;
|
||||
idStr currentFile;
|
||||
|
||||
bool buffersDone;
|
||||
bool bufferViewsDone;
|
||||
|
|
|
@ -813,6 +813,66 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
gltfNode *GetNode(gltfScene * scene ,gltfMesh * mesh) {
|
||||
assert( scene );
|
||||
assert( mesh );
|
||||
|
||||
auto & nodeList = scene->nodes;
|
||||
for ( auto & nodeId : nodeList )
|
||||
{
|
||||
if ( nodes[nodeId]->mesh != -1 && *&meshes[nodes[nodeId]->mesh] == mesh ) {
|
||||
return nodes[nodeId];
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gltfNode *GetNode(idStr sceneName, idStr name ) {
|
||||
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 == name ) {
|
||||
return nodes[nodeId];
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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) )
|
||||
|
@ -966,8 +1026,8 @@ private:
|
|||
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;
|
||||
|
|
|
@ -346,8 +346,8 @@ idRenderModel* idRenderModelManagerLocal::GetModel( const char* _modelName, bool
|
|||
{
|
||||
model = new( TAG_MODEL ) idRenderModelGLTF;
|
||||
|
||||
// RB: Collada DAE and Wavefront OBJ
|
||||
}
|
||||
// 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 ) )
|
||||
|
|
|
@ -5,15 +5,18 @@
|
|||
|
||||
#include "Model_gltf.h"
|
||||
#include "Model_local.h"
|
||||
#include "RenderCommon.h"
|
||||
|
||||
#define GLTF_YUP 1
|
||||
|
||||
idCVar gltf_ForceBspMeshTexture( "gltf_ForceBspMeshTexture", "0", CVAR_SYSTEM | CVAR_BOOL, "all world geometry has the same forced texture" );
|
||||
|
||||
bool idRenderModelStatic::ConvertGltfMeshToModelsurfaces( const gltfMesh* mesh )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* prim, gltfData* _data )
|
||||
MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* prim, gltfData* _data , idMat4 trans )
|
||||
{
|
||||
MapPolygonMesh* mesh = new MapPolygonMesh();
|
||||
gltfAccessor* accessor = _data->AccessorList( )[prim->indices];
|
||||
|
@ -46,7 +49,7 @@ MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* p
|
|||
{
|
||||
MapPolygon& polygon = mesh->polygons.Alloc();
|
||||
|
||||
if( mat != NULL )
|
||||
if( mat != NULL && !gltf_ForceBspMeshTexture.GetBool() )
|
||||
{
|
||||
polygon.SetMaterial( mat->name );
|
||||
}
|
||||
|
@ -91,6 +94,8 @@ MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* p
|
|||
bin.Read( ( void* )( &pos.y ), attrAcc->typeSize );
|
||||
bin.Read( ( void* )( &pos.z ), attrAcc->typeSize );
|
||||
|
||||
pos *= trans;
|
||||
|
||||
#if GLTF_YUP
|
||||
// RB: proper glTF2 convention, requires Y-up export option ticked on in Blender
|
||||
mesh->verts[i].xyz.x = pos.z;
|
||||
|
@ -226,6 +231,63 @@ MapPolygonMesh* MapPolygonMesh::ConvertFromMeshGltf( const gltfMesh_Primitive* p
|
|||
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;
|
||||
#if GLTF_YUP
|
||||
// RB: proper glTF2 convention, requires Y-up export option ticked on in Blender
|
||||
origin.x = node->translation.z;
|
||||
origin.y = node->translation.x;
|
||||
origin.z = node->translation.y;
|
||||
#else
|
||||
origin.x = node->translation.x;
|
||||
origin.y = node->translation.y;
|
||||
origin.z = node->translation.z;
|
||||
#endif
|
||||
|
||||
newEntity->epairs.Set( "origin", origin.ToString() );
|
||||
}
|
||||
|
||||
int idMapEntity::GetEntities( gltfData* data, EntityListRef entities, int sceneID )
|
||||
{
|
||||
idMapEntity* worldspawn = new( TAG_IDLIB_GLTF ) idMapEntity();
|
||||
|
@ -237,8 +299,9 @@ int idMapEntity::GetEntities( gltfData* data, EntityListRef entities, int sceneI
|
|||
for( auto& nodeID : data->SceneList()[sceneID]->nodes )
|
||||
{
|
||||
auto* node = data->NodeList()[nodeID];
|
||||
const char* classname = node->extras.strPairs.GetString( "classname" );
|
||||
|
||||
bool isWorldSpawn = idStr::Icmp( node->extras.strPairs.GetString( "classname" ), "worldspawn" ) == 0;
|
||||
bool isWorldSpawn = idStr::Icmp( classname, "worldspawn" ) == 0;
|
||||
if( isWorldSpawn )
|
||||
{
|
||||
assert( !wpSet );
|
||||
|
@ -252,49 +315,15 @@ int idMapEntity::GetEntities( gltfData* data, EntityListRef entities, int sceneI
|
|||
{
|
||||
for( auto prim : data->MeshList()[node->mesh]->primitives )
|
||||
{
|
||||
worldspawn->AddPrimitive( MapPolygonMesh::ConvertFromMeshGltf( prim, data ) );
|
||||
worldspawn->AddPrimitive( MapPolygonMesh::ConvertFromMeshGltf( prim, data , mat4_identity ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
idMapEntity* newEntity = new( TAG_IDLIB_GLTF ) idMapEntity();
|
||||
entities.Append( newEntity );
|
||||
|
||||
// set name and retrieve epairs from node extras
|
||||
if( node->name.Length() )
|
||||
{
|
||||
newEntity->epairs.Set( "name", node->name );
|
||||
}
|
||||
newEntity->epairs.Copy( node->extras.strPairs );
|
||||
|
||||
#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
|
||||
|
||||
//data->ResolveNodeMatrix( node );
|
||||
|
||||
idVec3 origin;
|
||||
|
||||
#if GLTF_YUP
|
||||
// RB: proper glTF2 convention, requires Y-up export option ticked on in Blender
|
||||
origin.x = node->translation.z;
|
||||
origin.y = node->translation.x;
|
||||
origin.z = node->translation.y;
|
||||
#else
|
||||
origin.x = node->translation.x;
|
||||
origin.y = node->translation.y;
|
||||
origin.z = node->translation.z;
|
||||
#endif
|
||||
|
||||
newEntity->epairs.Set( "origin", origin.ToString() );
|
||||
|
||||
//common->Printf( " %s \n ", node->name.c_str( ) );
|
||||
ProcessSceneNode( newEntity, node, mat4_identity, data );
|
||||
|
||||
entityCount++;
|
||||
}
|
||||
|
@ -304,59 +333,143 @@ int idMapEntity::GetEntities( gltfData* data, EntityListRef entities, int sceneI
|
|||
return entityCount;
|
||||
}
|
||||
|
||||
|
||||
// not dots allowed in [%s]!
|
||||
// [filename].[%i|%s].[gltf/glb]
|
||||
bool gltfManager::ExtractMeshIdentifier( idStr& filename, int& meshId, idStr& meshName )
|
||||
{
|
||||
|
||||
idStr extension;
|
||||
idStr meshStr;
|
||||
filename.ExtractFileExtension( extension );
|
||||
idStr file = filename.Left( filename.Length() - extension.Length() - 1 );
|
||||
file.ExtractFileExtension( meshStr );
|
||||
filename = file.Left( file.Length() - meshStr.Length() - 1 ) + "." + extension;
|
||||
|
||||
idStr idPart = filename.Left( filename.Length() - extension.Length() - 1 );
|
||||
idStr id;
|
||||
idPart.ExtractFileExtension( id );
|
||||
|
||||
if( !id.Length() )
|
||||
if( !extension.Length() )
|
||||
{
|
||||
idLib::Warning( "no gltf mesh identifier" );
|
||||
return false;
|
||||
}
|
||||
|
||||
filename = idPart.Left( idPart.Length() - id.Length() ) + extension;
|
||||
|
||||
idLexer lexer( LEXFL_ALLOWMULTICHARLITERALS | LEXFL_NOSTRINGESCAPECHARS );
|
||||
lexer.LoadMemory( id.c_str( ), id.Size( ), "GltfmeshID", 0 );
|
||||
idParser parser( LEXFL_ALLOWPATHNAMES | LEXFL_NOSTRINGESCAPECHARS );
|
||||
parser.LoadMemory( meshStr.c_str( ), meshStr.Size( ), "model:GltfmeshID" );
|
||||
|
||||
idToken token;
|
||||
if( lexer.ExpectAnyToken( &token ) )
|
||||
if( parser.ExpectAnyToken( &token ) )
|
||||
{
|
||||
if( lexer.EndOfFile() && ( token.type == TT_NUMBER ) && ( token.subtype & TT_INTEGER ) )
|
||||
if( ( token.type == TT_NUMBER ) && ( token.subtype & TT_INTEGER ) )
|
||||
{
|
||||
meshId = token.GetIntValue();
|
||||
}
|
||||
else if( token.type == TT_NUMBER || token.type == TT_STRING )
|
||||
else if( token.type == TT_NAME )
|
||||
{
|
||||
meshName = id;
|
||||
meshName = token;
|
||||
}
|
||||
else
|
||||
{
|
||||
lexer.Warning( "malformed gltf mesh identifier" );
|
||||
parser.Warning( "malformed gltf mesh identifier" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lexer.Warning( "malformed gltf mesh identifier" );
|
||||
parser.Warning( "malformed gltf mesh identifier" );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::ProcessNode( gltfNode * modelNode, idMat4 trans, gltfData * data )
|
||||
{
|
||||
auto& meshList = data->MeshList();
|
||||
auto& nodeList = data->NodeList( );
|
||||
|
||||
gltfData::ResolveNodeMatrix( modelNode );
|
||||
idMat4 curTrans = trans * modelNode->matrix;
|
||||
|
||||
gltfMesh *targetMesh = meshList[modelNode->mesh];
|
||||
|
||||
for ( auto prim : targetMesh->primitives ) {
|
||||
|
||||
auto *newMesh = MapPolygonMesh::ConvertFromMeshGltf( prim, data, curTrans );
|
||||
modelSurface_t surf;
|
||||
|
||||
gltfMaterial *mat = NULL;
|
||||
if ( prim->material != -1 ) {
|
||||
mat = data->MaterialList( )[prim->material];
|
||||
}
|
||||
if ( mat != NULL && !gltf_ForceBspMeshTexture.GetBool( ) ) {
|
||||
surf.shader = declManager->FindMaterial( mat->name );
|
||||
} else {
|
||||
surf.shader = declManager->FindMaterial( "textures/base_wall/snpanel2rust" );
|
||||
}
|
||||
surf.id = this->NumSurfaces( );
|
||||
|
||||
srfTriangles_t *tri = R_AllocStaticTriSurf( );
|
||||
tri->numIndexes = newMesh->GetNumPolygons( ) * 3;
|
||||
tri->numVerts = newMesh->GetNumVertices( );
|
||||
|
||||
R_AllocStaticTriSurfIndexes( tri, tri->numIndexes );
|
||||
R_AllocStaticTriSurfVerts( tri, tri->numVerts );
|
||||
|
||||
int indx = 0;
|
||||
for ( int i = 0; i < newMesh->GetNumPolygons( ); i++ ) {
|
||||
auto &face = newMesh->GetFace( i );
|
||||
auto &faceIdxs = face.GetIndexes( );
|
||||
tri->indexes[indx] = faceIdxs[0];
|
||||
tri->indexes[indx + 1] = faceIdxs[1];
|
||||
tri->indexes[indx + 2] = faceIdxs[2];
|
||||
indx += 3;
|
||||
}
|
||||
|
||||
for ( int i = 0; i < tri->numVerts; ++i ) {
|
||||
tri->verts[i] = newMesh->GetDrawVerts( )[i];
|
||||
tri->bounds.AddPoint( tri->verts[i].xyz );
|
||||
}
|
||||
|
||||
bounds.AddBounds( tri->bounds );
|
||||
|
||||
surf.geometry = tri;
|
||||
AddSurface( surf );
|
||||
}
|
||||
|
||||
for ( auto &child : modelNode->children ) {
|
||||
ProcessNode( nodeList[child], curTrans, data );
|
||||
}
|
||||
}
|
||||
|
||||
//constructs a renderModel from a gltfScene node found in the "models" scene of the given gltfFile.
|
||||
// warning : nodeName cannot have dots!
|
||||
//[fileName].[nodeName/nodeId].[gltf/glb]
|
||||
void idRenderModelGLTF::InitFromFile( const char* fileName )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
int meshID = -1;
|
||||
idStr meshName;
|
||||
idStr gltfFileName = idStr( fileName );
|
||||
gltfManager::ExtractMeshIdentifier( gltfFileName, meshID, meshName );
|
||||
|
||||
if( gltfParser->currentFile.Length( ) )
|
||||
{
|
||||
if( gltfParser->currentAsset && gltfParser->currentFile != gltfFileName )
|
||||
{
|
||||
common->FatalError( "multiple GLTF file loading not supported" );
|
||||
}
|
||||
gltfParser->Load( gltfFileName );
|
||||
}
|
||||
|
||||
timeStamp = fileSystem->GetTimestamp( gltfFileName );
|
||||
gltfData* data = gltfParser->currentAsset;
|
||||
|
||||
bounds.Clear( );
|
||||
|
||||
gltfNode * modelNode = data->GetNode("models",meshName);\
|
||||
if ( modelNode )
|
||||
ProcessNode(modelNode,mat4_identity,data);
|
||||
else
|
||||
common->Warning(" gltfNode %s not found in models scene" );
|
||||
|
||||
//skin
|
||||
//gltfNode * modelNode = data->GetNode(data->SceneList()[data->GetSceneId("models")],targetMesh);
|
||||
//__debugbreak();
|
||||
}
|
||||
|
||||
bool idRenderModelGLTF::LoadBinaryModel( idFile* file, const ID_TIME_T sourceTimeStamp )
|
||||
|
@ -367,33 +480,12 @@ bool idRenderModelGLTF::LoadBinaryModel( idFile* file, const ID_TIME_T sourceTim
|
|||
|
||||
void idRenderModelGLTF::WriteBinaryModel( idFile* file, ID_TIME_T* _timeStamp /*= NULL */ ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
bool idRenderModelGLTF::SupportsBinaryModel( )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return false;
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::ExportOBJ( idFile* objFile, idFile* mtlFile, ID_TIME_T* _timeStamp /*= NULL */ )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::PartialInitFromFile( const char* fileName )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
common->Warning( "idRenderModelGLTF::WriteBinaryModel is not implemented." );
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::PurgeModel( )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::Reset( )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
common->Warning( "idRenderModelGLTF::PurgeModel is not implemented." );
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::LoadModel( )
|
||||
|
@ -401,23 +493,6 @@ void idRenderModelGLTF::LoadModel( )
|
|||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
bool idRenderModelGLTF::IsLoaded( )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return false;
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::SetLevelLoadReferenced( bool referenced )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
bool idRenderModelGLTF::IsLevelLoadReferenced( )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return false;
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::TouchData( )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
|
@ -430,32 +505,6 @@ void idRenderModelGLTF::CreateBuffers()
|
|||
}
|
||||
*/
|
||||
|
||||
void idRenderModelGLTF::InitEmpty( const char* name )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::AddSurface( modelSurface_t surface )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::FinishSurfaces( bool useMikktspace )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::FreeVertexCache( )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
const char* idRenderModelGLTF::Name( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return "";
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::Print( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
|
@ -472,63 +521,9 @@ int idRenderModelGLTF::Memory( ) const
|
|||
return -1;
|
||||
}
|
||||
|
||||
ID_TIME_T idRenderModelGLTF::Timestamp( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return FILE_NOT_FOUND_TIMESTAMP;
|
||||
}
|
||||
|
||||
int idRenderModelGLTF::NumSurfaces( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return -1;
|
||||
}
|
||||
|
||||
int idRenderModelGLTF::NumBaseSurfaces( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return -1;
|
||||
}
|
||||
|
||||
const modelSurface_t* idRenderModelGLTF::Surface( int surfaceNum ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
srfTriangles_t* idRenderModelGLTF::AllocSurfaceTriangles( int numVerts, int numIndexes ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::FreeSurfaceTriangles( srfTriangles_t* tris ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
bool idRenderModelGLTF::IsStaticWorldModel( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return false;
|
||||
}
|
||||
|
||||
dynamicModel_t idRenderModelGLTF::IsDynamicModel( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return dynamicModel_t();
|
||||
}
|
||||
|
||||
bool idRenderModelGLTF::IsDefaultModel( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return false;
|
||||
}
|
||||
|
||||
bool idRenderModelGLTF::IsReloadable( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return false;
|
||||
return DM_STATIC;
|
||||
}
|
||||
|
||||
idRenderModel* idRenderModelGLTF::InstantiateDynamicModel( const struct renderEntity_s* ent, const viewDef_t* view, idRenderModel* cachedModel )
|
||||
|
@ -575,40 +570,5 @@ int idRenderModelGLTF::NearestJoint( int surfaceNum, int a, int b, int c ) const
|
|||
|
||||
idBounds idRenderModelGLTF::Bounds( const struct renderEntity_s* ent ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return idBounds();
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::ReadFromDemoFile( class idDemoFile* f )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
void idRenderModelGLTF::WriteToDemoFile( class idDemoFile* f )
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
}
|
||||
|
||||
float idRenderModelGLTF::DepthHack( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
bool idRenderModelGLTF::ModelHasDrawingSurfaces( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return false;
|
||||
}
|
||||
|
||||
bool idRenderModelGLTF::ModelHasInteractingSurfaces( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return false;
|
||||
}
|
||||
|
||||
bool idRenderModelGLTF::ModelHasShadowCastingSurfaces( ) const
|
||||
{
|
||||
common->Warning( "The method or operation is not implemented." );
|
||||
return false;
|
||||
return bounds;
|
||||
}
|
|
@ -20,50 +20,28 @@ private:
|
|||
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 false;
|
||||
}
|
||||
private:
|
||||
void ProcessNode( gltfNode * modelNode, idMat4 trans, gltfData * data );
|
||||
};
|
Loading…
Reference in a new issue