Browse Source

Merge branch 'master' of https://github.com/assimp/assimp

Kim Kulling 10 years ago
parent
commit
5160975138

+ 3 - 2
Readme.md

@@ -113,7 +113,9 @@ If the docs don't solve your problem, ask on [StackOverflow](http://stackoverflo
 For development discussions, there is also a (very low-volume) mailing list, _assimp-discussions_
   [(subscribe here)]( https://lists.sourceforge.net/lists/listinfo/assimp-discussions) 
 
-And we also have an IRC-channel at freenode: #assetimporterlib .
+And we also have an IRC-channel at freenode: #assetimporterlib . You can easily join us via: [KiwiIRC/freenote](https://kiwiirc.com/client/irc.freenode.net), choose your nickname and type
+> /join #assetimporterlib
+
 ### Contributing ###
 
 Contributions to assimp are highly appreciated. The easiest way to get involved is to submit 
@@ -126,4 +128,3 @@ Our license is based on the modified, __3-clause BSD__-License.
 An _informal_ summary is: do whatever you want, but include Assimp's license text with your product - 
 and don't sue us if our code doesn't work. Note that, unlike LGPLed code, you may link statically to Assimp.
 For the legal details, see the `LICENSE` file. 
-

+ 0 - 6
code/MD5Loader.cpp

@@ -285,9 +285,6 @@ void MD5Importer::AttachChilds_Mesh(int iParentID,aiNode* piParent, BoneList& bo
                 aiQuaternion quat;
                 MD5::ConvertQuaternion ( bones[i].mRotationQuat, quat );
 
-                // FIX to get to Assimp's quaternion conventions
-                quat.w *= -1.f;
-
                 bones[i].mTransform = aiMatrix4x4 ( quat.GetMatrix());
                 bones[i].mTransform.a4 = bones[i].mPositionXYZ.x;
                 bones[i].mTransform.b4 = bones[i].mPositionXYZ.y;
@@ -656,9 +653,6 @@ void MD5Importer::LoadMD5AnimFile ()
 
                     MD5::ConvertQuaternion(vTemp, qKey->mValue);
                     qKey->mTime = vKey->mTime = dTime;
-
-                    // we need this to get to Assimp quaternion conventions
-                    qKey->mValue.w *= -1.f;
                 }
             }
 

+ 3 - 0
code/MD5Parser.h

@@ -262,6 +262,9 @@ inline void ConvertQuaternion (const aiVector3D& in, aiQuaternion& out) {
     if (t < 0.0f)
         out.w = 0.0f;
     else out.w = std::sqrt (t);
+
+    // Assimp convention.
+    out.w *= -1.f;
 }
 
 // ---------------------------------------------------------------------------

+ 8 - 0
code/ObjFileData.h

@@ -156,6 +156,7 @@ struct Material
     aiString textureEmissive;
     aiString textureBump;
     aiString textureNormal;
+    aiString textureReflection[6];
     aiString textureSpecularity;
     aiString textureOpacity;
     aiString textureDisp;
@@ -167,6 +168,13 @@ struct Material
         TextureEmissiveType,
         TextureBumpType,
         TextureNormalType,
+        TextureReflectionSphereType,
+        TextureReflectionCubeTopType,
+        TextureReflectionCubeBottomType,
+        TextureReflectionCubeFrontType,
+        TextureReflectionCubeBackType,
+        TextureReflectionCubeLeftType,
+        TextureReflectionCubeRightType,
         TextureSpecularityType,
         TextureOpacityType,
         TextureDispType,

+ 17 - 1
code/ObjFileImporter.cpp

@@ -138,7 +138,7 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
     if ( pos != std::string::npos ) {
         modelName = pFile.substr(pos+1, pFile.size() - pos - 1);
         folderName = pFile.substr( 0, pos );
-        if ( folderName.empty() ) {
+        if ( !folderName.empty() ) {
             pIOHandler->PushDirectory( folderName );
         }
     } else {
@@ -636,6 +636,22 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc
             }
         }
 
+        if( 0 != pCurrentMaterial->textureReflection[0].length )
+        {
+            ObjFile::Material::TextureType type = 0 != pCurrentMaterial->textureReflection[1].length ?
+                ObjFile::Material::TextureReflectionCubeTopType :
+                ObjFile::Material::TextureReflectionSphereType;
+
+            unsigned count = type == ObjFile::Material::TextureReflectionSphereType ? 1 : 6;
+            for( unsigned i = 0; i < count; 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 ( 0 != pCurrentMaterial->textureDisp.length )
         {
             mat->AddProperty( &pCurrentMaterial->textureDisp, AI_MATKEY_TEXTURE_DISPLACEMENT(0) );

+ 52 - 5
code/ObjFileMtlImporter.cpp

@@ -64,6 +64,7 @@ static const std::string BumpTexture1        = "map_bump";
 static const std::string BumpTexture2        = "map_Bump";
 static const std::string BumpTexture3        = "bump";
 static const std::string NormalTexture       = "map_Kn";
+static const std::string ReflectionTexture   = "refl";
 static const std::string DisplacementTexture = "disp";
 static const std::string SpecularityTexture  = "map_ns";
 
@@ -200,6 +201,7 @@ void ObjFileMtlImporter::load()
 
         case 'm':   // Texture
         case 'b':   // quick'n'dirty - for 'bump' sections
+        case 'r':   // quick'n'dirty - for 'refl' sections
             {
                 getTexture();
                 m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
@@ -332,6 +334,9 @@ void ObjFileMtlImporter::getTexture() {
         // Normal map
         out = & m_pModel->m_pCurrentMaterial->textureNormal;
         clampIndex = ObjFile::Material::TextureNormalType;
+    } else if(!ASSIMP_strincmp( pPtr, ReflectionTexture.c_str(), ReflectionTexture.size() ) ) {
+        // Reflection texture(s)
+        //Do nothing here
     } else if (!ASSIMP_strincmp( pPtr, DisplacementTexture.c_str(), DisplacementTexture.size() ) ) {
         // Displacement texture
         out = &m_pModel->m_pCurrentMaterial->textureDisp;
@@ -346,7 +351,7 @@ void ObjFileMtlImporter::getTexture() {
     }
 
     bool clamp = false;
-    getTextureOption(clamp);
+    getTextureOption(clamp, clampIndex, out);
     m_pModel->m_pCurrentMaterial->clamp[clampIndex] = clamp;
 
     std::string texture;
@@ -369,7 +374,7 @@ void ObjFileMtlImporter::getTexture() {
  * Because aiMaterial supports clamp option, so we also want to return it
  * /////////////////////////////////////////////////////////////////////////////
  */
-void ObjFileMtlImporter::getTextureOption(bool &clamp)
+void ObjFileMtlImporter::getTextureOption(bool &clamp, int &clampIndex, aiString *&out)
 {
     m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
 
@@ -392,13 +397,55 @@ void ObjFileMtlImporter::getTextureOption(bool &clamp)
 
             skipToken = 2;
         }
-        else if (  !ASSIMP_strincmp(pPtr, BlendUOption.c_str(), BlendUOption.size())
+        else if( !ASSIMP_strincmp( pPtr, TypeOption.c_str(), TypeOption.size() ) )
+        {
+            DataArrayIt it = getNextToken<DataArrayIt>( m_DataIt, m_DataItEnd );
+            char value[ 12 ];
+            CopyNextWord( it, m_DataItEnd, value, sizeof( value ) / sizeof( *value ) );
+            if( !ASSIMP_strincmp( value, "cube_top", 8 ) )
+            {
+                clampIndex = ObjFile::Material::TextureReflectionCubeTopType;
+                out = &m_pModel->m_pCurrentMaterial->textureReflection[0];
+            }
+            else if( !ASSIMP_strincmp( value, "cube_bottom", 11 ) )
+            {
+                clampIndex = ObjFile::Material::TextureReflectionCubeBottomType;
+                out = &m_pModel->m_pCurrentMaterial->textureReflection[1];
+            }
+            else if( !ASSIMP_strincmp( value, "cube_front", 10 ) )
+            {
+                clampIndex = ObjFile::Material::TextureReflectionCubeFrontType;
+                out = &m_pModel->m_pCurrentMaterial->textureReflection[2];
+            }
+            else if( !ASSIMP_strincmp( value, "cube_back", 9 ) )
+            {
+                clampIndex = ObjFile::Material::TextureReflectionCubeBackType;
+                out = &m_pModel->m_pCurrentMaterial->textureReflection[3];
+            }
+            else if( !ASSIMP_strincmp( value, "cube_left", 9 ) )
+            {
+                clampIndex = ObjFile::Material::TextureReflectionCubeLeftType;
+                out = &m_pModel->m_pCurrentMaterial->textureReflection[4];
+            }
+            else if( !ASSIMP_strincmp( value, "cube_right", 10 ) )
+            {
+                clampIndex = ObjFile::Material::TextureReflectionCubeRightType;
+                out = &m_pModel->m_pCurrentMaterial->textureReflection[5];
+            }
+            else if( !ASSIMP_strincmp( value, "sphere", 6 ) )
+            {
+                clampIndex = ObjFile::Material::TextureReflectionSphereType;
+                out = &m_pModel->m_pCurrentMaterial->textureReflection[0];
+            }
+
+            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()) )
+                || !ASSIMP_strincmp(pPtr, ChannelOption.c_str(), ChannelOption.size()))
         {
             skipToken = 2;
         }

+ 2 - 1
code/ObjFileMtlImporter.h

@@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <string>
 
 struct aiColor3D;
+struct aiString;
 
 namespace Assimp {
 
@@ -89,7 +90,7 @@ private:
     void createMaterial();
     /// Get texture name from loaded data.
     void getTexture();
-    void getTextureOption(bool &clamp);
+    void getTextureOption(bool &clamp, int &clampIndex, aiString *&out);
 
 private:
     //! Absolute pathname

+ 5 - 2
code/ObjFileParser.cpp

@@ -414,7 +414,7 @@ void ObjFileParser::getFace(aiPrimitiveType type)
 
     if ( pIndices->empty() ) {
         DefaultLogger::get()->error("Obj: Ignoring empty face");
-        // skip line and clean up 
+        // skip line and clean up
         m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
         delete pNormalID;
         delete pTexID;
@@ -539,7 +539,10 @@ void ObjFileParser::getMaterialLib()
     const std::string strMatName(pStart, &(*m_DataIt));
     std::string absName;
     if ( m_pIO->StackSize() > 0 ) {
-        const std::string &path = m_pIO->CurrentDirectory();
+        std::string path = m_pIO->CurrentDirectory();
+        if ( '/' != *path.rbegin() ) {
+          path += '/';
+        }
         absName = path + strMatName;
     } else {
         absName = strMatName;

+ 1 - 1
code/PlyParser.cpp

@@ -857,7 +857,7 @@ bool PLY::PropertyInstance::ParseValueBinary(
 
     case EDT_UShort:
         {
-        int16_t i = *((uint16_t*)pCur);
+        uint16_t i = *((uint16_t*)pCur);
 
         // Swap endianess
         if (p_bBE)ByteSwap::Swap(&i);

BIN
test/regression/db.zip