From 65f6f0259ecb949bdd4884f3827ba9e1ec28684f Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Sat, 10 Jan 2015 19:39:53 +0100 Subject: [PATCH] Remove STL (stereolitography...) support --- lib/irrlicht/CMakeLists.txt | 4 - lib/irrlicht/include/IrrCompileConfig.h | 10 - .../source/Irrlicht/CSTLMeshFileLoader.cpp | 253 ------------------ .../source/Irrlicht/CSTLMeshFileLoader.h | 49 ---- .../source/Irrlicht/CSTLMeshWriter.cpp | 187 ------------- lib/irrlicht/source/Irrlicht/CSTLMeshWriter.h | 55 ---- .../source/Irrlicht/CSceneManager.cpp | 7 - 7 files changed, 565 deletions(-) delete mode 100644 lib/irrlicht/source/Irrlicht/CSTLMeshFileLoader.cpp delete mode 100644 lib/irrlicht/source/Irrlicht/CSTLMeshFileLoader.h delete mode 100644 lib/irrlicht/source/Irrlicht/CSTLMeshWriter.cpp delete mode 100644 lib/irrlicht/source/Irrlicht/CSTLMeshWriter.h diff --git a/lib/irrlicht/CMakeLists.txt b/lib/irrlicht/CMakeLists.txt index d8a67c245..409c61cdd 100644 --- a/lib/irrlicht/CMakeLists.txt +++ b/lib/irrlicht/CMakeLists.txt @@ -117,7 +117,6 @@ source/Irrlicht/CMeshCache.cpp source/Irrlicht/CIrrDeviceFB.cpp source/Irrlicht/CMemoryFile.cpp source/Irrlicht/CImageWriterPPM.cpp -source/Irrlicht/CSTLMeshFileLoader.cpp source/Irrlicht/CMountPointReader.cpp source/Irrlicht/CBillboardSceneNode.cpp source/Irrlicht/CGUIImageList.cpp @@ -140,7 +139,6 @@ source/Irrlicht/CLightSceneNode.cpp source/Irrlicht/CImageLoaderDDS.cpp source/Irrlicht/CSkyBoxSceneNode.cpp source/Irrlicht/CWriteFile.cpp -source/Irrlicht/CSTLMeshWriter.cpp source/Irrlicht/COctreeTriangleSelector.cpp source/Irrlicht/CFileList.cpp source/Irrlicht/CImageLoaderPCX.cpp @@ -229,7 +227,6 @@ source/Irrlicht/SoftwareDriver2_helper.h source/Irrlicht/CGUIWindow.h source/Irrlicht/CMD2MeshFileLoader.h source/Irrlicht/dmfsupport.h -source/Irrlicht/CSTLMeshFileLoader.h source/Irrlicht/CGUICheckBox.h source/Irrlicht/CMeshManipulator.h source/Irrlicht/IImagePresenter.h @@ -347,7 +344,6 @@ source/Irrlicht/CXMLWriter.h source/Irrlicht/CParticleCylinderEmitter.h source/Irrlicht/ITriangleRenderer.h source/Irrlicht/CSceneNodeAnimatorDelete.h -source/Irrlicht/CSTLMeshWriter.h source/Irrlicht/CIrrDeviceFB.h source/Irrlicht/CGUIEnvironment.h source/Irrlicht/CTerrainTriangleSelector.h diff --git a/lib/irrlicht/include/IrrCompileConfig.h b/lib/irrlicht/include/IrrCompileConfig.h index 7b92013f0..341806296 100644 --- a/lib/irrlicht/include/IrrCompileConfig.h +++ b/lib/irrlicht/include/IrrCompileConfig.h @@ -327,17 +327,7 @@ B3D, MS3D or X meshes */ #ifdef NO_IRR_COMPILE_WITH_OBJ_LOADER_ #undef _IRR_COMPILE_WITH_OBJ_LOADER_ #endif -//! Define _IRR_COMPILE_WITH_STL_LOADER_ if you want to load stereolithography files -#define _IRR_COMPILE_WITH_STL_LOADER_ -#ifdef NO_IRR_COMPILE_WITH_STL_LOADER_ -#undef _IRR_COMPILE_WITH_STL_LOADER_ -#endif -//! Define _IRR_COMPILE_WITH_STL_WRITER_ if you want to write .stl files -//#define _IRR_COMPILE_WITH_STL_WRITER_ -#ifdef NO_IRR_COMPILE_WITH_STL_WRITER_ -#undef _IRR_COMPILE_WITH_STL_WRITER_ -#endif //! Define _IRR_COMPILE_WITH_OBJ_WRITER_ if you want to write .obj files //#define _IRR_COMPILE_WITH_OBJ_WRITER_ #ifdef NO_IRR_COMPILE_WITH_OBJ_WRITER_ diff --git a/lib/irrlicht/source/Irrlicht/CSTLMeshFileLoader.cpp b/lib/irrlicht/source/Irrlicht/CSTLMeshFileLoader.cpp deleted file mode 100644 index bf9ffb309..000000000 --- a/lib/irrlicht/source/Irrlicht/CSTLMeshFileLoader.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (C) 2007-2012 Christian Stehno -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_STL_LOADER_ - -#include "CSTLMeshFileLoader.h" -#include "SMesh.h" -#include "SMeshBuffer.h" -#include "SAnimatedMesh.h" -#include "IReadFile.h" -#include "fast_atof.h" -#include "coreutil.h" -#include "os.h" - -namespace irr -{ -namespace scene -{ - - -//! returns true if the file maybe is able to be loaded by this class -//! based on the file extension (e.g. ".bsp") -bool CSTLMeshFileLoader::isALoadableFileExtension(const io::path& filename) const -{ - return core::hasFileExtension ( filename, "stl" ); -} - - - -//! creates/loads an animated mesh from the file. -//! \return Pointer to the created mesh. Returns 0 if loading failed. -//! If you no longer need the mesh, you should call IAnimatedMesh::drop(). -//! See IReferenceCounted::drop() for more information. -IAnimatedMesh* CSTLMeshFileLoader::createMesh(io::IReadFile* file) -{ - const long filesize = file->getSize(); - if (filesize < 6) // we need a header - return 0; - - SMesh* mesh = new SMesh(); - SMeshBuffer* meshBuffer = new SMeshBuffer(); - mesh->addMeshBuffer(meshBuffer); - meshBuffer->drop(); - - core::vector3df vertex[3]; - core::vector3df normal; - - bool binary = false; - core::stringc token; - if (getNextToken(file, token) != "solid") - binary = true; - // read/skip header - u32 binFaceCount = 0; - if (binary) - { - file->seek(80); - file->read(&binFaceCount, 4); -#ifdef __BIG_ENDIAN__ - binFaceCount = os::Byteswap::byteswap(binFaceCount); -#endif - } - else - goNextLine(file); - - u16 attrib=0; - token.reserve(32); - - while (file->getPos() < filesize) - { - if (!binary) - { - if (getNextToken(file, token) != "facet") - { - if (token=="endsolid") - break; - mesh->drop(); - return 0; - } - if (getNextToken(file, token) != "normal") - { - mesh->drop(); - return 0; - } - } - getNextVector(file, normal, binary); - if (!binary) - { - if (getNextToken(file, token) != "outer") - { - mesh->drop(); - return 0; - } - if (getNextToken(file, token) != "loop") - { - mesh->drop(); - return 0; - } - } - for (u32 i=0; i<3; ++i) - { - if (!binary) - { - if (getNextToken(file, token) != "vertex") - { - mesh->drop(); - return 0; - } - } - getNextVector(file, vertex[i], binary); - } - if (!binary) - { - if (getNextToken(file, token) != "endloop") - { - mesh->drop(); - return 0; - } - if (getNextToken(file, token) != "endfacet") - { - mesh->drop(); - return 0; - } - } - else - { - file->read(&attrib, 2); -#ifdef __BIG_ENDIAN__ - attrib = os::Byteswap::byteswap(attrib); -#endif - } - - SMeshBuffer* mb = reinterpret_cast(mesh->getMeshBuffer(mesh->getMeshBufferCount()-1)); - u32 vCount = mb->getVertexCount(); - video::SColor color(0xffffffff); - if (attrib & 0x8000) - color = video::A1R5G5B5toA8R8G8B8(attrib); - if (normal==core::vector3df()) - normal=core::plane3df(vertex[2],vertex[1],vertex[0]).Normal; - mb->Vertices.push_back(video::S3DVertex(vertex[2],normal,color, core::vector2df())); - mb->Vertices.push_back(video::S3DVertex(vertex[1],normal,color, core::vector2df())); - mb->Vertices.push_back(video::S3DVertex(vertex[0],normal,color, core::vector2df())); - mb->Indices.push_back(vCount); - mb->Indices.push_back(vCount+1); - mb->Indices.push_back(vCount+2); - } // end while (file->getPos() < filesize) - mesh->getMeshBuffer(0)->recalculateBoundingBox(); - - // Create the Animated mesh if there's anything in the mesh - SAnimatedMesh* pAM = 0; - if ( 0 != mesh->getMeshBufferCount() ) - { - mesh->recalculateBoundingBox(); - pAM = new SAnimatedMesh(); - pAM->Type = EAMT_OBJ; - pAM->addMesh(mesh); - pAM->recalculateBoundingBox(); - } - - mesh->drop(); - - return pAM; -} - - -//! Read 3d vector of floats -void CSTLMeshFileLoader::getNextVector(io::IReadFile* file, core::vector3df& vec, bool binary) const -{ - if (binary) - { - file->read(&vec.X, 4); - file->read(&vec.Y, 4); - file->read(&vec.Z, 4); -#ifdef __BIG_ENDIAN__ - vec.X = os::Byteswap::byteswap(vec.X); - vec.Y = os::Byteswap::byteswap(vec.Y); - vec.Z = os::Byteswap::byteswap(vec.Z); -#endif - } - else - { - goNextWord(file); - core::stringc tmp; - - getNextToken(file, tmp); - core::fast_atof_move(tmp.c_str(), vec.X); - getNextToken(file, tmp); - core::fast_atof_move(tmp.c_str(), vec.Y); - getNextToken(file, tmp); - core::fast_atof_move(tmp.c_str(), vec.Z); - } - vec.X=-vec.X; -} - - -//! Read next word -const core::stringc& CSTLMeshFileLoader::getNextToken(io::IReadFile* file, core::stringc& token) const -{ - goNextWord(file); - u8 c; - token = ""; - while(file->getPos() != file->getSize()) - { - file->read(&c, 1); - // found it, so leave - if (core::isspace(c)) - break; - token.append(c); - } - return token; -} - - -//! skip to next word -void CSTLMeshFileLoader::goNextWord(io::IReadFile* file) const -{ - u8 c; - while(file->getPos() != file->getSize()) - { - file->read(&c, 1); - // found it, so leave - if (!core::isspace(c)) - { - file->seek(-1, true); - break; - } - } -} - - -//! Read until line break is reached and stop at the next non-space character -void CSTLMeshFileLoader::goNextLine(io::IReadFile* file) const -{ - u8 c; - // look for newline characters - while(file->getPos() != file->getSize()) - { - file->read(&c, 1); - // found it, so leave - if (c=='\n' || c=='\r') - break; - } -} - - -} // end namespace scene -} // end namespace irr - - -#endif // _IRR_COMPILE_WITH_STL_LOADER_ - diff --git a/lib/irrlicht/source/Irrlicht/CSTLMeshFileLoader.h b/lib/irrlicht/source/Irrlicht/CSTLMeshFileLoader.h deleted file mode 100644 index fb5dc90f8..000000000 --- a/lib/irrlicht/source/Irrlicht/CSTLMeshFileLoader.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2007-2012 Christian Stehno -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __C_STL_MESH_FILE_LOADER_H_INCLUDED__ -#define __C_STL_MESH_FILE_LOADER_H_INCLUDED__ - -#include "IMeshLoader.h" -#include "irrString.h" -#include "vector3d.h" - -namespace irr -{ -namespace scene -{ - -//! Meshloader capable of loading STL meshes. -class CSTLMeshFileLoader : public IMeshLoader -{ -public: - - //! returns true if the file maybe is able to be loaded by this class - //! based on the file extension (i.e. ".stl") - virtual bool isALoadableFileExtension(const io::path& filename) const; - - //! creates/loads an animated mesh from the file. - //! \return Pointer to the created mesh. Returns 0 if loading failed. - //! If you no longer need the mesh, you should call IAnimatedMesh::drop(). - //! See IReferenceCounted::drop() for more information. - virtual IAnimatedMesh* createMesh(io::IReadFile* file); - -private: - - // skips to the first non-space character available - void goNextWord(io::IReadFile* file) const; - // returns the next word - const core::stringc& getNextToken(io::IReadFile* file, core::stringc& token) const; - // skip to next printable character after the first line break - void goNextLine(io::IReadFile* file) const; - - //! Read 3d vector of floats - void getNextVector(io::IReadFile* file, core::vector3df& vec, bool binary) const; -}; - -} // end namespace scene -} // end namespace irr - -#endif - diff --git a/lib/irrlicht/source/Irrlicht/CSTLMeshWriter.cpp b/lib/irrlicht/source/Irrlicht/CSTLMeshWriter.cpp deleted file mode 100644 index 998a73f72..000000000 --- a/lib/irrlicht/source/Irrlicht/CSTLMeshWriter.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright (C) 2002-2012 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#include "IrrCompileConfig.h" - -#ifdef _IRR_COMPILE_WITH_STL_WRITER_ - -#include "CSTLMeshWriter.h" -#include "os.h" -#include "IMesh.h" -#include "IMeshBuffer.h" -#include "IAttributes.h" -#include "ISceneManager.h" -#include "IMeshCache.h" -#include "IWriteFile.h" - -namespace irr -{ -namespace scene -{ - -CSTLMeshWriter::CSTLMeshWriter(scene::ISceneManager* smgr) - : SceneManager(smgr) -{ - #ifdef _DEBUG - setDebugName("CSTLMeshWriter"); - #endif - - if (SceneManager) - SceneManager->grab(); -} - - -CSTLMeshWriter::~CSTLMeshWriter() -{ - if (SceneManager) - SceneManager->drop(); -} - - -//! Returns the type of the mesh writer -EMESH_WRITER_TYPE CSTLMeshWriter::getType() const -{ - return EMWT_STL; -} - - -//! writes a mesh -bool CSTLMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags) -{ - if (!file) - return false; - - os::Printer::log("Writing mesh", file->getFileName()); - - if (flags & scene::EMWF_WRITE_COMPRESSED) - return writeMeshBinary(file, mesh, flags); - else - return writeMeshASCII(file, mesh, flags); -} - - -bool CSTLMeshWriter::writeMeshBinary(io::IWriteFile* file, scene::IMesh* mesh, s32 flags) -{ - // write STL MESH header - - file->write("binary ",7); - const core::stringc name(SceneManager->getMeshCache()->getMeshName(mesh)); - const s32 sizeleft = 73-name.size(); // 80 byte header - if (sizeleft<0) - file->write(name.c_str(),73); - else - { - char* buf = new char[80]; - memset(buf, 0, 80); - file->write(name.c_str(),name.size()); - file->write(buf,sizeleft); - delete [] buf; - } - u32 facenum = 0; - for (u32 j=0; jgetMeshBufferCount(); ++j) - facenum += mesh->getMeshBuffer(j)->getIndexCount()/3; - file->write(&facenum,4); - - // write mesh buffers - - for (u32 i=0; igetMeshBufferCount(); ++i) - { - IMeshBuffer* buffer = mesh->getMeshBuffer(i); - if (buffer) - { - const u32 indexCount = buffer->getIndexCount(); - const u16 attributes = 0; - for (u32 j=0; jgetPosition(buffer->getIndices()[j]); - const core::vector3df& v2 = buffer->getPosition(buffer->getIndices()[j+1]); - const core::vector3df& v3 = buffer->getPosition(buffer->getIndices()[j+2]); - const core::plane3df tmpplane(v1,v2,v3); - file->write(&tmpplane.Normal, 12); - file->write(&v1, 12); - file->write(&v2, 12); - file->write(&v3, 12); - file->write(&attributes, 2); - } - } - } - return true; -} - - -bool CSTLMeshWriter::writeMeshASCII(io::IWriteFile* file, scene::IMesh* mesh, s32 flags) -{ - // write STL MESH header - - file->write("solid ",6); - const core::stringc name(SceneManager->getMeshCache()->getMeshName(mesh)); - file->write(name.c_str(),name.size()); - file->write("\n\n",2); - - // write mesh buffers - - for (u32 i=0; igetMeshBufferCount(); ++i) - { - IMeshBuffer* buffer = mesh->getMeshBuffer(i); - if (buffer) - { - const u32 indexCount = buffer->getIndexCount(); - for (u32 j=0; jgetPosition(buffer->getIndices()[j]), - buffer->getPosition(buffer->getIndices()[j+1]), - buffer->getPosition(buffer->getIndices()[j+2])); - } - file->write("\n",1); - } - } - - file->write("endsolid ",9); - file->write(name.c_str(),name.size()); - - return true; -} - - -void CSTLMeshWriter::getVectorAsStringLine(const core::vector3df& v, core::stringc& s) const -{ - s = core::stringc(v.X); - s += " "; - s += core::stringc(v.Y); - s += " "; - s += core::stringc(v.Z); - s += "\n"; -} - - -void CSTLMeshWriter::writeFace(io::IWriteFile* file, - const core::vector3df& v1, - const core::vector3df& v2, - const core::vector3df& v3) -{ - core::stringc tmp; - file->write("facet normal ",13); - getVectorAsStringLine(core::plane3df(v1,v2,v3).Normal, tmp); - file->write(tmp.c_str(),tmp.size()); - file->write(" outer loop\n",13); - file->write(" vertex ",11); - getVectorAsStringLine(v1, tmp); - file->write(tmp.c_str(),tmp.size()); - file->write(" vertex ",11); - getVectorAsStringLine(v2, tmp); - file->write(tmp.c_str(),tmp.size()); - file->write(" vertex ",11); - getVectorAsStringLine(v3, tmp); - file->write(tmp.c_str(),tmp.size()); - file->write(" endloop\n",10); - file->write("endfacet\n",9); -} - - -} // end namespace -} // end namespace - -#endif - diff --git a/lib/irrlicht/source/Irrlicht/CSTLMeshWriter.h b/lib/irrlicht/source/Irrlicht/CSTLMeshWriter.h deleted file mode 100644 index 0b0b76d44..000000000 --- a/lib/irrlicht/source/Irrlicht/CSTLMeshWriter.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2002-2012 Nikolaus Gebhardt -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_STL_MESH_WRITER_H_INCLUDED__ -#define __IRR_STL_MESH_WRITER_H_INCLUDED__ - -#include "IMeshWriter.h" -#include "S3DVertex.h" -#include "irrString.h" - -namespace irr -{ -namespace scene -{ - class IMeshBuffer; - class ISceneManager; - - //! class to write meshes, implementing a STL writer - class CSTLMeshWriter : public IMeshWriter - { - public: - - CSTLMeshWriter(scene::ISceneManager* smgr); - virtual ~CSTLMeshWriter(); - - //! Returns the type of the mesh writer - virtual EMESH_WRITER_TYPE getType() const; - - //! writes a mesh - virtual bool writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags=EMWF_NONE); - - protected: - // write binary format - bool writeMeshBinary(io::IWriteFile* file, scene::IMesh* mesh, s32 flags); - - // write text format - bool writeMeshASCII(io::IWriteFile* file, scene::IMesh* mesh, s32 flags); - - // create vector output with line end into string - void getVectorAsStringLine(const core::vector3df& v, - core::stringc& s) const; - - // write face information to file - void writeFace(io::IWriteFile* file, const core::vector3df& v1, - const core::vector3df& v2, const core::vector3df& v3); - - scene::ISceneManager* SceneManager; - }; - -} // end namespace -} // end namespace - -#endif - diff --git a/lib/irrlicht/source/Irrlicht/CSceneManager.cpp b/lib/irrlicht/source/Irrlicht/CSceneManager.cpp index 0a9aa6c0e..c1d7062a6 100644 --- a/lib/irrlicht/source/Irrlicht/CSceneManager.cpp +++ b/lib/irrlicht/source/Irrlicht/CSceneManager.cpp @@ -68,10 +68,6 @@ #include "CB3DMeshFileLoader.h" #endif -#ifdef _IRR_COMPILE_WITH_STL_LOADER_ -#include "CSTLMeshFileLoader.h" -#endif - #ifdef _IRR_COMPILE_WITH_IRR_SCENE_LOADER_ #include "CSceneLoaderIrr.h" #endif @@ -197,9 +193,6 @@ CSceneManager::CSceneManager(video::IVideoDriver* driver, io::IFileSystem* fs, // TODO: now that we have multiple scene managers, these should be // shallow copies from the previous manager if there is one. - #ifdef _IRR_COMPILE_WITH_STL_LOADER_ - MeshLoaderList.push_back(new CSTLMeshFileLoader()); - #endif #ifdef _IRR_COMPILE_WITH_OGRE_LOADER_ MeshLoaderList.push_back(new COgreMeshFileLoader(FileSystem, Driver)); #endif