Ahh load object, that would be a good idea now wouldn' it!
DARKSDK_DLL void Load ( SDK_LPSTR szFilename, int iID )
{
// Uses actual or virtual file..
char VirtualFilename[_MAX_PATH];
strcpy(VirtualFilename, (LPSTR)szFilename);
g_pGlob->UpdateFilenameFromVirtualTable( (DWORD)VirtualFilename);
// Decrypt and use media, re-encrypt
g_pGlob->Decrypt( (DWORD)VirtualFilename );
LoadCore ( (SDK_LPSTR)VirtualFilename, iID, 0, 0 );
g_pGlob->Encrypt( (DWORD)VirtualFilename );
}
DARKSDK_DLL void Load ( SDK_LPSTR szFilename, int iID, int iDBProMode )
{
// Uses actual or virtual file..
char VirtualFilename[_MAX_PATH];
strcpy(VirtualFilename, (LPSTR)szFilename);
g_pGlob->UpdateFilenameFromVirtualTable( (DWORD)VirtualFilename);
// Decrypt and use media, re-encrypt
g_pGlob->Decrypt( (DWORD)VirtualFilename );
LoadCore ( (SDK_LPSTR)VirtualFilename, iID, iDBProMode, 0 );
g_pGlob->Encrypt( (DWORD)VirtualFilename );
}
DARKSDK_DLL void Load ( SDK_LPSTR szFilename, int iID, int iDBProMode, int iDivideTextureSize )
{
// Uses actual or virtual file..
char VirtualFilename[_MAX_PATH];
strcpy(VirtualFilename, (LPSTR)szFilename);
g_pGlob->UpdateFilenameFromVirtualTable( (DWORD)VirtualFilename);
// Decrypt and use media, re-encrypt
g_pGlob->Decrypt( (DWORD)VirtualFilename );
LoadCore ( (SDK_LPSTR)VirtualFilename, iID, iDBProMode, iDivideTextureSize );
g_pGlob->Encrypt( (DWORD)VirtualFilename );
}
Yes, that is the load object section; here are the calling compiler commands:
#ifdef DARKSDK_COMPILE
void dbLoadObject ( char* szFilename, int iID )
{
Load ( ( DWORD ) szFilename, iID );
}
void dbLoadObject ( char* szFilename, int iID, int iDBProMode )
{
Load ( ( DWORD ) szFilename, iID, iDBProMode );
}
// mike - 181206 - expose full load object function for GDK
void dbLoadObject ( char* szFilename, int iID, int iDBProMode, int iDivideTextureSize )
{
Load ( ( DWORD ) szFilename, iID, iDBProMode, iDivideTextureSize );
}
And last by no means least, an additional, further command calling additional, further commands for the load object procedure:
DARKSDK_DLL void LoadCore ( SDK_LPSTR szFilename, int iID, int iDBProMode, int iDivideTextureSize )
{
// ensure the object is okay to use
ConfirmNewObject ( iID );
// check memory allocation
ID_ALLOCATION ( iID );
// load the object
if ( !LoadDBO ( (LPSTR)szFilename, &g_ObjectList [ iID ] ) )
return;
// setup new object and introduce to buffers
if ( !SetNewObjectFinalProperties ( iID, -1.0f ) )
return;
if ( g_ObjectList [ iID ]->iMeshCount == 0 )
return;
// add object id to shortlist
AddObjectToObjectListRef ( iID );
// calculate path from filename
char szPath [ MAX_PATH ];
if ( _strnicmp ( (char*)szFilename+strlen((char*)szFilename)-4, ".mdl", 4 )==NULL )
{
// MDL models store their textures in the temp folder
DBOCalculateLoaderTempFolder();
strcpy ( szPath, g_WindowsTempDirectory );
}
else
{
// Path is current model location
strcpy( szPath, "" );
LPSTR pFile = (LPSTR)szFilename;
DWORD dwLength = strlen(pFile);
for ( int n=dwLength; n>0; n-- )
{
if ( pFile[n]=='\\' || pFile[n]=='/' )
{
strcpy ( szPath, pFile );
szPath[n+1]=0;
break;
}
}
}
// prepare textures for all meshes (load them)
sObject* pObject = g_ObjectList [ iID ];
for ( int iMesh = 0; iMesh < pObject->iMeshCount; iMesh++ )
LoadInternalTextures ( pObject->ppMeshList [ iMesh ], szPath, iDBProMode, iDivideTextureSize );
// 250704 - prepare effects for all meshes (load them)
for ( int iMesh = 0; iMesh < pObject->iMeshCount; iMesh++ )
{
// get mesh ptr
sMesh* pMesh = pObject->ppMeshList [ iMesh ];
if ( pMesh->bUseVertexShader )
{
// Search if effect already loaded (else create a new)
CreateNewOrSharedEffect ( pMesh, true );
}
}
}
Good luck.
Nah seriously, there has got to be a better way. Ideally a way which completely seperates the 3D resources from the loading screen.
If nothing can be invented, perhaps loading into memblocks on the other thread then running Make Object From Memblock on the main thread would be plan B.