mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Updated Assimp
Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
This commit is contained in:
parent
2d015bc426
commit
6ade6f08ce
545 changed files with 15077 additions and 8437 deletions
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "MDL/MDLLoader.h"
|
||||
#include "MDL/MDLDefaultColorMap.h"
|
||||
#include "MD2/MD2FileData.h"
|
||||
#include "MDL/HalfLife/HL1MDLLoader.h"
|
||||
|
||||
#include <assimp/qnan.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
|
|
@ -142,6 +143,18 @@ void MDLImporter::SetupProperties(const Importer* pImp)
|
|||
|
||||
// AI_CONFIG_IMPORT_MDL_COLORMAP - palette file
|
||||
configPalette = pImp->GetPropertyString(AI_CONFIG_IMPORT_MDL_COLORMAP,"colormap.lmp");
|
||||
|
||||
// Read configuration specific to MDL (Half-Life 1).
|
||||
mHL1ImportSettings.read_animations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS, true);
|
||||
if (mHL1ImportSettings.read_animations) {
|
||||
mHL1ImportSettings.read_animation_events = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATION_EVENTS, true);
|
||||
mHL1ImportSettings.read_blend_controllers = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_BLEND_CONTROLLERS, true);
|
||||
mHL1ImportSettings.read_sequence_transitions = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS, true);
|
||||
}
|
||||
mHL1ImportSettings.read_attachments = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_ATTACHMENTS, true);
|
||||
mHL1ImportSettings.read_bone_controllers = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_BONE_CONTROLLERS, true);
|
||||
mHL1ImportSettings.read_hitboxes = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_HITBOXES, true);
|
||||
mHL1ImportSettings.read_misc_global_info = pImp->GetPropertyBool(AI_CONFIG_IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO, true);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -166,83 +179,104 @@ void MDLImporter::InternReadFile( const std::string& pFile,
|
|||
}
|
||||
|
||||
// This should work for all other types of MDL files, too ...
|
||||
// the quake header is one of the smallest, afaik
|
||||
// the HL1 sequence group header is one of the smallest, afaik
|
||||
iFileSize = (unsigned int)file->FileSize();
|
||||
if( iFileSize < sizeof(MDL::Header)) {
|
||||
if( iFileSize < sizeof(MDL::HalfLife::SequenceHeader_HL1)) {
|
||||
throw DeadlyImportError( "MDL File is too small.");
|
||||
}
|
||||
|
||||
// delete the file buffer and cleanup.
|
||||
auto DeleteBufferAndCleanup = [&]() {
|
||||
if (mBuffer) {
|
||||
delete [] mBuffer;
|
||||
mBuffer = nullptr;
|
||||
}
|
||||
AI_DEBUG_INVALIDATE_PTR(pIOHandler);
|
||||
AI_DEBUG_INVALIDATE_PTR(pScene);
|
||||
};
|
||||
|
||||
try {
|
||||
// Allocate storage and copy the contents of the file to a memory buffer
|
||||
mBuffer = new unsigned char[iFileSize+1];
|
||||
file->Read( (void*)mBuffer, 1, iFileSize);
|
||||
|
||||
// Allocate storage and copy the contents of the file to a memory buffer
|
||||
mBuffer =new unsigned char[iFileSize+1];
|
||||
file->Read( (void*)mBuffer, 1, iFileSize);
|
||||
// Append a binary zero to the end of the buffer.
|
||||
// this is just for safety that string parsing routines
|
||||
// find the end of the buffer ...
|
||||
mBuffer[iFileSize] = '\0';
|
||||
const uint32_t iMagicWord = *((uint32_t*)mBuffer);
|
||||
|
||||
// Append a binary zero to the end of the buffer.
|
||||
// this is just for safety that string parsing routines
|
||||
// find the end of the buffer ...
|
||||
mBuffer[iFileSize] = '\0';
|
||||
const uint32_t iMagicWord = *((uint32_t*)mBuffer);
|
||||
// Determine the file subtype and call the appropriate member function
|
||||
|
||||
// Determine the file subtype and call the appropriate member function
|
||||
// Original Quake1 format
|
||||
if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: Quake 1, magic word is IDPO");
|
||||
iGSFileVersion = 0;
|
||||
InternReadFile_Quake1();
|
||||
}
|
||||
// GameStudio A<old> MDL2 format - used by some test models that come with 3DGS
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS3 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS3 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A2, magic word is MDL2");
|
||||
iGSFileVersion = 2;
|
||||
InternReadFile_Quake1();
|
||||
}
|
||||
// GameStudio A4 MDL3 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS4 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS4 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL3");
|
||||
iGSFileVersion = 3;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A5+ MDL4 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS5a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5a == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL4");
|
||||
iGSFileVersion = 4;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A5+ MDL5 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS5b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5b == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A5, magic word is MDL5");
|
||||
iGSFileVersion = 5;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A7 MDL7 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS7 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS7 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A7, magic word is MDL7");
|
||||
iGSFileVersion = 7;
|
||||
InternReadFile_3DGS_MDL7();
|
||||
}
|
||||
// IDST/IDSQ Format (CS:S/HL^2, etc ...)
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord ||
|
||||
AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord)
|
||||
{
|
||||
iGSFileVersion = 0;
|
||||
|
||||
// Original Quake1 format
|
||||
if (AI_MDL_MAGIC_NUMBER_BE == iMagicWord || AI_MDL_MAGIC_NUMBER_LE == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: Quake 1, magic word is IDPO");
|
||||
iGSFileVersion = 0;
|
||||
InternReadFile_Quake1();
|
||||
}
|
||||
// GameStudio A<old> MDL2 format - used by some test models that come with 3DGS
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS3 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS3 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A2, magic word is MDL2");
|
||||
iGSFileVersion = 2;
|
||||
InternReadFile_Quake1();
|
||||
}
|
||||
// GameStudio A4 MDL3 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS4 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS4 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL3");
|
||||
iGSFileVersion = 3;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A5+ MDL4 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS5a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5a == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A4, magic word is MDL4");
|
||||
iGSFileVersion = 4;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A5+ MDL5 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS5b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS5b == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A5, magic word is MDL5");
|
||||
iGSFileVersion = 5;
|
||||
InternReadFile_3DGS_MDL345();
|
||||
}
|
||||
// GameStudio A7 MDL7 format
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_GS7 == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_GS7 == iMagicWord) {
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: 3D GameStudio A7, magic word is MDL7");
|
||||
iGSFileVersion = 7;
|
||||
InternReadFile_3DGS_MDL7();
|
||||
}
|
||||
// IDST/IDSQ Format (CS:S/HL^2, etc ...)
|
||||
else if (AI_MDL_MAGIC_NUMBER_BE_HL2a == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2a == iMagicWord ||
|
||||
AI_MDL_MAGIC_NUMBER_BE_HL2b == iMagicWord || AI_MDL_MAGIC_NUMBER_LE_HL2b == iMagicWord)
|
||||
{
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: Source(tm) Engine, magic word is IDST/IDSQ");
|
||||
iGSFileVersion = 0;
|
||||
InternReadFile_HL2();
|
||||
}
|
||||
else {
|
||||
// print the magic word to the log file
|
||||
throw DeadlyImportError( "Unknown MDL subformat " + pFile +
|
||||
". Magic word (" + std::string((char*)&iMagicWord,4) + ") is not known");
|
||||
}
|
||||
HalfLife::HalfLifeMDLBaseHeader *pHeader = (HalfLife::HalfLifeMDLBaseHeader *)mBuffer;
|
||||
if (pHeader->version == AI_MDL_HL1_VERSION)
|
||||
{
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: Half-Life 1/Goldsrc Engine, magic word is IDST/IDSQ");
|
||||
InternReadFile_HL1(pFile, iMagicWord);
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSIMP_LOG_DEBUG("MDL subtype: Source(tm) Engine, magic word is IDST/IDSQ");
|
||||
InternReadFile_HL2();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// print the magic word to the log file
|
||||
throw DeadlyImportError( "Unknown MDL subformat " + pFile +
|
||||
". Magic word (" + std::string((char*)&iMagicWord,4) + ") is not known");
|
||||
}
|
||||
|
||||
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||
pScene->mRootNode->mTransformation = aiMatrix4x4(1.f,0.f,0.f,0.f,
|
||||
0.f,0.f,1.f,0.f,0.f,-1.f,0.f,0.f,0.f,0.f,0.f,1.f);
|
||||
// Now rotate the whole scene 90 degrees around the x axis to convert to internal coordinate system
|
||||
pScene->mRootNode->mTransformation = aiMatrix4x4(1.f,0.f,0.f,0.f,
|
||||
0.f,0.f,1.f,0.f,0.f,-1.f,0.f,0.f,0.f,0.f,0.f,1.f);
|
||||
|
||||
// delete the file buffer and cleanup
|
||||
delete [] mBuffer;
|
||||
mBuffer= nullptr;
|
||||
AI_DEBUG_INVALIDATE_PTR(pIOHandler);
|
||||
AI_DEBUG_INVALIDATE_PTR(pScene);
|
||||
DeleteBufferAndCleanup();
|
||||
} catch(...) {
|
||||
DeleteBufferAndCleanup();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
@ -1387,11 +1421,11 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
|||
avOutList[i].reserve(3);
|
||||
|
||||
// buffer to held the names of all groups in the file
|
||||
const size_t buffersize( AI_MDL7_MAX_GROUPNAMESIZE*pcHeader->groups_num );
|
||||
char* aszGroupNameBuffer = new char[ buffersize ];
|
||||
const size_t buffersize(AI_MDL7_MAX_GROUPNAMESIZE*pcHeader->groups_num);
|
||||
char* aszGroupNameBuffer = new char[ buffersize ];
|
||||
|
||||
// read all groups
|
||||
for (unsigned int iGroup = 0; iGroup < (unsigned int)pcHeader->groups_num;++iGroup) {
|
||||
for (unsigned int iGroup = 0; iGroup < (unsigned int)pcHeader->groups_num; ++iGroup) {
|
||||
MDL::IntGroupInfo_MDL7 groupInfo((BE_NCONST MDL::Group_MDL7*)szCurrent,iGroup);
|
||||
szCurrent = (const unsigned char*)(groupInfo.pcGroup+1);
|
||||
|
||||
|
|
@ -1552,7 +1586,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
|||
const size_t maxSize(buffersize - (i*AI_MDL7_MAX_GROUPNAMESIZE));
|
||||
pcNode->mName.length = ai_snprintf(szBuffer, maxSize, "Group_%u", p);
|
||||
} else {
|
||||
pcNode->mName.length = ::strlen(szBuffer);
|
||||
pcNode->mName.length = (ai_uint32)::strlen(szBuffer);
|
||||
}
|
||||
::strncpy(pcNode->mName.data,szBuffer,MAXLEN-1);
|
||||
++p;
|
||||
|
|
@ -1955,6 +1989,23 @@ void MDLImporter::JoinSkins_3DGS_MDL7(
|
|||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Read a Half-life 1 MDL
|
||||
void MDLImporter::InternReadFile_HL1(const std::string& pFile, const uint32_t iMagicWord)
|
||||
{
|
||||
// We can't correctly load an MDL from a MDL "sequence" file.
|
||||
if (iMagicWord == AI_MDL_MAGIC_NUMBER_BE_HL2b || iMagicWord == AI_MDL_MAGIC_NUMBER_LE_HL2b)
|
||||
throw DeadlyImportError("Impossible to properly load a model from an MDL sequence file.");
|
||||
|
||||
// Read the MDL file.
|
||||
HalfLife::HL1MDLLoader loader(
|
||||
pScene,
|
||||
pIOHandler,
|
||||
mBuffer,
|
||||
pFile,
|
||||
mHL1ImportSettings);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Read a half-life 2 MDL
|
||||
void MDLImporter::InternReadFile_HL2( )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue