From 559daf900d5eece5f00efdd0c5433d178519d5b7 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Thu, 11 Sep 2008 20:50:15 +0000 Subject: [PATCH] NFF finished except cone implementation. Added fixes by lynxeye to make assimp work with GCC 4. Website - again a backup of the current version. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@130 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/3DSConverter.cpp | 9 ++- code/3DSHelper.h | 6 +- code/3DSLoader.h | 2 +- code/BaseImporter.h | 2 +- code/NFFLoader.cpp | 110 ++++++++++++++++++++++++++++---- code/NFFLoader.h | 2 +- code/SGSpatialSort.h | 7 +- code/SmoothingGroups.h | 2 +- code/SmoothingGroups.inl | 6 +- code/StandardShapes.cpp | Bin 12994 -> 20776 bytes code/StandardShapes.h | 70 +++++++++++++++++--- code/qnan.h | 14 +--- include/NullLogger.h | 2 +- include/aiMaterial.inl | 2 +- include/aiMatrix3x3.h | 2 +- include/aiMatrix3x3.inl | 2 +- include/aiMesh.h | 3 +- include/aiTexture.h | 4 +- include/aiVector3D.h | 6 +- include/aiVector3D.inl | 2 +- test/NFF/dodecahedron.nff | 1 + test/NFF/hexahedron.nff | 2 + test/NFF/octahedron.nff | 1 + test/NFF/positionTest.nff | 29 +++++++-- test/NFF/spheres.nff | 9 ++- test/NFF/tetrahedron.nff | 1 + tools/assimp_view/AssetHelper.h | 1 + tools/assimp_view/Normals.cpp | 12 +++- 28 files changed, 244 insertions(+), 65 deletions(-) create mode 100644 test/NFF/dodecahedron.nff create mode 100644 test/NFF/hexahedron.nff create mode 100644 test/NFF/octahedron.nff create mode 100644 test/NFF/tetrahedron.nff 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 29406a6f17a762b9efd2b5ed351e6ad83bef105d..e8a74dd4bed9b926e48900a7a5e47bd129a769af 100644 GIT binary patch literal 20776 zcmeI4`%fF$702(dRO+9|Mj-t z&pkfA9(!KKR+To$8qfI7ocFosac9Q={?}Z%7ycOj5H`a5a2U=)BP@kWeGWrM$7|tK z4MXbP;*!h669 zrcRWNu?s<7YwVyq0u|s*7T}-{M`-UnQa+Q78lrTSmUBemjbVSKC3dg3)Jza|zz;Qz#U`;3{> z70d%{iS;jfHb0Ht%gC{gPGr$MFZcPAyu4_pr+9$H-iVgXL?|TaGtq)u_hFZ$Kl*aD zMI-zUKg`3B<^gmrdvcjK_D3S%xf+Ry^?Q-N#Umn9M-&+*t0J@7N3kBku=%uL!@JoiTIkL6}ir%Zi=#S zoz-qt4oH^V4zH9E+rrRRR(+u?@m9FD!m37Wd{e(R!VmhjqR|zNKMz0Z8%VBN*4a&s zZ0U-Z8r#;`D~+wk>$f8AC3y>wT>C~>aP9N3qoWNSL!IbxCrV*-?`X`S*h6tO{8g0T zjeOULuv|?(U)SEaGybAmU6_999LH%r2@sqZb(UlXPsLGz2z z9ql)DWm|CQ%j|}H?I`P#j^JQL(H2d;(KnK!%OA913oH+J>-r=a^Q;Ot8}bjhgg&+_ zv*~kP*NCzr^?Lkea+z(hDZIkk;VV z$B4C`Q*`wgY0hvNBz!ChYDr#!cTp{l?=LoUuox0z2h+ECMqA_0MGLEL>lklqi2jB? zE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%{ZQUY;xG;4$9PLCaw%JX9p84bw=#?0$3(wuU-Hv1Z9T0` zUgsI^X36@`H+sKkN~?4IPof3mBJY6~YcgtR@ zaw&TPKPwYmWa57KY4>ba9_{Tadwc4;p3KkGtxZc){wCE_?%Q_7JS2brl0A4izDY5v z_Yw)K{Wo2eSN{yp2_jiF)^t^!d13#?FqwBbxD#aj@gH3LR~Yx){U7V>okaf2fcucV z^UnV=9qRX7*GGSg(6@d^JXzMv<^SQR>_?59ZiQm6vj3erjW$SD`@Caq@{8Z)KNgd| K(oz4vFZ>5wCthm+ delta 263 zcmZ3ni1ASBhHdSf@Fa~P`$_OSwWsG5ZH?vAdGIFLd?_DWZ!TiR7|dy*}u8WhK+Huo4E~&@cPL?7GaauSfouBv&@;SV5u|N zKwDvQf)UT;dzL(4{yZRmftAQ)KP#TeeA-Hr8?2mwG{@vQMtqY6tfe-8v+82p+~+xq F9RSJwNp1iD 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)