add `AI_CONFIG_IMPORT_MD3_LOAD_SHADERS` bool option

the purpose is use of this loader with idtech3 FS
this requires full original material name, which euqals to Q3 shader path
result of deduction is not usable inside Q3 FS at all
option in general is "do not tinker with the path"
pull/3847/head
Garux 2021-05-01 00:27:28 +03:00
parent 55abc49d6d
commit eab1c9c3c0
3 changed files with 26 additions and 4 deletions

View File

@ -450,6 +450,9 @@ void MD3Importer::SetupProperties(const Importer *pImp) {
// AI_CONFIG_IMPORT_MD3_SKIN_NAME
configSkinFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SKIN_NAME, "default"));
// AI_CONFIG_IMPORT_MD3_LOAD_SHADERS
configLoadShaders = (pImp->GetPropertyBool(AI_CONFIG_IMPORT_MD3_LOAD_SHADERS, true));
// AI_CONFIG_IMPORT_MD3_SHADER_SRC
configShaderFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SHADER_SRC, ""));
@ -781,7 +784,9 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// And check whether we can locate a shader file for this model
Q3Shader::ShaderData shaders;
ReadShader(shaders);
if (configLoadShaders){
ReadShader(shaders);
}
// Adjust all texture paths in the shader
const char *header_name = pcHeader->NAME;
@ -863,7 +868,12 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
std::string convertedPath;
if (texture_name) {
ConvertPath(texture_name, header_name, convertedPath);
if (configLoadShaders){
ConvertPath(texture_name, header_name, convertedPath);
}
else{
convertedPath = texture_name;
}
}
const Q3Shader::ShaderDataBlock *shader = nullptr;

View File

@ -297,6 +297,9 @@ protected:
/** Configuration option: name of skin file to be read */
std::string configSkinFile;
/** Configuration option: whether to load shaders */
bool configLoadShaders;
/** Configuration option: name or path of shader */
std::string configShaderFile;

View File

@ -669,7 +669,7 @@ enum aiComponent
// ---------------------------------------------------------------------------
/** @brief Set wether the importer shall not remove empty bones.
*
*
* Empty bone are often used to define connections for other models.
*/
#define AI_CONFIG_IMPORT_REMOVE_EMPTY_BONES \
@ -854,6 +854,15 @@ enum aiComponent
#define AI_CONFIG_IMPORT_MD3_SKIN_NAME \
"IMPORT_MD3_SKIN_NAME"
// ---------------------------------------------------------------------------
/** @brief Specify if to try load Quake 3 shader files. This also controls
* original surface name handling: when disabled it will be used unchanged.
*
* Property type: bool. Default value: true.
*/
#define AI_CONFIG_IMPORT_MD3_LOAD_SHADERS \
"IMPORT_MD3_LOAD_SHADERS"
// ---------------------------------------------------------------------------
/** @brief Specify the Quake 3 shader file to be used for a particular
* MD3 file. This can also be a search path.
@ -1058,7 +1067,7 @@ enum aiComponent
#define AI_CONFIG_EXPORT_XFILE_64BIT "EXPORT_XFILE_64BIT"
/** @brief Specifies whether the assimp export shall be able to export point clouds
*
*
* When this flag is not defined the render data has to contain valid faces.
* Point clouds are only a collection of vertices which have nor spatial organization
* by a face and the validation process will remove them. Enabling this feature will