2
0
Эх сурвалжийг харах

Merge pull request #1106 from elect86/master

OBJ, added the index to handle clamp option for each cubemap texture
Kim Kulling 8 жил өмнө
parent
commit
df03c657bf

+ 7 - 7
code/ObjFileImporter.cpp

@@ -542,13 +542,13 @@ void ObjFileImporter::countObjects(const std::vector<ObjFile::Object*> &rObjects
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 //   Add clamp mode property to material if necessary
 //   Add clamp mode property to material if necessary
-void ObjFileImporter::addTextureMappingModeProperty( aiMaterial* mat, aiTextureType type, int clampMode) {
+void ObjFileImporter::addTextureMappingModeProperty( aiMaterial* mat, aiTextureType type, int clampMode, int index) {
     if ( nullptr == mat ) {
     if ( nullptr == mat ) {
         return;
         return;
     }
     }
 
 
-    mat->AddProperty<int>( &clampMode, 1, AI_MATKEY_MAPPINGMODE_U( type, 0 ) );
-    mat->AddProperty<int>( &clampMode, 1, AI_MATKEY_MAPPINGMODE_V( type, 0 ) );
+    mat->AddProperty<int>( &clampMode, 1, AI_MATKEY_MAPPINGMODE_U( type, index ) );
+    mat->AddProperty<int>( &clampMode, 1, AI_MATKEY_MAPPINGMODE_V( type, index ) );
 }
 }
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
@@ -668,12 +668,12 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc
 
 
             unsigned count = type == ObjFile::Material::TextureReflectionSphereType ? 1 : 6;
             unsigned count = type == ObjFile::Material::TextureReflectionSphereType ? 1 : 6;
             for( unsigned i = 0; i < count; i++ )
             for( unsigned i = 0; i < count; i++ )
+            {
                 mat->AddProperty(&pCurrentMaterial->textureReflection[i], AI_MATKEY_TEXTURE_REFLECTION(i));
                 mat->AddProperty(&pCurrentMaterial->textureReflection[i], AI_MATKEY_TEXTURE_REFLECTION(i));
 
 
-            if(pCurrentMaterial->clamp[type])
-                //TODO addTextureMappingModeProperty should accept an index to handle clamp option for each
-                //texture of a cubemap
-                addTextureMappingModeProperty(mat, aiTextureType_REFLECTION);
+                if(pCurrentMaterial->clamp[type])
+                    addTextureMappingModeProperty(mat, aiTextureType_REFLECTION, 1, i);
+            }
         }
         }
 
 
         if ( 0 != pCurrentMaterial->textureDisp.length )
         if ( 0 != pCurrentMaterial->textureDisp.length )

+ 1 - 1
code/ObjFileImporter.h

@@ -100,7 +100,7 @@ private:
     void createMaterials(const ObjFile::Model* pModel, aiScene* pScene);
     void createMaterials(const ObjFile::Model* pModel, aiScene* pScene);
 
 
     /// @brief  Adds special property for the used texture mapping mode of the model.
     /// @brief  Adds special property for the used texture mapping mode of the model.
-    void addTextureMappingModeProperty(aiMaterial* mat, aiTextureType type, int clampMode = 1);
+    void addTextureMappingModeProperty(aiMaterial* mat, aiTextureType type, int clampMode = 1, int index = 0);
 
 
     //! \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);