Merge branch 'master' into cached_output_directory_vars
commit
f675aaa871
|
@ -196,11 +196,11 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
|
||||||
// 'cull' specifies culling behaviour for the model
|
// 'cull' specifies culling behaviour for the model
|
||||||
else if (TokenMatchI(buff, "cull", 4)) {
|
else if (TokenMatchI(buff, "cull", 4)) {
|
||||||
SkipSpaces(&buff);
|
SkipSpaces(&buff);
|
||||||
if (!ASSIMP_strincmp(buff, "back", 4)) {
|
if (!ASSIMP_strincmp(buff, "back", 4)) { // render face's backside, does not function in Q3 engine (bug)
|
||||||
curData->cull = Q3Shader::CULL_CCW;
|
curData->cull = Q3Shader::CULL_CCW;
|
||||||
} else if (!ASSIMP_strincmp(buff, "front", 5)) {
|
} else if (!ASSIMP_strincmp(buff, "front", 5)) { // is not valid keyword in Q3, but occurs in shaders
|
||||||
curData->cull = Q3Shader::CULL_CW;
|
curData->cull = Q3Shader::CULL_CW;
|
||||||
} else if (!ASSIMP_strincmp(buff, "none", 4) || !ASSIMP_strincmp(buff, "disable", 7)) {
|
} else if (!ASSIMP_strincmp(buff, "none", 4) || !ASSIMP_strincmp(buff, "twosided", 8) || !ASSIMP_strincmp(buff, "disable", 7)) {
|
||||||
curData->cull = Q3Shader::CULL_NONE;
|
curData->cull = Q3Shader::CULL_NONE;
|
||||||
} else {
|
} else {
|
||||||
ASSIMP_LOG_ERROR("Q3Shader: Unrecognized cull mode");
|
ASSIMP_LOG_ERROR("Q3Shader: Unrecognized cull mode");
|
||||||
|
@ -450,6 +450,9 @@ void MD3Importer::SetupProperties(const Importer *pImp) {
|
||||||
// AI_CONFIG_IMPORT_MD3_SKIN_NAME
|
// AI_CONFIG_IMPORT_MD3_SKIN_NAME
|
||||||
configSkinFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SKIN_NAME, "default"));
|
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
|
// AI_CONFIG_IMPORT_MD3_SHADER_SRC
|
||||||
configShaderFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SHADER_SRC, ""));
|
configShaderFile = (pImp->GetPropertyString(AI_CONFIG_IMPORT_MD3_SHADER_SRC, ""));
|
||||||
|
|
||||||
|
@ -483,8 +486,9 @@ void MD3Importer::ReadShader(Q3Shader::ShaderData &fill) const {
|
||||||
|
|
||||||
// If no specific dir or file is given, use our default search behaviour
|
// If no specific dir or file is given, use our default search behaviour
|
||||||
if (!configShaderFile.length()) {
|
if (!configShaderFile.length()) {
|
||||||
if (!Q3Shader::LoadShader(fill, path + "..\\..\\..\\scripts\\" + model_file + ".shader", mIOHandler)) {
|
const char sep = mIOHandler->getOsSeparator();
|
||||||
Q3Shader::LoadShader(fill, path + "..\\..\\..\\scripts\\" + filename + ".shader", mIOHandler);
|
if (!Q3Shader::LoadShader(fill, path + ".." + sep + ".." + sep + ".." + sep + "scripts" + sep + model_file + ".shader", mIOHandler)) {
|
||||||
|
Q3Shader::LoadShader(fill, path + ".." + sep + ".." + sep + ".." + sep + "scripts" + sep + filename + ".shader", mIOHandler);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the given string specifies a file, load this file.
|
// If the given string specifies a file, load this file.
|
||||||
|
@ -780,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
|
// And check whether we can locate a shader file for this model
|
||||||
Q3Shader::ShaderData shaders;
|
Q3Shader::ShaderData shaders;
|
||||||
|
if (configLoadShaders){
|
||||||
ReadShader(shaders);
|
ReadShader(shaders);
|
||||||
|
}
|
||||||
|
|
||||||
// Adjust all texture paths in the shader
|
// Adjust all texture paths in the shader
|
||||||
const char *header_name = pcHeader->NAME;
|
const char *header_name = pcHeader->NAME;
|
||||||
|
@ -862,8 +868,13 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
|
|
||||||
std::string convertedPath;
|
std::string convertedPath;
|
||||||
if (texture_name) {
|
if (texture_name) {
|
||||||
|
if (configLoadShaders){
|
||||||
ConvertPath(texture_name, header_name, convertedPath);
|
ConvertPath(texture_name, header_name, convertedPath);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
convertedPath = texture_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const Q3Shader::ShaderDataBlock *shader = nullptr;
|
const Q3Shader::ShaderDataBlock *shader = nullptr;
|
||||||
|
|
||||||
|
@ -985,8 +996,8 @@ void MD3Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
||||||
pcMesh->mTextureCoords[0][iCurrent].x = pcUVs[index].U;
|
pcMesh->mTextureCoords[0][iCurrent].x = pcUVs[index].U;
|
||||||
pcMesh->mTextureCoords[0][iCurrent].y = 1.0f - pcUVs[index].V;
|
pcMesh->mTextureCoords[0][iCurrent].y = 1.0f - pcUVs[index].V;
|
||||||
}
|
}
|
||||||
// Flip face order if necessary
|
// Flip face order normally, unless shader is backfacing
|
||||||
if (!shader || shader->cull == Q3Shader::CULL_CW) {
|
if (!(shader && shader->cull == Q3Shader::CULL_CCW)) {
|
||||||
std::swap(pcMesh->mFaces[i].mIndices[2], pcMesh->mFaces[i].mIndices[1]);
|
std::swap(pcMesh->mFaces[i].mIndices[2], pcMesh->mFaces[i].mIndices[1]);
|
||||||
}
|
}
|
||||||
++pcTriangles;
|
++pcTriangles;
|
||||||
|
|
|
@ -297,6 +297,9 @@ protected:
|
||||||
/** Configuration option: name of skin file to be read */
|
/** Configuration option: name of skin file to be read */
|
||||||
std::string configSkinFile;
|
std::string configSkinFile;
|
||||||
|
|
||||||
|
/** Configuration option: whether to load shaders */
|
||||||
|
bool configLoadShaders;
|
||||||
|
|
||||||
/** Configuration option: name or path of shader */
|
/** Configuration option: name or path of shader */
|
||||||
std::string configShaderFile;
|
std::string configShaderFile;
|
||||||
|
|
||||||
|
|
|
@ -180,8 +180,7 @@ static void UnknownChunk(StreamReaderLE * /*stream*/, const SIBChunk &chunk) {
|
||||||
// Reads a UTF-16LE string and returns it at UTF-8.
|
// Reads a UTF-16LE string and returns it at UTF-8.
|
||||||
static aiString ReadString(StreamReaderLE *stream, uint32_t numWChars) {
|
static aiString ReadString(StreamReaderLE *stream, uint32_t numWChars) {
|
||||||
if (nullptr == stream || 0 == numWChars) {
|
if (nullptr == stream || 0 == numWChars) {
|
||||||
static const aiString empty;
|
return aiString();
|
||||||
return empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate buffers (max expansion is 1 byte -> 4 bytes for UTF-8)
|
// Allocate buffers (max expansion is 1 byte -> 4 bytes for UTF-8)
|
||||||
|
|
|
@ -854,6 +854,15 @@ enum aiComponent
|
||||||
#define AI_CONFIG_IMPORT_MD3_SKIN_NAME \
|
#define AI_CONFIG_IMPORT_MD3_SKIN_NAME \
|
||||||
"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
|
/** @brief Specify the Quake 3 shader file to be used for a particular
|
||||||
* MD3 file. This can also be a search path.
|
* MD3 file. This can also be a search path.
|
||||||
|
|
Loading…
Reference in New Issue