Merge branch 'master' into patch-3

pull/4645/head
Kim Kulling 2022-07-18 15:19:27 +02:00 committed by GitHub
commit f07bc2c5b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 17 deletions

View File

@ -126,16 +126,20 @@ void ObjFileMtlImporter::load() {
if (*m_DataIt == 'a') // Ambient color if (*m_DataIt == 'a') // Ambient color
{ {
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getColorRGBA(&m_pModel->m_pCurrentMaterial->ambient); getColorRGBA(&m_pModel->m_pCurrentMaterial->ambient);
} else if (*m_DataIt == 'd') { } else if (*m_DataIt == 'd') {
// Diffuse color // Diffuse color
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getColorRGBA(&m_pModel->m_pCurrentMaterial->diffuse); getColorRGBA(&m_pModel->m_pCurrentMaterial->diffuse);
} else if (*m_DataIt == 's') { } else if (*m_DataIt == 's') {
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getColorRGBA(&m_pModel->m_pCurrentMaterial->specular); getColorRGBA(&m_pModel->m_pCurrentMaterial->specular);
} else if (*m_DataIt == 'e') { } else if (*m_DataIt == 'e') {
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getColorRGBA(&m_pModel->m_pCurrentMaterial->emissive); getColorRGBA(&m_pModel->m_pCurrentMaterial->emissive);
} }
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine); m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
@ -145,12 +149,14 @@ void ObjFileMtlImporter::load() {
// Material transmission color // Material transmission color
if (*m_DataIt == 'f') { if (*m_DataIt == 'f') {
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getColorRGBA(&m_pModel->m_pCurrentMaterial->transparent); getColorRGBA(&m_pModel->m_pCurrentMaterial->transparent);
} else if (*m_DataIt == 'r') { } else if (*m_DataIt == 'r') {
// Material transmission alpha value // Material transmission alpha value
++m_DataIt; ++m_DataIt;
ai_real d; ai_real d;
getFloatValue(d); getFloatValue(d);
if (m_pModel->m_pCurrentMaterial != nullptr)
m_pModel->m_pCurrentMaterial->alpha = static_cast<ai_real>(1.0) - d; m_pModel->m_pCurrentMaterial->alpha = static_cast<ai_real>(1.0) - d;
} }
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine); m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
@ -162,6 +168,7 @@ void ObjFileMtlImporter::load() {
} else { } else {
// Alpha value // Alpha value
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getFloatValue(m_pModel->m_pCurrentMaterial->alpha); getFloatValue(m_pModel->m_pCurrentMaterial->alpha);
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine); m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
} }
@ -173,10 +180,12 @@ void ObjFileMtlImporter::load() {
switch (*m_DataIt) { switch (*m_DataIt) {
case 's': // Specular exponent case 's': // Specular exponent
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getFloatValue(m_pModel->m_pCurrentMaterial->shineness); getFloatValue(m_pModel->m_pCurrentMaterial->shineness);
break; break;
case 'i': // Index Of refraction case 'i': // Index Of refraction
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getFloatValue(m_pModel->m_pCurrentMaterial->ior); getFloatValue(m_pModel->m_pCurrentMaterial->ior);
break; break;
case 'e': // New material case 'e': // New material
@ -197,22 +206,27 @@ void ObjFileMtlImporter::load() {
{ {
case 'r': case 'r':
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getFloatValue(m_pModel->m_pCurrentMaterial->roughness); getFloatValue(m_pModel->m_pCurrentMaterial->roughness);
break; break;
case 'm': case 'm':
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getFloatValue(m_pModel->m_pCurrentMaterial->metallic); getFloatValue(m_pModel->m_pCurrentMaterial->metallic);
break; break;
case 's': case 's':
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getColorRGBA(m_pModel->m_pCurrentMaterial->sheen); getColorRGBA(m_pModel->m_pCurrentMaterial->sheen);
break; break;
case 'c': case 'c':
++m_DataIt; ++m_DataIt;
if (*m_DataIt == 'r') { if (*m_DataIt == 'r') {
++m_DataIt; ++m_DataIt;
if (m_pModel->m_pCurrentMaterial != nullptr)
getFloatValue(m_pModel->m_pCurrentMaterial->clearcoat_roughness); getFloatValue(m_pModel->m_pCurrentMaterial->clearcoat_roughness);
} else { } else {
if (m_pModel->m_pCurrentMaterial != nullptr)
getFloatValue(m_pModel->m_pCurrentMaterial->clearcoat_thickness); getFloatValue(m_pModel->m_pCurrentMaterial->clearcoat_thickness);
} }
break; break;
@ -232,6 +246,7 @@ void ObjFileMtlImporter::load() {
case 'i': // Illumination model case 'i': // Illumination model
{ {
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd); m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
if (m_pModel->m_pCurrentMaterial != nullptr)
getIlluminationModel(m_pModel->m_pCurrentMaterial->illumination_model); getIlluminationModel(m_pModel->m_pCurrentMaterial->illumination_model);
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine); m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
} break; } break;
@ -240,6 +255,7 @@ void ObjFileMtlImporter::load() {
{ {
++m_DataIt; ++m_DataIt;
getFloatValue(m_pModel->m_pCurrentMaterial->anisotropy); getFloatValue(m_pModel->m_pCurrentMaterial->anisotropy);
if (m_pModel->m_pCurrentMaterial != nullptr)
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine); m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
} break; } break;

View File

@ -458,7 +458,8 @@ void ObjFileParser::getFace(aiPrimitiveType type) {
iPos = 0; iPos = 0;
} else { } else {
//OBJ USES 1 Base ARRAYS!!!! //OBJ USES 1 Base ARRAYS!!!!
const int iVal(::atoi(&(*m_DataIt))); std::string number(&(*m_DataIt), m_DataItEnd - m_DataIt);
const int iVal(::atoi(number.c_str()));
// increment iStep position based off of the sign and # of digits // increment iStep position based off of the sign and # of digits
int tmp = iVal; int tmp = iVal;