Merge commit '44773b8f9e47d9fe7e80946a1a9eb3d764fc8af2' into contrib
commit
8bbe14c052
|
@ -66,9 +66,12 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config.cmake.in" "${C
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE)
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/assimp-config-version.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" @ONLY IMMEDIATE)
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/assimp-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/assimp-config-version.cmake" DESTINATION "${ASSIMP_LIB_INSTALL_DIR}/cmake/assimp-${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}" COMPONENT ${LIBASSIMP-DEV_COMPONENT})
|
||||||
|
|
||||||
# add make uninstall capability
|
# Only generate this target if no higher-level project already has
|
||||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
IF (NOT TARGET uninstall)
|
||||||
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
# add make uninstall capability
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
||||||
|
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
# Globally enbale Boost resp. the Boost workaround – it is also needed by the
|
# Globally enbale Boost resp. the Boost workaround – it is also needed by the
|
||||||
# tools which include the Assimp headers.
|
# tools which include the Assimp headers.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
MACRO(ADD_MSVC_PRECOMPILED_HEADER PrecompiledHeader PrecompiledSource SourcesVar)
|
MACRO(ADD_MSVC_PRECOMPILED_HEADER PrecompiledHeader PrecompiledSource SourcesVar)
|
||||||
IF(MSVC)
|
IF(MSVC)
|
||||||
GET_FILENAME_COMPONENT(PrecompiledBasename ${PrecompiledHeader} NAME_WE)
|
GET_FILENAME_COMPONENT(PrecompiledBasename ${PrecompiledHeader} NAME_WE)
|
||||||
SET(PrecompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${PrecompiledBasename}.pch")
|
SET(PrecompiledBinary "${CMAKE_CFG_INTDIR}/${PrecompiledBasename}.pch")
|
||||||
SET(Sources ${${SourcesVar}})
|
SET(Sources ${${SourcesVar}})
|
||||||
|
|
||||||
SET_SOURCE_FILES_PROPERTIES(${PrecompiledSource}
|
SET_SOURCE_FILES_PROPERTIES(${PrecompiledSource}
|
||||||
|
|
|
@ -161,6 +161,19 @@ struct Material
|
||||||
aiString textureSpecularity;
|
aiString textureSpecularity;
|
||||||
aiString textureOpacity;
|
aiString textureOpacity;
|
||||||
aiString textureDisp;
|
aiString textureDisp;
|
||||||
|
enum TextureType
|
||||||
|
{
|
||||||
|
TextureDiffuseType = 0,
|
||||||
|
TextureSpecularType,
|
||||||
|
TextureAmbientType,
|
||||||
|
TextureBumpType,
|
||||||
|
TextureNormalType,
|
||||||
|
TextureSpecularityType,
|
||||||
|
TextureOpacityType,
|
||||||
|
TextureDispType,
|
||||||
|
TextureTypeCount
|
||||||
|
};
|
||||||
|
bool clamp[TextureTypeCount];
|
||||||
|
|
||||||
//! Ambient color
|
//! Ambient color
|
||||||
aiColor3D ambient;
|
aiColor3D ambient;
|
||||||
|
@ -186,6 +199,10 @@ struct Material
|
||||||
, ior (1.f)
|
, ior (1.f)
|
||||||
{
|
{
|
||||||
// empty
|
// empty
|
||||||
|
for (size_t i = 0; i < TextureTypeCount; ++i)
|
||||||
|
{
|
||||||
|
clamp[i] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
|
|
|
@ -484,6 +484,15 @@ void ObjFileImporter::countObjects(const std::vector<ObjFile::Object*> &rObjects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Add clamp mode property to material if necessary
|
||||||
|
void ObjFileImporter::addTextureMappingModeProperty(aiMaterial* mat, aiTextureType type, int clampMode)
|
||||||
|
{
|
||||||
|
ai_assert( NULL != mat);
|
||||||
|
mat->AddProperty<int>(&clampMode, 1, AI_MATKEY_MAPPINGMODE_U(type, 0));
|
||||||
|
mat->AddProperty<int>(&clampMode, 1, AI_MATKEY_MAPPINGMODE_V(type, 0));
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Creates the material
|
// Creates the material
|
||||||
void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pScene )
|
void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pScene )
|
||||||
|
@ -549,28 +558,76 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc
|
||||||
|
|
||||||
// Adding textures
|
// Adding textures
|
||||||
if ( 0 != pCurrentMaterial->texture.length )
|
if ( 0 != pCurrentMaterial->texture.length )
|
||||||
|
{
|
||||||
mat->AddProperty( &pCurrentMaterial->texture, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
mat->AddProperty( &pCurrentMaterial->texture, AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||||
|
if (pCurrentMaterial->clamp[ObjFile::Material::TextureDiffuseType])
|
||||||
|
{
|
||||||
|
addTextureMappingModeProperty(mat, aiTextureType_DIFFUSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( 0 != pCurrentMaterial->textureAmbient.length )
|
if ( 0 != pCurrentMaterial->textureAmbient.length )
|
||||||
|
{
|
||||||
mat->AddProperty( &pCurrentMaterial->textureAmbient, AI_MATKEY_TEXTURE_AMBIENT(0));
|
mat->AddProperty( &pCurrentMaterial->textureAmbient, AI_MATKEY_TEXTURE_AMBIENT(0));
|
||||||
|
if (pCurrentMaterial->clamp[ObjFile::Material::TextureAmbientType])
|
||||||
|
{
|
||||||
|
addTextureMappingModeProperty(mat, aiTextureType_AMBIENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( 0 != pCurrentMaterial->textureSpecular.length )
|
if ( 0 != pCurrentMaterial->textureSpecular.length )
|
||||||
|
{
|
||||||
mat->AddProperty( &pCurrentMaterial->textureSpecular, AI_MATKEY_TEXTURE_SPECULAR(0));
|
mat->AddProperty( &pCurrentMaterial->textureSpecular, AI_MATKEY_TEXTURE_SPECULAR(0));
|
||||||
|
if (pCurrentMaterial->clamp[ObjFile::Material::TextureSpecularType])
|
||||||
|
{
|
||||||
|
addTextureMappingModeProperty(mat, aiTextureType_SPECULAR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( 0 != pCurrentMaterial->textureBump.length )
|
if ( 0 != pCurrentMaterial->textureBump.length )
|
||||||
|
{
|
||||||
mat->AddProperty( &pCurrentMaterial->textureBump, AI_MATKEY_TEXTURE_HEIGHT(0));
|
mat->AddProperty( &pCurrentMaterial->textureBump, AI_MATKEY_TEXTURE_HEIGHT(0));
|
||||||
|
if (pCurrentMaterial->clamp[ObjFile::Material::TextureBumpType])
|
||||||
|
{
|
||||||
|
addTextureMappingModeProperty(mat, aiTextureType_HEIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( 0 != pCurrentMaterial->textureNormal.length )
|
if ( 0 != pCurrentMaterial->textureNormal.length )
|
||||||
|
{
|
||||||
mat->AddProperty( &pCurrentMaterial->textureNormal, AI_MATKEY_TEXTURE_NORMALS(0));
|
mat->AddProperty( &pCurrentMaterial->textureNormal, AI_MATKEY_TEXTURE_NORMALS(0));
|
||||||
|
if (pCurrentMaterial->clamp[ObjFile::Material::TextureNormalType])
|
||||||
|
{
|
||||||
|
addTextureMappingModeProperty(mat, aiTextureType_NORMALS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( 0 != pCurrentMaterial->textureDisp.length )
|
if ( 0 != pCurrentMaterial->textureDisp.length )
|
||||||
|
{
|
||||||
mat->AddProperty( &pCurrentMaterial->textureDisp, AI_MATKEY_TEXTURE_DISPLACEMENT(0) );
|
mat->AddProperty( &pCurrentMaterial->textureDisp, AI_MATKEY_TEXTURE_DISPLACEMENT(0) );
|
||||||
|
if (pCurrentMaterial->clamp[ObjFile::Material::TextureDispType])
|
||||||
|
{
|
||||||
|
addTextureMappingModeProperty(mat, aiTextureType_DISPLACEMENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( 0 != pCurrentMaterial->textureOpacity.length )
|
if ( 0 != pCurrentMaterial->textureOpacity.length )
|
||||||
|
{
|
||||||
mat->AddProperty( &pCurrentMaterial->textureOpacity, AI_MATKEY_TEXTURE_OPACITY(0));
|
mat->AddProperty( &pCurrentMaterial->textureOpacity, AI_MATKEY_TEXTURE_OPACITY(0));
|
||||||
|
if (pCurrentMaterial->clamp[ObjFile::Material::TextureOpacityType])
|
||||||
|
{
|
||||||
|
addTextureMappingModeProperty(mat, aiTextureType_OPACITY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( 0 != pCurrentMaterial->textureSpecularity.length )
|
if ( 0 != pCurrentMaterial->textureSpecularity.length )
|
||||||
|
{
|
||||||
mat->AddProperty( &pCurrentMaterial->textureSpecularity, AI_MATKEY_TEXTURE_SHININESS(0));
|
mat->AddProperty( &pCurrentMaterial->textureSpecularity, AI_MATKEY_TEXTURE_SHININESS(0));
|
||||||
|
if (pCurrentMaterial->clamp[ObjFile::Material::TextureSpecularityType])
|
||||||
|
{
|
||||||
|
addTextureMappingModeProperty(mat, aiTextureType_SHININESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Store material property info in material array in scene
|
// Store material property info in material array in scene
|
||||||
pScene->mMaterials[ pScene->mNumMaterials ] = mat;
|
pScene->mMaterials[ pScene->mNumMaterials ] = mat;
|
||||||
|
|
|
@ -103,6 +103,7 @@ private:
|
||||||
|
|
||||||
//! \brief Material creation.
|
//! \brief Material creation.
|
||||||
void createMaterials(const ObjFile::Model* pModel, aiScene* pScene);
|
void createMaterials(const ObjFile::Model* pModel, aiScene* pScene);
|
||||||
|
void addTextureMappingModeProperty(aiMaterial* mat, aiTextureType type, int clampMode = 1);
|
||||||
|
|
||||||
//! \brief Appends a child node to a parent node and updates the data structures.
|
//! \brief Appends a child node to a parent node and updates the data structures.
|
||||||
void appendChildToParentNode(aiNode *pParent, aiNode *pChild);
|
void appendChildToParentNode(aiNode *pParent, aiNode *pChild);
|
||||||
|
|
|
@ -61,6 +61,22 @@ static const std::string NormalTexture = "map_Kn";
|
||||||
static const std::string DisplacementTexture = "disp";
|
static const std::string DisplacementTexture = "disp";
|
||||||
static const std::string SpecularityTexture = "map_ns";
|
static const std::string SpecularityTexture = "map_ns";
|
||||||
|
|
||||||
|
// texture option specific token
|
||||||
|
static const std::string BlendUOption = "-blendu";
|
||||||
|
static const std::string BlendVOption = "-blendv";
|
||||||
|
static const std::string BoostOption = "-boost";
|
||||||
|
static const std::string ModifyMapOption = "-mm";
|
||||||
|
static const std::string OffsetOption = "-o";
|
||||||
|
static const std::string ScaleOption = "-s";
|
||||||
|
static const std::string TurbulenceOption = "-t";
|
||||||
|
static const std::string ResolutionOption = "-texres";
|
||||||
|
static const std::string ClampOption = "-clamp";
|
||||||
|
static const std::string BumpOption = "-bm";
|
||||||
|
static const std::string ChannelOption = "-imfchan";
|
||||||
|
static const std::string TypeOption = "-type";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Constructor
|
// Constructor
|
||||||
ObjFileMtlImporter::ObjFileMtlImporter( std::vector<char> &buffer,
|
ObjFileMtlImporter::ObjFileMtlImporter( std::vector<char> &buffer,
|
||||||
|
@ -263,47 +279,128 @@ void ObjFileMtlImporter::createMaterial()
|
||||||
// Gets a texture name from data.
|
// Gets a texture name from data.
|
||||||
void ObjFileMtlImporter::getTexture() {
|
void ObjFileMtlImporter::getTexture() {
|
||||||
aiString *out( NULL );
|
aiString *out( NULL );
|
||||||
|
int clampIndex = -1;
|
||||||
|
|
||||||
const char *pPtr( &(*m_DataIt) );
|
const char *pPtr( &(*m_DataIt) );
|
||||||
if ( !ASSIMP_strincmp( pPtr, DiffuseTexture.c_str(), DiffuseTexture.size() ) ) {
|
if ( !ASSIMP_strincmp( pPtr, DiffuseTexture.c_str(), DiffuseTexture.size() ) ) {
|
||||||
// Diffuse texture
|
// Diffuse texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->texture;
|
out = & m_pModel->m_pCurrentMaterial->texture;
|
||||||
|
clampIndex = ObjFile::Material::TextureDiffuseType;
|
||||||
} else if ( !ASSIMP_strincmp( pPtr,AmbientTexture.c_str(),AmbientTexture.size() ) ) {
|
} else if ( !ASSIMP_strincmp( pPtr,AmbientTexture.c_str(),AmbientTexture.size() ) ) {
|
||||||
// Ambient texture
|
// Ambient texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureAmbient;
|
out = & m_pModel->m_pCurrentMaterial->textureAmbient;
|
||||||
|
clampIndex = ObjFile::Material::TextureAmbientType;
|
||||||
} else if (!ASSIMP_strincmp( pPtr, SpecularTexture.c_str(), SpecularTexture.size())) {
|
} else if (!ASSIMP_strincmp( pPtr, SpecularTexture.c_str(), SpecularTexture.size())) {
|
||||||
// Specular texture
|
// Specular texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureSpecular;
|
out = & m_pModel->m_pCurrentMaterial->textureSpecular;
|
||||||
|
clampIndex = ObjFile::Material::TextureSpecularType;
|
||||||
} else if ( !ASSIMP_strincmp( pPtr, OpacityTexture.c_str(), OpacityTexture.size() ) ) {
|
} else if ( !ASSIMP_strincmp( pPtr, OpacityTexture.c_str(), OpacityTexture.size() ) ) {
|
||||||
// Opacity texture
|
// Opacity texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureOpacity;
|
out = & m_pModel->m_pCurrentMaterial->textureOpacity;
|
||||||
|
clampIndex = ObjFile::Material::TextureOpacityType;
|
||||||
} else if (!ASSIMP_strincmp( pPtr,"map_ka",6)) {
|
} else if (!ASSIMP_strincmp( pPtr,"map_ka",6)) {
|
||||||
// Ambient texture
|
// Ambient texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureAmbient;
|
out = & m_pModel->m_pCurrentMaterial->textureAmbient;
|
||||||
|
clampIndex = ObjFile::Material::TextureAmbientType;
|
||||||
} else if ( !ASSIMP_strincmp( pPtr, BumpTexture1.c_str(), BumpTexture1.size() ) ||
|
} else if ( !ASSIMP_strincmp( pPtr, BumpTexture1.c_str(), BumpTexture1.size() ) ||
|
||||||
!ASSIMP_strincmp( pPtr, BumpTexture2.c_str(), BumpTexture2.size() ) ||
|
!ASSIMP_strincmp( pPtr, BumpTexture2.c_str(), BumpTexture2.size() ) ||
|
||||||
!ASSIMP_strincmp( pPtr, BumpTexture3.c_str(), BumpTexture3.size() ) ) {
|
!ASSIMP_strincmp( pPtr, BumpTexture3.c_str(), BumpTexture3.size() ) ) {
|
||||||
// Bump texture
|
// Bump texture
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureBump;
|
out = & m_pModel->m_pCurrentMaterial->textureBump;
|
||||||
|
clampIndex = ObjFile::Material::TextureBumpType;
|
||||||
} else if (!ASSIMP_strincmp( pPtr,NormalTexture.c_str(), NormalTexture.size())) {
|
} else if (!ASSIMP_strincmp( pPtr,NormalTexture.c_str(), NormalTexture.size())) {
|
||||||
// Normal map
|
// Normal map
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureNormal;
|
out = & m_pModel->m_pCurrentMaterial->textureNormal;
|
||||||
|
clampIndex = ObjFile::Material::TextureNormalType;
|
||||||
} else if (!ASSIMP_strincmp( pPtr, DisplacementTexture.c_str(), DisplacementTexture.size() ) ) {
|
} else if (!ASSIMP_strincmp( pPtr, DisplacementTexture.c_str(), DisplacementTexture.size() ) ) {
|
||||||
// Displacement texture
|
// Displacement texture
|
||||||
out = &m_pModel->m_pCurrentMaterial->textureDisp;
|
out = &m_pModel->m_pCurrentMaterial->textureDisp;
|
||||||
|
clampIndex = ObjFile::Material::TextureDispType;
|
||||||
} else if (!ASSIMP_strincmp( pPtr, SpecularityTexture.c_str(),SpecularityTexture.size() ) ) {
|
} else if (!ASSIMP_strincmp( pPtr, SpecularityTexture.c_str(),SpecularityTexture.size() ) ) {
|
||||||
// Specularity scaling (glossiness)
|
// Specularity scaling (glossiness)
|
||||||
out = & m_pModel->m_pCurrentMaterial->textureSpecularity;
|
out = & m_pModel->m_pCurrentMaterial->textureSpecularity;
|
||||||
|
clampIndex = ObjFile::Material::TextureSpecularityType;
|
||||||
} else {
|
} else {
|
||||||
DefaultLogger::get()->error("OBJ/MTL: Encountered unknown texture type");
|
DefaultLogger::get()->error("OBJ/MTL: Encountered unknown texture type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool clamp = false;
|
||||||
|
getTextureOption(clamp);
|
||||||
|
m_pModel->m_pCurrentMaterial->clamp[clampIndex] = clamp;
|
||||||
|
|
||||||
std::string strTexture;
|
std::string strTexture;
|
||||||
m_DataIt = getName<DataArrayIt>( m_DataIt, m_DataItEnd, strTexture );
|
m_DataIt = getName<DataArrayIt>( m_DataIt, m_DataItEnd, strTexture );
|
||||||
out->Set( strTexture );
|
out->Set( strTexture );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* /////////////////////////////////////////////////////////////////////////////
|
||||||
|
* Texture Option
|
||||||
|
* /////////////////////////////////////////////////////////////////////////////
|
||||||
|
* According to http://en.wikipedia.org/wiki/Wavefront_.obj_file#Texture_options
|
||||||
|
* Texture map statement can contains various texture option, for example:
|
||||||
|
*
|
||||||
|
* map_Ka -o 1 1 1 some.png
|
||||||
|
* map_Kd -clamp on some.png
|
||||||
|
*
|
||||||
|
* So we need to parse and skip these options, and leave the last part which is
|
||||||
|
* the url of image, otherwise we will get a wrong url like "-clamp on some.png".
|
||||||
|
*
|
||||||
|
* Because aiMaterial supports clamp option, so we also want to return it
|
||||||
|
* /////////////////////////////////////////////////////////////////////////////
|
||||||
|
*/
|
||||||
|
void ObjFileMtlImporter::getTextureOption(bool &clamp)
|
||||||
|
{
|
||||||
|
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
||||||
|
|
||||||
|
//If there is any more texture option
|
||||||
|
while (!isEndOfBuffer(m_DataIt, m_DataItEnd) && *m_DataIt == '-')
|
||||||
|
{
|
||||||
|
const char *pPtr( &(*m_DataIt) );
|
||||||
|
//skip option key and value
|
||||||
|
int skipToken = 1;
|
||||||
|
|
||||||
|
if (!ASSIMP_strincmp(pPtr, ClampOption.c_str(), ClampOption.size()))
|
||||||
|
{
|
||||||
|
DataArrayIt it = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
||||||
|
char value[3];
|
||||||
|
CopyNextWord(it, m_DataItEnd, value, sizeof(value) / sizeof(*value));
|
||||||
|
if (!ASSIMP_strincmp(value, "on", 2))
|
||||||
|
{
|
||||||
|
clamp = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
skipToken = 2;
|
||||||
|
}
|
||||||
|
else if ( !ASSIMP_strincmp(pPtr, BlendUOption.c_str(), BlendUOption.size())
|
||||||
|
|| !ASSIMP_strincmp(pPtr, BlendVOption.c_str(), BlendVOption.size())
|
||||||
|
|| !ASSIMP_strincmp(pPtr, BoostOption.c_str(), BoostOption.size())
|
||||||
|
|| !ASSIMP_strincmp(pPtr, ResolutionOption.c_str(), ResolutionOption.size())
|
||||||
|
|| !ASSIMP_strincmp(pPtr, BumpOption.c_str(), BumpOption.size())
|
||||||
|
|| !ASSIMP_strincmp(pPtr, ChannelOption.c_str(), ChannelOption.size())
|
||||||
|
|| !ASSIMP_strincmp(pPtr, TypeOption.c_str(), TypeOption.size()) )
|
||||||
|
{
|
||||||
|
skipToken = 2;
|
||||||
|
}
|
||||||
|
else if (!ASSIMP_strincmp(pPtr, ModifyMapOption.c_str(), ModifyMapOption.size()))
|
||||||
|
{
|
||||||
|
skipToken = 3;
|
||||||
|
}
|
||||||
|
else if ( !ASSIMP_strincmp(pPtr, OffsetOption.c_str(), OffsetOption.size())
|
||||||
|
|| !ASSIMP_strincmp(pPtr, ScaleOption.c_str(), ScaleOption.size())
|
||||||
|
|| !ASSIMP_strincmp(pPtr, TurbulenceOption.c_str(), TurbulenceOption.size())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
skipToken = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < skipToken; ++i)
|
||||||
|
{
|
||||||
|
m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
} // Namespace Assimp
|
} // Namespace Assimp
|
||||||
|
|
|
@ -92,6 +92,7 @@ private:
|
||||||
void createMaterial();
|
void createMaterial();
|
||||||
/// Get texture name from loaded data.
|
/// Get texture name from loaded data.
|
||||||
void getTexture();
|
void getTexture();
|
||||||
|
void getTextureOption(bool &clamp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Absolute pathname
|
//! Absolute pathname
|
||||||
|
|
|
@ -149,8 +149,11 @@ void ObjFileParser::parseFile()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'm': // Parse a material library
|
case 'm': // Parse a material library or merging group ('mg')
|
||||||
{
|
{
|
||||||
|
if (*(m_DataIt + 1) == 'g')
|
||||||
|
getGroupNumberAndResolution();
|
||||||
|
else
|
||||||
getMaterialLib();
|
getMaterialLib();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -609,6 +612,15 @@ void ObjFileParser::getGroupNumber()
|
||||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Not supported
|
||||||
|
void ObjFileParser::getGroupNumberAndResolution()
|
||||||
|
{
|
||||||
|
// Not used
|
||||||
|
|
||||||
|
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Stores values for a new object instance, name will be used to
|
// Stores values for a new object instance, name will be used to
|
||||||
// identify it.
|
// identify it.
|
||||||
|
|
|
@ -102,6 +102,8 @@ private:
|
||||||
void getGroupName();
|
void getGroupName();
|
||||||
/// Gets the group number from file.
|
/// Gets the group number from file.
|
||||||
void getGroupNumber();
|
void getGroupNumber();
|
||||||
|
/// Gets the group number and resolution from file.
|
||||||
|
void getGroupNumberAndResolution();
|
||||||
/// Returns the index of the material. Is -1 if not material was found.
|
/// Returns the index of the material. Is -1 if not material was found.
|
||||||
int getMaterialIndex( const std::string &strMaterialName );
|
int getMaterialIndex( const std::string &strMaterialName );
|
||||||
/// Parse object name
|
/// Parse object name
|
||||||
|
|
|
@ -157,7 +157,6 @@ template<class char_t>
|
||||||
inline char_t getName( char_t it, char_t end, std::string &name )
|
inline char_t getName( char_t it, char_t end, std::string &name )
|
||||||
{
|
{
|
||||||
name = "";
|
name = "";
|
||||||
it = getNextToken<char_t>( it, end );
|
|
||||||
if ( isEndOfBuffer( it, end ) )
|
if ( isEndOfBuffer( it, end ) )
|
||||||
return end;
|
return end;
|
||||||
|
|
||||||
|
|
|
@ -153,8 +153,8 @@ void STLImporter::InternReadFile( const std::string& pFile,
|
||||||
this->pScene = pScene;
|
this->pScene = pScene;
|
||||||
this->mBuffer = &mBuffer2[0];
|
this->mBuffer = &mBuffer2[0];
|
||||||
|
|
||||||
// the default vertex color is white
|
// the default vertex color is light gray.
|
||||||
clrColorDefault.r = clrColorDefault.g = clrColorDefault.b = clrColorDefault.a = 1.0f;
|
clrColorDefault.r = clrColorDefault.g = clrColorDefault.b = clrColorDefault.a = 0.6f;
|
||||||
|
|
||||||
// allocate one mesh
|
// allocate one mesh
|
||||||
pScene->mNumMeshes = 1;
|
pScene->mNumMeshes = 1;
|
||||||
|
@ -189,13 +189,14 @@ void STLImporter::InternReadFile( const std::string& pFile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a single default material - everything white, as we have vertex colors
|
// create a single default material, using a light gray diffuse color for consistency with
|
||||||
|
// other geometric types (e.g., PLY).
|
||||||
aiMaterial* pcMat = new aiMaterial();
|
aiMaterial* pcMat = new aiMaterial();
|
||||||
aiString s;
|
aiString s;
|
||||||
s.Set(AI_DEFAULT_MATERIAL_NAME);
|
s.Set(AI_DEFAULT_MATERIAL_NAME);
|
||||||
pcMat->AddProperty(&s, AI_MATKEY_NAME);
|
pcMat->AddProperty(&s, AI_MATKEY_NAME);
|
||||||
|
|
||||||
aiColor4D clrDiffuse(1.0f,1.0f,1.0f,1.0f);
|
aiColor4D clrDiffuse(0.6f,0.6f,0.6f,1.0f);
|
||||||
if (bMatClr) {
|
if (bMatClr) {
|
||||||
clrDiffuse = clrColorDefault;
|
clrDiffuse = clrColorDefault;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue