diff --git a/code/3DSConverter.cpp b/code/3DSConverter.cpp index 8e53585f4..8bf54a277 100644 --- a/code/3DSConverter.cpp +++ b/code/3DSConverter.cpp @@ -265,6 +265,12 @@ void Dot3DSImporter::ConvertMaterial(Dot3DS::Material& oldMat, case Dot3DS::Dot3DSFile::Metal : eShading = aiShadingMode_CookTorrance; break; + + // FIX to workaround a warning with GCC 4 who complained + // about a missing case Blinn: here - Blinn isn't a valid + // value in the 3DS Loader, it is just needed for ASE + case Dot3DS::Dot3DSFile::Blinn : + eShading = aiShadingMode_Blinn; break; } mat.AddProperty( (int*)&eShading,1,AI_MATKEY_SHADING_MODEL); @@ -402,7 +408,6 @@ void Dot3DSImporter::ConvertMeshes(aiScene* pcOut) aiSplit[*a].push_back(iNum); } // now generate submeshes - bool bFirst = true; for (unsigned int p = 0; p < this->mScene->mMaterials.size();++p) { if (aiSplit[p].size() != 0) @@ -586,8 +591,6 @@ void Dot3DSImporter::GenerateNodeGraph(aiScene* pcOut) // | | | | // MESH_0 MESH_1 MESH_2 ... MESH_N // - unsigned int iCnt = 0; - DefaultLogger::get()->warn("No hierarchy information has been found in the file. "); pcOut->mRootNode->mNumChildren = pcOut->mNumMeshes; diff --git a/code/3DSHelper.h b/code/3DSHelper.h index 353d71e6e..3bdf0ded7 100644 --- a/code/3DSHelper.h +++ b/code/3DSHelper.h @@ -326,8 +326,8 @@ struct Texture , mOffsetU (0.0f) , mOffsetV (0.0f) , mRotation (0.0f) - , iUVSrc (0) , mMapMode (aiTextureMapMode_Wrap) + , iUVSrc (0) { mTextureBlend = std::numeric_limits::quiet_NaN(); } @@ -364,9 +364,9 @@ struct Material mTransparency (1.0f), mBumpHeight (1.0f), iBakeUVTransform (0), - pcSingleTexture (NULL), mShininessStrength (1.0f), - mTwoSided (false) + mTwoSided (false), + pcSingleTexture (NULL) { static int iCnt = 0; diff --git a/code/3DSLoader.h b/code/3DSLoader.h index 446ded6af..ccdab4032 100644 --- a/code/3DSLoader.h +++ b/code/3DSLoader.h @@ -269,4 +269,4 @@ protected: } // end of namespace Assimp -#endif // AI_3DSIMPORTER_H_INC \ No newline at end of file +#endif // AI_3DSIMPORTER_H_INC diff --git a/code/BaseImporter.h b/code/BaseImporter.h index 5bac0481e..913d9db74 100644 --- a/code/BaseImporter.h +++ b/code/BaseImporter.h @@ -189,4 +189,4 @@ protected: } // end of namespace Assimp -#endif // AI_BASEIMPORTER_H_INC \ No newline at end of file +#endif // AI_BASEIMPORTER_H_INC diff --git a/code/NFFLoader.cpp b/code/NFFLoader.cpp index 467c2f247..d532f82b8 100644 --- a/code/NFFLoader.cpp +++ b/code/NFFLoader.cpp @@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "ParsingUtils.h" #include "StandardShapes.h" #include "fast_atof.h" +#include "qnan.h" // public assimp headers #include "../include/IOStream.h" @@ -105,7 +106,7 @@ bool GetNextLine(const char*& buffer, char out[4096]) // ------------------------------------------------------------------------------------------------ #define AI_NFF_PARSE_FLOAT(f) \ SkipSpaces(&sz); \ - sz = fast_atof_move(sz, f); + if (!::IsLineEnd(*sz))sz = fast_atof_move(sz, f); // ------------------------------------------------------------------------------------------------ #define AI_NFF_PARSE_TRIPLE(v) \ @@ -115,10 +116,12 @@ bool GetNextLine(const char*& buffer, char out[4096]) // ------------------------------------------------------------------------------------------------ #define AI_NFF_PARSE_SHAPE_INFORMATION() \ - sz = &line[1]; \ - aiVector3D center; float radius; \ + aiVector3D center, radius(1.0f,std::numeric_limits::quiet_NaN(),std::numeric_limits::quiet_NaN()); \ AI_NFF_PARSE_TRIPLE(center); \ - AI_NFF_PARSE_FLOAT(radius); \ + AI_NFF_PARSE_TRIPLE(radius); \ + if (is_qnan(radius.z))radius.z = radius.x; \ + if (is_qnan(radius.y))radius.y = radius.x; \ + currentMesh.radius = radius; \ currentMesh.center = center; // ------------------------------------------------------------------------------------------------ @@ -156,7 +159,9 @@ void NFFImporter::InternReadFile( const std::string& pFile, char line[4096]; const char* sz; - unsigned int sphere = 0,cylinder = 0,cone = 0,numNamed = 0; + unsigned int sphere = 0,cylinder = 0,cone = 0,numNamed = 0, + dodecahedron = 0,octecahedron = 0,octahedron = 0,tetrahedron = 0, hexahedron = 0; + while (GetNextLine(buffer,line)) { if ('p' == line[0]) @@ -186,7 +191,12 @@ void NFFImporter::InternReadFile( const std::string& pFile, SkipSpaces(sz,&sz); m = strtol10(sz); - out->vertices.reserve(out->vertices.size()+m); + // ---- flip the face order + out->vertices.resize(out->vertices.size()+m); + if (out == currentMeshWithNormals) + { + out->normals.resize(out->vertices.size()); + } for (unsigned int n = 0; n < m;++n) { if(!GetNextLine(buffer,line)) @@ -197,12 +207,12 @@ void NFFImporter::InternReadFile( const std::string& pFile, aiVector3D v; sz = &line[0]; AI_NFF_PARSE_TRIPLE(v); - out->vertices.push_back(v); + out->vertices[out->vertices.size()-n-1] = v; - if ('p' == line[1]) + if (out == currentMeshWithNormals) { AI_NFF_PARSE_TRIPLE(v); - out->normals.push_back(v); + out->normals[out->vertices.size()-n-1] = v; } } out->faces.push_back(m); @@ -256,15 +266,88 @@ void NFFImporter::InternReadFile( const std::string& pFile, MeshInfo& currentMesh = meshesLocked.back(); currentMesh.shader = s; + sz = &line[1]; AI_NFF_PARSE_SHAPE_INFORMATION(); - // generate the sphere - it consists of simple triangles - StandardShapes::MakeSphere(aiVector3D(), radius, iTesselation, currentMesh.vertices); + // we don't need scaling or translation here - we do it in the node's transform + StandardShapes::MakeSphere(aiVector3D(), 1.0f, iTesselation, currentMesh.vertices); currentMesh.faces.resize(currentMesh.vertices.size()/3,3); // generate a name for the mesh ::sprintf(currentMesh.name,"sphere_%i",sphere++); } + // 'dod' - dodecahedron + else if (!strncmp(line,"dod",3) && IsSpace(line[3])) + { + meshesLocked.push_back(MeshInfo(false,true)); + MeshInfo& currentMesh = meshesLocked.back(); + currentMesh.shader = s; + + sz = &line[4]; + AI_NFF_PARSE_SHAPE_INFORMATION(); + + // we don't need scaling or translation here - we do it in the node's transform + StandardShapes::MakeDodecahedron(aiVector3D(), 1.0f, currentMesh.vertices); + currentMesh.faces.resize(currentMesh.vertices.size()/3,3); + + // generate a name for the mesh + ::sprintf(currentMesh.name,"dodecahedron_%i",dodecahedron++); + } + + // 'oct' - octahedron + else if (!strncmp(line,"oct",3) && IsSpace(line[3])) + { + meshesLocked.push_back(MeshInfo(false,true)); + MeshInfo& currentMesh = meshesLocked.back(); + currentMesh.shader = s; + + sz = &line[4]; + AI_NFF_PARSE_SHAPE_INFORMATION(); + + // we don't need scaling or translation here - we do it in the node's transform + StandardShapes::MakeOctahedron(aiVector3D(), 1.0f, currentMesh.vertices); + currentMesh.faces.resize(currentMesh.vertices.size()/3,3); + + // generate a name for the mesh + ::sprintf(currentMesh.name,"octecahedron_%i",octecahedron++); + } + + // 'tet' - tetrahedron + else if (!strncmp(line,"tet",3) && IsSpace(line[3])) + { + meshesLocked.push_back(MeshInfo(false,true)); + MeshInfo& currentMesh = meshesLocked.back(); + currentMesh.shader = s; + + sz = &line[4]; + AI_NFF_PARSE_SHAPE_INFORMATION(); + + // we don't need scaling or translation here - we do it in the node's transform + StandardShapes::MakeTetrahedron(aiVector3D(), 1.0f, currentMesh.vertices); + currentMesh.faces.resize(currentMesh.vertices.size()/3,3); + + // generate a name for the mesh + ::sprintf(currentMesh.name,"tetrahedron_%i",tetrahedron++); + } + + // 'hex' - hexahedron + else if (!strncmp(line,"hex",3) && IsSpace(line[3])) + { + meshesLocked.push_back(MeshInfo(false,true)); + MeshInfo& currentMesh = meshesLocked.back(); + currentMesh.shader = s; + + sz = &line[4]; + AI_NFF_PARSE_SHAPE_INFORMATION(); + + // we don't need scaling or translation here - we do it in the node's transform + StandardShapes::MakeHexahedron(aiVector3D(),1.0f, currentMesh.vertices); + currentMesh.faces.resize(currentMesh.vertices.size()/3,3); + + // generate a name for the mesh + ::sprintf(currentMesh.name,"hexahedron_%i",hexahedron++); + } + // 'tess' - tesselation else if (!strncmp(line,"tess",4) && IsSpace(line[4])) { @@ -359,12 +442,17 @@ void NFFImporter::InternReadFile( const std::string& pFile, node->mNumMeshes = 1; node->mMeshes = new unsigned int[1]; node->mMeshes[0] = m; + node->mName.Set(src.name); // setup the transformation matrix of the node node->mTransformation.a4 = src.center.x; node->mTransformation.b4 = src.center.y; node->mTransformation.c4 = src.center.z; + node->mTransformation.a1 = src.radius.x; + node->mTransformation.b2 = src.radius.y; + node->mTransformation.c3 = src.radius.z; + ++ppcChildren; } else *pMeshes++ = m; diff --git a/code/NFFLoader.h b/code/NFFLoader.h index ea9eb1662..82767c441 100644 --- a/code/NFFLoader.h +++ b/code/NFFLoader.h @@ -119,7 +119,7 @@ private: bool bHasNormals, bLocked; // for spheres, cones and cylinders: center point of the object - aiVector3D center; + aiVector3D center, radius; char name[128]; diff --git a/code/SGSpatialSort.h b/code/SGSpatialSort.h index be05abc96..451516eb2 100644 --- a/code/SGSpatialSort.h +++ b/code/SGSpatialSort.h @@ -110,7 +110,10 @@ protected: Entry() { /** intentionally not initialized.*/ } Entry( unsigned int pIndex, const aiVector3D& pPosition, float pDistance,uint32_t pSG) : - mPosition( pPosition), mIndex( pIndex), mDistance( pDistance),mSmoothGroups (pSG) + mIndex( pIndex), + mPosition( pPosition), + mSmoothGroups (pSG), + mDistance( pDistance) { } bool operator < (const Entry& e) const { return mDistance < e.mDistance; } @@ -122,4 +125,4 @@ protected: } // end of namespace Assimp -#endif // AI_SPATIALSORT_H_INC \ No newline at end of file +#endif // AI_SPATIALSORT_H_INC diff --git a/code/SmoothingGroups.h b/code/SmoothingGroups.h index ea8c92890..98f2a778e 100644 --- a/code/SmoothingGroups.h +++ b/code/SmoothingGroups.h @@ -100,4 +100,4 @@ void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups& sMesh); // include implementations #include "SmoothingGroups.inl" -#endif // !! AI_SMOOTHINGGROUPS_H_INC \ No newline at end of file +#endif // !! AI_SMOOTHINGGROUPS_H_INC diff --git a/code/SmoothingGroups.inl b/code/SmoothingGroups.inl index a86e4fe28..da43c8dea 100644 --- a/code/SmoothingGroups.inl +++ b/code/SmoothingGroups.inl @@ -95,8 +95,7 @@ void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups& sMesh) // now generate the spatial sort tree SGSpatialSort sSort; - for( std::vector::iterator - i = sMesh.mFaces.begin(); + for( std::vector::iterator i = sMesh.mFaces.begin(); i != sMesh.mFaces.end();++i) { sSort.Add(sMesh.mPositions[(*i).mIndices[0]],(*i).mIndices[0],(*i).iSmoothGroup); @@ -105,8 +104,7 @@ void ComputeNormalsWithSmoothingsGroups(MeshWithSmoothingGroups& sMesh) } sSort.Prepare(); - for( std::vector::iterator - i = sMesh.mFaces.begin(); + for( std::vector::iterator i = sMesh.mFaces.begin(); i != sMesh.mFaces.end();++i) { std::vector poResult; diff --git a/code/StandardShapes.cpp b/code/StandardShapes.cpp index 29406a6f1..e8a74dd4b 100644 Binary files a/code/StandardShapes.cpp and b/code/StandardShapes.cpp differ diff --git a/code/StandardShapes.h b/code/StandardShapes.h index 194d44870..e0f7763d4 100644 --- a/code/StandardShapes.h +++ b/code/StandardShapes.h @@ -59,32 +59,52 @@ class ASSIMP_API StandardShapes public: + /** @brief Generates a hexahedron (cube) + * + * Hexahedrons can be scaled on all axes. + * @param center Center point of the hexahedron + * @param length Radius of the hexahedron + * @param positions Receives output triangles. + */ + static void MakeHexahedron(aiVector3D& center,const aiVector3D& length, + std::vector& positions); + + /** @brief Generates an icosahedron * * @param center Center point of the icosahedron - * @param length Face length of the icosahedron + * @param length Radius of the icosahedron * @param positions Receives output triangles. */ - static void MakeIcosahedron(aiVector3D& center,float length, + static void MakeIcosahedron(aiVector3D& center,const aiVector3D& length, std::vector& positions); /** @brief Generates a dodecahedron * * @param center Center point of the dodecahedron - * @param length Face length of the dodecahedron - * @param positions Receives output triangles. + * @param length Radius of the dodecahedron + * @param positions Receives output triangles */ - static void MakeDodecahedron(aiVector3D& center,float length, + static void MakeDodecahedron(aiVector3D& center,const aiVector3D& length, std::vector& positions); /** @brief Generates an octahedron * * @param center Center point of the octahedron - * @param length Face length of the octahedron + * @param length Radius of the octahedron * @param positions Receives output triangles. */ - static void MakeOctahedron(aiVector3D& center,float length, + static void MakeOctahedron(aiVector3D& center,const aiVector3D& length, + std::vector& positions); + + /** @brief Generates a tetrahedron + * + * @param center Center point of the tetrahedron + * @param length Radius of the octahedron + * @param positions Receives output triangles. + */ + static void MakeTetrahedron(aiVector3D& center,const aiVector3D& length, std::vector& positions); @@ -95,7 +115,7 @@ public: * @param tess Number of subdivions - 0 generates a octahedron * @param positions Receives output triangles. */ - static void MakeSphere(aiVector3D& center,float radius,unsigned int tess, + static void MakeSphere(aiVector3D& center,float length,unsigned int tess, std::vector& positions); /** @brief Generates a cone or a cylinder, either opened or closed. @@ -140,6 +160,40 @@ public: static void MakeCircle(aiVector3D& center, aiVector3D& normal, float radius, unsigned int tess, std::vector& positions); + + + // simplified versions - the radius is a single float and applies + // to all axes. These version of the functions must be used if ou + // REALLY want a platonic primitive :-) + static void MakeHexahedron(aiVector3D& center,float length, + std::vector& positions) + { + MakeHexahedron(center,aiVector3D(length),positions); + } + + static void MakeDodecahedron(aiVector3D& center,float length, + std::vector& positions) + { + MakeDodecahedron(center,aiVector3D(length),positions); + } + + static void MakeOcathedron(aiVector3D& center,float length, + std::vector& positions) + { + MakeOctahedron(center,aiVector3D(length),positions); + } + + static void MakeTetrahedron(aiVector3D& center,float length, + std::vector& positions) + { + MakeTetrahedron(center,aiVector3D(length),positions); + } + + static void MakeIcosahedron(aiVector3D& center,float length, + std::vector& positions) + { + MakeIcosahedron(center,aiVector3D(length),positions); + } }; } // ! Assimp diff --git a/code/qnan.h b/code/qnan.h index af515f56f..92c20df4e 100644 --- a/code/qnan.h +++ b/code/qnan.h @@ -3,9 +3,7 @@ #if (!defined AI_QNAN_H_INCLUDED) #define AI_QNAN_H_INCLUDED -#if (!defined ASSIMP_BUILD_CPP_09) -# include -#endif + inline bool is_qnan(const float in) { @@ -21,14 +19,6 @@ inline bool is_qnan(const float in) int32_t i; } FPUNION1,FPUNION2; - // use a compile-time asertion if possible -#if (defined ASSIMP_BUILD_CPP_09) - static_assert(sizeof(float)==sizeof(int32_t), - "A float seems not to be 4 bytes on this platform"); -#else - BOOST_STATIC_ASSERT(sizeof(float)==sizeof(int32_t)); -#endif - FPUNION1.f = in; FPUNION2.f = std::numeric_limits::quiet_NaN(); return FPUNION1.i == FPUNION2.i; @@ -39,4 +29,4 @@ inline bool is_not_qnan(const float in) return !is_qnan(in); } -#endif // !! AI_QNAN_H_INCLUDED \ No newline at end of file +#endif // !! AI_QNAN_H_INCLUDED diff --git a/include/NullLogger.h b/include/NullLogger.h index 0fd603db2..410894eb2 100644 --- a/include/NullLogger.h +++ b/include/NullLogger.h @@ -79,4 +79,4 @@ public: } -#endif // !! AI_NULLLOGGER_H_INCLUDED \ No newline at end of file +#endif // !! AI_NULLLOGGER_H_INCLUDED diff --git a/include/aiMaterial.inl b/include/aiMaterial.inl index a8ab82e11..4f12cf34d 100644 --- a/include/aiMaterial.inl +++ b/include/aiMaterial.inl @@ -132,4 +132,4 @@ inline aiReturn aiMaterial::Get(const char* pKey,aiString& pOut) return aiGetMaterialString(this,pKey,&pOut); } -#endif //! AI_MATERIAL_INL_INC \ No newline at end of file +#endif //! AI_MATERIAL_INL_INC diff --git a/include/aiMatrix3x3.h b/include/aiMatrix3x3.h index bef3015bb..4b21237d4 100644 --- a/include/aiMatrix3x3.h +++ b/include/aiMatrix3x3.h @@ -89,4 +89,4 @@ struct aiMatrix3x3 } // end of extern C #endif -#endif // AI_MATRIX3x3_H_INC \ No newline at end of file +#endif // AI_MATRIX3x3_H_INC diff --git a/include/aiMatrix3x3.inl b/include/aiMatrix3x3.inl index 5ed27b4f6..3dabacfa0 100644 --- a/include/aiMatrix3x3.inl +++ b/include/aiMatrix3x3.inl @@ -53,4 +53,4 @@ inline aiMatrix3x3& aiMatrix3x3::Transpose() #endif // __cplusplus -#endif // AI_MATRIX3x3_INL_INC \ No newline at end of file +#endif // AI_MATRIX3x3_INL_INC diff --git a/include/aiMesh.h b/include/aiMesh.h index e9b191f8c..b9dbf4d44 100644 --- a/include/aiMesh.h +++ b/include/aiMesh.h @@ -451,4 +451,5 @@ struct aiMesh } #endif -#endif // AI_MESH_H_INC \ No newline at end of file +#endif // AI_MESH_H_INC + diff --git a/include/aiTexture.h b/include/aiTexture.h index 57b2e8ad5..b63b607aa 100644 --- a/include/aiTexture.h +++ b/include/aiTexture.h @@ -164,7 +164,7 @@ struct aiTexture // Construction aiTexture () - : mHeight(0), mWidth(0), pcData(NULL) + : mWidth(0), mHeight(0), pcData(NULL) { achFormatHint[0] = '\0'; achFormatHint[1] = '\0'; @@ -185,4 +185,4 @@ struct aiTexture } #endif -#endif // AI_TEXTURE_H_INC \ No newline at end of file +#endif // AI_TEXTURE_H_INC diff --git a/include/aiVector3D.h b/include/aiVector3D.h index ae10bd109..c2164969d 100644 --- a/include/aiVector3D.h +++ b/include/aiVector3D.h @@ -55,6 +55,7 @@ struct aiVector3D #ifdef __cplusplus aiVector3D () : x(0.0f), y(0.0f), z(0.0f) {} aiVector3D (float _x, float _y, float _z) : x(_x), y(_y), z(_z) {} + aiVector3D (float _xyz) : x(_xyz), y(_xyz), z(_xyz) {} aiVector3D (const aiVector3D& o) : x(o.x), y(o.y), z(o.z) {} void Set( float pX, float pY, float pZ) { x = pX; y = pY; z = pZ; } @@ -78,6 +79,9 @@ struct aiVector3D inline aiVector3D& operator= (float f) {x = y = z = f;return *this;} + const aiVector3D SymMul(const aiVector3D& o) + {return aiVector3D(x*o.x,y*o.y,z*o.z);} + #endif // __cplusplus float x, y, z; @@ -143,4 +147,4 @@ inline aiVector3D operator - ( const aiVector3D& v) #endif // __cplusplus -#endif // AI_VECTOR3D_H_INC \ No newline at end of file +#endif // AI_VECTOR3D_H_INC diff --git a/include/aiVector3D.inl b/include/aiVector3D.inl index e59e4614b..ce0e78c4f 100644 --- a/include/aiVector3D.inl +++ b/include/aiVector3D.inl @@ -30,4 +30,4 @@ inline aiVector3D operator * (const aiMatrix4x4& pMatrix, const aiVector3D& pVec #endif // __cplusplus -#endif // AI_VECTOR3D_INL_INC \ No newline at end of file +#endif // AI_VECTOR3D_INL_INC diff --git a/test/NFF/dodecahedron.nff b/test/NFF/dodecahedron.nff new file mode 100644 index 000000000..6ab505178 --- /dev/null +++ b/test/NFF/dodecahedron.nff @@ -0,0 +1 @@ +dod 0 0 0 5 \ No newline at end of file diff --git a/test/NFF/hexahedron.nff b/test/NFF/hexahedron.nff new file mode 100644 index 000000000..7181f1039 --- /dev/null +++ b/test/NFF/hexahedron.nff @@ -0,0 +1,2 @@ +f 1 0 0 +hex 0 0 0 5 10 20 \ No newline at end of file diff --git a/test/NFF/octahedron.nff b/test/NFF/octahedron.nff new file mode 100644 index 000000000..eac88e7ad --- /dev/null +++ b/test/NFF/octahedron.nff @@ -0,0 +1 @@ +oct 0 0 0 5 5 5 \ No newline at end of file diff --git a/test/NFF/positionTest.nff b/test/NFF/positionTest.nff index 17c62b3f0..304aa9c66 100644 --- a/test/NFF/positionTest.nff +++ b/test/NFF/positionTest.nff @@ -1,10 +1,27 @@ +tess 4 + +f 0.3 0.3 0.3 1 1 + # a centered sphere + + s 0 0 0 5 -# a polgyon that should not be visible -p 4 -5 0 0 -0 -5 0 --5 0 0 -0 5 0 \ No newline at end of file +s 20 0 0 5 + +s 40 0 0 5 + +s 60 0 0 5 + + + +f 1 1 1 1 1 + +s -5 0 0 3 + +s 0 5 0 3 +s 0 -5 0 3 + + + diff --git a/test/NFF/spheres.nff b/test/NFF/spheres.nff index a029e555f..c03c52d49 100644 --- a/test/NFF/spheres.nff +++ b/test/NFF/spheres.nff @@ -14,11 +14,16 @@ s 5.0 4.0 8.0 3.0 f 0.0 1.0 0.0 0 1 1 # And another one -s 1.0 -4.0 2.0 4.0 +s 1.0 -4.0 2.0 4.0 2 2 #red f 1.0 0.0 0.0 0 1 1 # a simple cone c 10 10 5 3 -c 14 14 3 6 \ No newline at end of file +c 14 14 3 6 + + +# An icosahedron +tess 0 +s 1 -15 2 4 8 8 \ No newline at end of file diff --git a/test/NFF/tetrahedron.nff b/test/NFF/tetrahedron.nff new file mode 100644 index 000000000..78c3bdf79 --- /dev/null +++ b/test/NFF/tetrahedron.nff @@ -0,0 +1 @@ +tet 0 0 0 5 \ No newline at end of file diff --git a/tools/assimp_view/AssetHelper.h b/tools/assimp_view/AssetHelper.h index 2e80881e5..ee53a0eb4 100644 --- a/tools/assimp_view/AssetHelper.h +++ b/tools/assimp_view/AssetHelper.h @@ -201,6 +201,7 @@ class AssetHelper // ------------------------------------------------------------------ // flip all normal vectors void FlipNormals(); + void FlipNormalsInt(); }; #endif // !! IG \ No newline at end of file diff --git a/tools/assimp_view/Normals.cpp b/tools/assimp_view/Normals.cpp index 1c9ce0948..9e27ae470 100644 --- a/tools/assimp_view/Normals.cpp +++ b/tools/assimp_view/Normals.cpp @@ -93,10 +93,11 @@ public: bool g_bWasFlipped = false; + //------------------------------------------------------------------------------- // Flip all normal vectors //------------------------------------------------------------------------------- -void AssetHelper::FlipNormals() +void AssetHelper::FlipNormalsInt() { // invert all normal vectors for (unsigned int i = 0; i < this->pcScene->mNumMeshes;++i) @@ -107,6 +108,13 @@ void AssetHelper::FlipNormals() pcMesh->mNormals[a] *= -1.0f; } } +} + +//------------------------------------------------------------------------------- +void AssetHelper::FlipNormals() +{ + FlipNormalsInt(); + // recreate native data DeleteAssetData(true); CreateAssetData(); @@ -145,12 +153,14 @@ void AssetHelper::SetNormalSet(unsigned int iSet) { MyGenFaceNormalsProcess* pcProcess = new MyGenFaceNormalsProcess(); pcProcess->Execute(this->pcScene); + //FlipNormalsInt(); delete pcProcess; } else if (SMOOTH == iSet) { MyGenVertexNormalsProcess* pcProcess = new MyGenVertexNormalsProcess(); pcProcess->Execute(this->pcScene); + //FlipNormalsInt(); delete pcProcess; } else if (ORIGINAL == iSet)