From 9ddd459fe88d67cff7b57c30dde4921306c091b3 Mon Sep 17 00:00:00 2001 From: Madrich Date: Sat, 31 May 2014 12:50:07 +0200 Subject: [PATCH 1/8] Extend Collada Exporter using lines and triangles --- code/ColladaExporter.cpp | 95 ++++++++++++++++++++++++++++++++-------- 1 file changed, 76 insertions(+), 19 deletions(-) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index cb392acf0..6cfef2246 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -420,12 +420,12 @@ void ColladaExporter::WriteMaterials() aiString name; if( mat->Get( AI_MATKEY_NAME, name) != aiReturn_SUCCESS ) - name = "mat"; + name = "mat"; materials[a].name = std::string( "m") + boost::lexical_cast (a) + name.C_Str(); for( std::string::iterator it = materials[a].name.begin(); it != materials[a].name.end(); ++it ) { // isalnum on MSVC asserts for code points in [0,255]. Thus prevent unwanted promotion // of char to signed int and take the unsigned char value. - if( !isalnum( static_cast(*it) ) ) { + if( !isalnum( static_cast(*it) ) ) { *it = '_'; } } @@ -630,26 +630,83 @@ void ColladaExporter::WriteGeometry( size_t pIndex) PopTag(); mOutput << startstr << "" << endstr; - // write face setup - mOutput << startstr << "mNumFaces << "\" material=\"theresonlyone\">" << endstr; - PushTag(); - mOutput << startstr << "" << endstr; - - mOutput << startstr << ""; - for( size_t a = 0; a < mesh->mNumFaces; ++a ) - mOutput << mesh->mFaces[a].mNumIndices << " "; - mOutput << "" << endstr; - - mOutput << startstr << "

"; + // count the number of lines, triangles and polygon meshes + int countLines = 0; + int countTriangles = 0; + int countPoly = 0; for( size_t a = 0; a < mesh->mNumFaces; ++a ) { - const aiFace& face = mesh->mFaces[a]; - for( size_t b = 0; b < face.mNumIndices; ++b ) - mOutput << face.mIndices[b] << " "; + if (mesh->mFaces[a].mNumIndices == 2) countLines++; + else if (mesh->mFaces[a].mNumIndices == 3) countTriangles++; + else if (mesh->mFaces[a].mNumIndices > 3) countPoly++; + } + + // lines + if (countLines) + { + mOutput << startstr << "" << endstr; + PushTag(); + mOutput << startstr << "" << endstr; + mOutput << startstr << "

"; + for( size_t a = 0; a < mesh->mNumFaces; ++a ) + { + const aiFace& face = mesh->mFaces[a]; + if (face.mNumIndices != 2) continue; + for( size_t b = 0; b < face.mNumIndices; ++b ) + mOutput << face.mIndices[b] << " "; + } + mOutput << "

" << endstr; + PopTag(); + mOutput << startstr << "" << endstr; + } + + // triangles + if (countTriangles) + { + mOutput << startstr << "" << endstr; + PushTag(); + mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; + mOutput << startstr << "

"; + for( size_t a = 0; a < mesh->mNumFaces; ++a ) + { + const aiFace& face = mesh->mFaces[a]; + if (face.mNumIndices != 3) continue; + for( size_t b = 0; b < face.mNumIndices; ++b ) + mOutput << face.mIndices[b] << " "; + } + mOutput << "

" << endstr; + PopTag(); + mOutput << startstr << "
" << endstr; + } + + // polygons + if (countPoly) + { + mOutput << startstr << "" << endstr; + PushTag(); + mOutput << startstr << "" << endstr; + + mOutput << startstr << ""; + for( size_t a = 0; a < mesh->mNumFaces; ++a ) + { + if (mesh->mFaces[a].mNumIndices <= 3) continue; + mOutput << mesh->mFaces[a].mNumIndices << " "; + } + mOutput << "" << endstr; + + mOutput << startstr << "

"; + for( size_t a = 0; a < mesh->mNumFaces; ++a ) + { + const aiFace& face = mesh->mFaces[a]; + if (face.mNumIndices <= 3) continue; + for( size_t b = 0; b < face.mNumIndices; ++b ) + mOutput << face.mIndices[b] << " "; + } + mOutput << "

" << endstr; + PopTag(); + mOutput << startstr << "
" << endstr; } - mOutput << "

" << endstr; - PopTag(); - mOutput << startstr << "
" << endstr; // closing tags PopTag(); From ec2ce906544ce99ec0153eb8f697b43b3bdc84f7 Mon Sep 17 00:00:00 2001 From: Madrich Date: Fri, 6 Jun 2014 01:56:54 +0200 Subject: [PATCH 2/8] Add Scene Author + AuthorTool Add XFileExporter Add Collada Triangle+Line export Fix Obj Comment --- code/AssimpPCH.cpp | 2 + code/CMakeLists.txt | 4 +- code/ColladaExporter.cpp | 7 +- code/Exporter.cpp | 5 + code/ObjExporter.h | 2 +- code/XFileExporter.cpp | 454 +++++++++++++++++++++++++++++++++++++++ code/XFileExporter.h | 120 +++++++++++ include/assimp/scene.h | 9 + 8 files changed, 598 insertions(+), 5 deletions(-) create mode 100644 code/XFileExporter.cpp create mode 100644 code/XFileExporter.h diff --git a/code/AssimpPCH.cpp b/code/AssimpPCH.cpp index 62df955de..2d74e3b00 100644 --- a/code/AssimpPCH.cpp +++ b/code/AssimpPCH.cpp @@ -88,6 +88,8 @@ ASSIMP_API aiScene::aiScene() , mNumCameras(0) , mCameras(NULL) , mPrivate(new Assimp::ScenePrivateData()) + , author("Assimp") + , authoringTool("Assimp Importer/Exporter") { } diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index f9a09378e..0533a05fd 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -187,7 +187,7 @@ SET( Collada_SRCS ColladaParser.cpp ColladaParser.h ColladaExporter.h - ColladaExporter.cpp + ColladaExporter.cpp ) SOURCE_GROUP( Collada FILES ${Collada_SRCS}) @@ -543,6 +543,8 @@ SET( XFile_SRCS XFileImporter.h XFileParser.cpp XFileParser.h + XFileExporter.h + XFileExporter.cpp ) SOURCE_GROUP( XFile FILES ${XFile_SRCS}) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 6cfef2246..6a016e331 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -151,7 +151,7 @@ void ColladaExporter::WriteFile() // Writes the asset header void ColladaExporter::WriteHeader() { - static const float epsilon = 0.000001f; + static const float epsilon = 0.00001f; static const aiQuaternion x_rot(aiMatrix3x3( 0, -1, 0, 1, 0, 0, @@ -176,6 +176,7 @@ void ColladaExporter::WriteHeader() aiQuaternion rotation; aiVector3D position; mScene->mRootNode->mTransformation.Decompose(scaling, rotation, position); + rotation.Normalize(); bool add_root_node = false; @@ -229,8 +230,8 @@ void ColladaExporter::WriteHeader() PushTag(); mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "Assimp" << endstr; - mOutput << startstr << "Assimp Collada Exporter" << endstr; + mOutput << startstr << "" << mScene->author.C_Str() << "" << endstr; + mOutput << startstr << "" << mScene->authoringTool.C_Str() << "" << endstr; PopTag(); mOutput << startstr << "" << endstr; mOutput << startstr << "" << date_str << "" << endstr; diff --git a/code/Exporter.cpp b/code/Exporter.cpp index a693f75e2..22db17659 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -72,6 +72,7 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out); // ------------------------------------------------------------------------------------------------ // Exporter worker function prototypes. Should not be necessary to #ifndef them, it's just a prototype void ExportSceneCollada(const char*,IOSystem*, const aiScene*); +void ExportSceneXFile(const char*,IOSystem*, const aiScene*); void ExportSceneObj(const char*,IOSystem*, const aiScene*); void ExportSceneSTL(const char*,IOSystem*, const aiScene*); void ExportSceneSTLBinary(const char*,IOSystem*, const aiScene*); @@ -86,6 +87,10 @@ Exporter::ExportFormatEntry gExporters[] = Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada), #endif +#ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER + Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile), +#endif + #ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER Exporter::ExportFormatEntry( "obj", "Wavefront OBJ format", "obj", &ExportSceneObj, aiProcess_GenSmoothNormals /*| aiProcess_PreTransformVertices */), diff --git a/code/ObjExporter.h b/code/ObjExporter.h index 4f6555aa5..e1ec7a9a6 100644 --- a/code/ObjExporter.h +++ b/code/ObjExporter.h @@ -38,7 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------- */ -/** @file ColladaExporter.h +/** @file ObjExporter.h * Declares the exporter class to write a scene to a Collada file */ #ifndef AI_OBJEXPORTER_H_INC diff --git a/code/XFileExporter.cpp b/code/XFileExporter.cpp new file mode 100644 index 000000000..2f14dbbe4 --- /dev/null +++ b/code/XFileExporter.cpp @@ -0,0 +1,454 @@ +/* +Open Asset Import Library (assimp) +---------------------------------------------------------------------- + +Copyright (c) 2006-2012, assimp team +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +@author: Richard Steffen, 2014 +---------------------------------------------------------------------- +*/ + +#include "AssimpPCH.h" + +#ifndef ASSIMP_BUILD_NO_EXPORT +#ifndef ASSIMP_BUILD_NO_XFILE_EXPORTER +#include "XFileExporter.h" + +#include "Bitmap.h" +#include "fast_atof.h" +#include "SceneCombiner.h" + +#include +#include + +using namespace Assimp; + +namespace Assimp +{ + +// ------------------------------------------------------------------------------------------------ +// Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp +void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) +{ + std::string path = ""; + std::string file = pFile; + + // We need to test both types of folder separators because pIOSystem->getOsSeparator() is not reliable. + // Moreover, the path given by some applications is not even consistent with the OS specific type of separator. + const char* end_path = std::max(strrchr(pFile, '\\'), strrchr(pFile, '/')); + + if(end_path != NULL) { + path = std::string(pFile, end_path + 1 - pFile); + file = file.substr(end_path + 1 - pFile, file.npos); + + std::size_t pos = file.find_last_of('.'); + if(pos != file.npos) { + file = file.substr(0, pos); + } + } + + // invoke the exporter + XFileExporter iDoTheExportThing( pScene, pIOSystem, path, file); + + // we're still here - export successfully completed. Write result to the given IOSYstem + boost::scoped_ptr outfile (pIOSystem->Open(pFile,"wt")); + if(outfile == NULL) { + throw DeadlyExportError("could not open output .dae file: " + std::string(pFile)); + } + + // XXX maybe use a small wrapper around IOStream that behaves like std::stringstream in order to avoid the extra copy. + outfile->Write( iDoTheExportThing.mOutput.str().c_str(), static_cast(iDoTheExportThing.mOutput.tellp()),1); +} + +} // end of namespace Assimp + + +// ------------------------------------------------------------------------------------------------ +// Constructor for a specific scene to export +XFileExporter::XFileExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file) : mIOSystem(pIOSystem), mPath(path), mFile(file) +{ + // make sure that all formatting happens using the standard, C locale and not the user's current locale + mOutput.imbue( std::locale("C") ); + + mScene = pScene; + mSceneOwned = false; + + // set up strings + endstr = "\n"; + + // start writing + WriteFile(); +} + +// ------------------------------------------------------------------------------------------------ +// Destructor +XFileExporter::~XFileExporter() +{ + if(mSceneOwned) { + delete mScene; + } +} + +// ------------------------------------------------------------------------------------------------ +// Starts writing the contents +void XFileExporter::WriteFile() +{ + // note, that all realnumber values must be comma separated in x files + mOutput.setf(_IOSfixed); + mOutput.precision(6); // precission for float + + // entry of writing the file + WriteHeader(); + + mOutput << startstr << "Frame DXCC_ROOT {" << endstr; + PushTag(); + + aiMatrix4x4 I; // identity + WriteFrameTransform(I); + + WriteNode(mScene->mRootNode); + PopTag(); + + mOutput << startstr << "}" << endstr; +} + +// ------------------------------------------------------------------------------------------------ +// Writes the asset header +void XFileExporter::WriteHeader() +{ + mOutput << startstr << "xof 0303txt 0032" << endstr; + mOutput << endstr; + mOutput << startstr << "template Frame {" << endstr; + PushTag(); + mOutput << startstr << "<3d82ab46-62da-11cf-ab39-0020af71e433>" << endstr; + mOutput << startstr << "[...]" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template Matrix4x4 {" << endstr; + PushTag(); + mOutput << startstr << "" << endstr; + mOutput << startstr << "array FLOAT matrix[16];" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template FrameTransformMatrix {" << endstr; + PushTag(); + mOutput << startstr << "" << endstr; + mOutput << startstr << "Matrix4x4 frameMatrix;" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template Vector {" << endstr; + PushTag(); + mOutput << startstr << "<3d82ab5e-62da-11cf-ab39-0020af71e433>" << endstr; + mOutput << startstr << "FLOAT x;" << endstr; + mOutput << startstr << "FLOAT y;" << endstr; + mOutput << startstr << "FLOAT z;" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template MeshFace {" << endstr; + PushTag(); + mOutput << startstr << "<3d82ab5f-62da-11cf-ab39-0020af71e433>" << endstr; + mOutput << startstr << "DWORD nFaceVertexIndices;" << endstr; + mOutput << startstr << "array DWORD faceVertexIndices[nFaceVertexIndices];" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template Mesh {" << endstr; + PushTag(); + mOutput << startstr << "<3d82ab44-62da-11cf-ab39-0020af71e433>" << endstr; + mOutput << startstr << "DWORD nVertices;" << endstr; + mOutput << startstr << "array Vector vertices[nVertices];" << endstr; + mOutput << startstr << "DWORD nFaces;" << endstr; + mOutput << startstr << "array MeshFace faces[nFaces];" << endstr; + mOutput << startstr << "[...]" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template MeshNormals {" << endstr; + PushTag(); + mOutput << startstr << "" << endstr; + mOutput << startstr << "DWORD nNormals;" << endstr; + mOutput << startstr << "array Vector normals[nNormals];" << endstr; + mOutput << startstr << "DWORD nFaceNormals;" << endstr; + mOutput << startstr << "array MeshFace faceNormals[nFaceNormals];" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template Coords2d {" << endstr; + PushTag(); + mOutput << startstr << "" << endstr; + mOutput << startstr << "FLOAT u;" << endstr; + mOutput << startstr << "FLOAT v;" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template MeshTextureCoords {" << endstr; + PushTag(); + mOutput << startstr << "" << endstr; + mOutput << startstr << "DWORD nTextureCoords;" << endstr; + mOutput << startstr << "array Coords2d textureCoords[nTextureCoords];" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template ColorRGBA {" << endstr; + PushTag(); + mOutput << startstr << "<35ff44e0-6c7c-11cf-8f52-0040333594a3>" << endstr; + mOutput << startstr << "FLOAT red;" << endstr; + mOutput << startstr << "FLOAT green;" << endstr; + mOutput << startstr << "FLOAT blue;" << endstr; + mOutput << startstr << "FLOAT alpha;" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template IndexedColor {" << endstr; + PushTag(); + mOutput << startstr << "<1630b820-7842-11cf-8f52-0040333594a3>" << endstr; + mOutput << startstr << "DWORD index;" << endstr; + mOutput << startstr << "ColorRGBA indexColor;" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template MeshVertexColors {" << endstr; + PushTag(); + mOutput << startstr << "<1630b821-7842-11cf-8f52-0040333594a3>" << endstr; + mOutput << startstr << "DWORD nVertexColors;" << endstr; + mOutput << startstr << "array IndexedColor vertexColors[nVertexColors];" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template VertexElement {" << endstr; + PushTag(); + mOutput << startstr << "" << endstr; + mOutput << startstr << "DWORD Type;" << endstr; + mOutput << startstr << "DWORD Method;" << endstr; + mOutput << startstr << "DWORD Usage;" << endstr; + mOutput << startstr << "DWORD UsageIndex;" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; + mOutput << startstr << "template DeclData {" << endstr; + PushTag(); + mOutput << startstr << "" << endstr; + mOutput << startstr << "DWORD nElements;" << endstr; + mOutput << startstr << "array VertexElement Elements[nElements];" << endstr; + mOutput << startstr << "DWORD nDWords;" << endstr; + mOutput << startstr << "array DWORD data[nDWords];" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + mOutput << endstr; +} + + +// Writes the material setup +void XFileExporter::WriteFrameTransform(aiMatrix4x4& m) +{ + mOutput << startstr << "FrameTransformMatrix {" << endstr << " "; + PushTag(); + mOutput << startstr << m.a1 << "," << m.a2 << "," << m.a3 << "," << m.a4 << "," + << m.b1 << "," << m.b2 << "," << m.b3 << "," << m.b4 << "," + << m.c1 << "," << m.c2 << "," << m.c3 << "," << m.c4 << "," + << m.d1 << "," << m.d2 << "," << m.d3 << "," << m.d4 << ";;" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr << endstr; +} + + +// ------------------------------------------------------------------------------------------------ +// Recursively writes the given node +void XFileExporter::WriteNode( const aiNode* pNode) +{ + mOutput << startstr << "Frame " << pNode->mName.C_Str() << " {" << endstr; + + PushTag(); + + aiMatrix4x4 m;// = pNode->mTransformation; + + WriteFrameTransform(m); + + for (size_t i = 0; i < pNode->mNumMeshes; i++) + WriteMesh(mScene->mMeshes[pNode->mMeshes[i]]); + + // recursive call the Nodes + for (size_t a = 0; a < pNode->mNumChildren; a++) + WriteNode( mScene->mRootNode->mChildren[a]); + + PopTag(); + + mOutput << startstr << "}" << endstr << endstr; +} + +void XFileExporter::WriteMesh(const aiMesh* mesh) +{ + mOutput << startstr << "Mesh " << mesh->mName.C_Str() << "_mShape" << " {" << endstr; + + PushTag(); + + // write all the vertices + mOutput << startstr << mesh->mNumVertices << ";" << endstr; + for (size_t a = 0; a < mesh->mNumVertices; a++) + { + aiVector3D &v = mesh->mVertices[a]; + mOutput << startstr << v[0] << ";"<< v[1] << ";" << v[2] << ";"; + if (a < mesh->mNumVertices - 1) + mOutput << "," << endstr; + else + mOutput << ";" << endstr; + } + + // write all the faces + mOutput << startstr << mesh->mNumFaces << ";" << endstr; + for( size_t a = 0; a < mesh->mNumFaces; ++a ) + { + const aiFace& face = mesh->mFaces[a]; + mOutput << startstr << face.mNumIndices << ";"; + // must be counter clockwise triangle + //for(int b = face.mNumIndices - 1; b >= 0 ; --b) + for(size_t b = 0; b < face.mNumIndices ; ++b) + { + mOutput << face.mIndices[b]; + //if (b > 0) + if (bmNumFaces - 1) + mOutput << "," << endstr; + else + mOutput << ";" << endstr; + } + + // write normals (every vertex has one) + mOutput << endstr; + if (mesh->HasNormals()) + { + mOutput << startstr << "MeshNormals {" << endstr; + mOutput << startstr << mesh->mNumVertices << ";" << endstr; + for (size_t a = 0; a < mesh->mNumVertices; a++) + { + aiVector3D &v = mesh->mNormals[a]; + mOutput << startstr << v[0] << ";"<< v[1] << ";" << v[2] << ";"; + if (a < mesh->mNumVertices - 1) + mOutput << "," << endstr; + else + mOutput << ";" << endstr; + } + + mOutput << startstr << mesh->mNumFaces << ";" << endstr; + for (size_t a = 0; a < mesh->mNumFaces; a++) + { + const aiFace& face = mesh->mFaces[a]; + mOutput << startstr << face.mNumIndices << ";"; + + //for(int b = face.mNumIndices-1; b >= 0 ; --b) + for(size_t b = 0; b < face.mNumIndices ; ++b) + { + mOutput << face.mIndices[b]; + //if (b > 0) + if (bmNumFaces-1) + mOutput << "," << endstr; + else + mOutput << ";" << endstr; + } + mOutput << startstr << "}" << endstr; + } + + // write texture UVs if available + if (mesh->HasTextureCoords(0)) + { + mOutput << startstr << "MeshTextureCoords {" << endstr; + mOutput << startstr << mesh->mNumVertices << ";" << endstr; + for (size_t a = 0; a < mesh->mNumVertices; a++) + { + aiVector3D& uv = mesh->mTextureCoords[0][a]; // uv of first uv layer for the vertex + mOutput << uv.x << ";" << uv.y; + if (a < mesh->mNumVertices-1) + mOutput << ";," << endstr; + else + mOutput << ";;" << endstr; + } + mOutput << startstr << "}" << endstr; + } + + // write color channel if available + if (mesh->HasVertexColors(0)) + { + mOutput << startstr << "MeshVertexColors {" << endstr; + mOutput << startstr << mesh->mNumVertices << ";" << endstr; + for (size_t a = 0; a < mesh->mNumVertices; a++) + { + aiColor4D& mColors = mesh->mColors[0][a]; // color of first vertex color set for the vertex + mOutput << startstr << a << ";" << mColors.r << ";" << mColors.g << ";" << mColors.b << ";" << mColors.a << ";;"; + if (a < mesh->mNumVertices-1) + mOutput << "," << endstr; + else + mOutput << ";" << endstr; + } + mOutput << startstr << "}" << endstr; + } + // test ... + else + { + mOutput << startstr << "MeshVertexColors {" << endstr; + mOutput << startstr << mesh->mNumVertices << ";" << endstr; + for (size_t a = 0; a < mesh->mNumVertices; a++) + { + aiColor4D* mColors = mesh->mColors[a]; + mOutput << startstr << a << ";0.500000;0.000000;0.000000;0.000000;;"; + if (a < mesh->mNumVertices-1) + mOutput << "," << endstr; + else + mOutput << ";" << endstr; + } + mOutput << startstr << "}" << endstr; + } + + PopTag(); + mOutput << startstr << "}" << endstr << endstr; + +} + +#endif +#endif + diff --git a/code/XFileExporter.h b/code/XFileExporter.h new file mode 100644 index 000000000..39660530e --- /dev/null +++ b/code/XFileExporter.h @@ -0,0 +1,120 @@ +/* +Open Asset Import Library (assimp) +---------------------------------------------------------------------- + +Copyright (c) 2006-2012, assimp team +All rights reserved. + +Redistribution and use of this software in source and binary forms, +with or without modification, are permitted provided that the +following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of the assimp team, nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of the assimp team. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +@author: Richard Steffen, 2014 + +---------------------------------------------------------------------- +*/ + +/** @file XFileExporter.h + * Declares the exporter class to write a scene to a Collada file + */ +#ifndef AI_XFILEEXPORTER_H_INC +#define AI_XFILEEXPORTER_H_INC + +#include "../include/assimp/ai_assert.h" +#include + +struct aiScene; +struct aiNode; + +namespace Assimp +{ + +/// Helper class to export a given scene to a Collada file. Just for my personal +/// comfort when implementing it. +class XFileExporter +{ +public: + /// Constructor for a specific scene to export + XFileExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file); + + /// Destructor + virtual ~XFileExporter(); + +protected: + /// Starts writing the contents + void WriteFile(); + + /// Writes the asset header + void WriteHeader(); + + /// write a frame transform + void WriteFrameTransform(aiMatrix4x4& m); + + /// Recursively writes the given node + void WriteNode( const aiNode* pNode); + + /// write a mesh entry of the scene + void WriteMesh(const aiMesh* mesh); + + /// Enters a new xml element, which increases the indentation + void PushTag() { startstr.append( " "); } + + /// Leaves an element, decreasing the indentation + void PopTag() { ai_assert( startstr.length() > 1); startstr.erase( startstr.length() - 2); } + +public: + /// Stringstream to write all output into + std::stringstream mOutput; + +protected: + /// The IOSystem for output + IOSystem* mIOSystem; + + /// Path of the directory where the scene will be exported + const std::string mPath; + + /// Name of the file (without extension) where the scene will be exported + const std::string mFile; + + /// The scene to be written + const aiScene* mScene; + bool mSceneOwned; + + /// current line start string, contains the current indentation for simple stream insertion + std::string startstr; + /// current line end string for simple stream insertion + std::string endstr; + +protected: + +}; + +} + +#endif // !! AI_XFILEEXPORTER_H_INC diff --git a/include/assimp/scene.h b/include/assimp/scene.h index 87f13152f..f40323126 100644 --- a/include/assimp/scene.h +++ b/include/assimp/scene.h @@ -375,6 +375,15 @@ struct aiScene */ C_STRUCT aiCamera** mCameras; + + /** a string representing the author + */ + aiString author; + + /** a string representing the authoringtool + */ + aiString authoringTool; + #ifdef __cplusplus //! Default constructor - set everything to 0/NULL From 77cec96d740106a317c4327bd20f0acb2b0c6254 Mon Sep 17 00:00:00 2001 From: Madrich Date: Sat, 7 Jun 2014 21:17:31 +0200 Subject: [PATCH 3/8] Fix collada --- code/ColladaExporter.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 6a016e331..f753124e3 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -354,7 +354,8 @@ void ColladaExporter::WriteTextureColorEntry( const Surface& pSurface, const std if( pSurface.texture.empty() ) { mOutput << startstr << "" << pSurface.color.r << " " << pSurface.color.g << " " << pSurface.color.b << " " << pSurface.color.a << "" << endstr; - } else + } + else { mOutput << startstr << "" << endstr; } @@ -673,8 +674,17 @@ void ColladaExporter::WriteGeometry( size_t pIndex) { const aiFace& face = mesh->mFaces[a]; if (face.mNumIndices != 3) continue; + // write vertix indices for( size_t b = 0; b < face.mNumIndices; ++b ) + { mOutput << face.mIndices[b] << " "; + } + // write normal indices + for( size_t b = 0; b < face.mNumIndices; ++b ) + { + mOutput << face.mIndices[b] << " "; + } + } mOutput << "

" << endstr; PopTag(); From c4021fbaafff951fab9258e6bf834ba77a565839 Mon Sep 17 00:00:00 2001 From: Madrich Date: Mon, 9 Jun 2014 15:17:45 +0200 Subject: [PATCH 4/8] Fix Collada export validated by Schema --- code/AssimpPCH.cpp | 2 +- code/ColladaExporter.cpp | 24 ++++++++++++++++-------- code/ColladaExporter.h | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/code/AssimpPCH.cpp b/code/AssimpPCH.cpp index 2d74e3b00..2ee9e4b95 100644 --- a/code/AssimpPCH.cpp +++ b/code/AssimpPCH.cpp @@ -89,7 +89,7 @@ ASSIMP_API aiScene::aiScene() , mCameras(NULL) , mPrivate(new Assimp::ScenePrivateData()) , author("Assimp") - , authoringTool("Assimp Importer/Exporter") + , authoringTool("Assimp Importer-Exporter") { } diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index f753124e3..da208c27b 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -124,7 +124,7 @@ ColladaExporter::~ColladaExporter() void ColladaExporter::WriteFile() { // write the DTD - mOutput << "" << endstr; + mOutput << "" << endstr; // COLLADA element start mOutput << "" << endstr; PushTag(); @@ -646,7 +646,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) // lines if (countLines) { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "" << endstr; mOutput << startstr << "

"; @@ -662,13 +662,13 @@ void ColladaExporter::WriteGeometry( size_t pIndex) mOutput << startstr << "" << endstr; } - // triangles + // triangles, note for collada, triangles are defined in a right hand system if (countTriangles) { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "" << endstr; - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; mOutput << startstr << "

"; for( size_t a = 0; a < mesh->mNumFaces; ++a ) { @@ -694,7 +694,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) // polygons if (countPoly) { - mOutput << startstr << "" << endstr; + mOutput << startstr << "" << endstr; PushTag(); mOutput << startstr << "" << endstr; @@ -838,8 +838,16 @@ void ColladaExporter::WriteSceneLibrary() // ------------------------------------------------------------------------------------------------ // Recursively writes the given node -void ColladaExporter::WriteNode( const aiNode* pNode) +void ColladaExporter::WriteNode(aiNode* pNode) { + // the must have a name + if (pNode->mName.length == 0) + { + std::stringstream ss; + ss << "Node_" << pNode; + pNode->mName.Set(ss.str()); + } + mOutput << startstr << "mName.data << "\" name=\"" << pNode->mName.data << "\">" << endstr; PushTag(); @@ -867,7 +875,7 @@ void ColladaExporter::WriteNode( const aiNode* pNode) PushTag(); mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "mMaterialIndex].name << "\" />" << endstr; + mOutput << startstr << "mMaterialIndex].name << "\" />" << endstr; PopTag(); mOutput << startstr << "" << endstr; PopTag(); diff --git a/code/ColladaExporter.h b/code/ColladaExporter.h index f96671c40..47b8405e0 100644 --- a/code/ColladaExporter.h +++ b/code/ColladaExporter.h @@ -92,7 +92,7 @@ protected: void WriteSceneLibrary(); /// Recursively writes the given node - void WriteNode( const aiNode* pNode); + void WriteNode( aiNode* pNode); /// Enters a new xml element, which increases the indentation void PushTag() { startstr.append( " "); } From 272a59cd3617c48d3e3c22152e13cdfaa5fc0a32 Mon Sep 17 00:00:00 2001 From: Madrich Date: Tue, 10 Jun 2014 13:14:41 +0200 Subject: [PATCH 5/8] Fix convertToLH for uv coordinates Fix Collada export Fix XFile export --- code/ColladaExporter.cpp | 2 +- code/ConvertToLHProcess.cpp | 12 ++++- code/Exporter.cpp | 15 ++++--- code/ObjExporter.cpp | 2 +- code/PlyExporter.cpp | 2 +- code/STLExporter.cpp | 4 +- code/XFileExporter.cpp | 89 ++++++++++++++++++++++++++++++++----- code/XFileExporter.h | 13 ++++-- include/assimp/Exporter.hpp | 2 +- 9 files changed, 112 insertions(+), 29 deletions(-) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index da208c27b..3a1c096bf 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -58,7 +58,7 @@ namespace Assimp // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp -void ExportSceneCollada(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) +void ExportSceneCollada(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) { std::string path = ""; std::string file = pFile; diff --git a/code/ConvertToLHProcess.cpp b/code/ConvertToLHProcess.cpp index cc9141306..17e157c45 100644 --- a/code/ConvertToLHProcess.cpp +++ b/code/ConvertToLHProcess.cpp @@ -134,12 +134,22 @@ void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) { pMesh->mVertices[a].z *= -1.0f; if( pMesh->HasNormals()) - pMesh->mNormals[a].z *= -1.0f; + pMesh->mNormals[a].z *= -1.0f; if( pMesh->HasTangentsAndBitangents()) { pMesh->mTangents[a].z *= -1.0f; pMesh->mBitangents[a].z *= -1.0f; } + + // texture coords for all channels + for (unsigned int c = 0; c < pMesh->GetNumUVChannels(); c++) + { + if (pMesh->HasTextureCoords(c)) + { + pMesh->mTextureCoords[c][a].y = 1.0f - pMesh->mTextureCoords[c][a].y; + } + } + } // mirror offset matrices of all bones diff --git a/code/Exporter.cpp b/code/Exporter.cpp index 22db17659..37c36fb8c 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -71,13 +71,14 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out); // ------------------------------------------------------------------------------------------------ // Exporter worker function prototypes. Should not be necessary to #ifndef them, it's just a prototype -void ExportSceneCollada(const char*,IOSystem*, const aiScene*); -void ExportSceneXFile(const char*,IOSystem*, const aiScene*); -void ExportSceneObj(const char*,IOSystem*, const aiScene*); -void ExportSceneSTL(const char*,IOSystem*, const aiScene*); -void ExportSceneSTLBinary(const char*,IOSystem*, const aiScene*); -void ExportScenePly(const char*,IOSystem*, const aiScene*); -void ExportScene3DS(const char*, IOSystem*, const aiScene*) {} +// do not use const, because some exporter need to convert the scene temporary +void ExportSceneCollada(const char*,IOSystem*, aiScene*); +void ExportSceneXFile(const char*,IOSystem*, aiScene*); +void ExportSceneObj(const char*,IOSystem*, aiScene*); +void ExportSceneSTL(const char*,IOSystem*, aiScene*); +void ExportSceneSTLBinary(const char*,IOSystem*, aiScene*); +void ExportScenePly(const char*,IOSystem*, aiScene*); +void ExportScene3DS(const char*, IOSystem*, aiScene*) {} // ------------------------------------------------------------------------------------------------ // global array of all export formats which Assimp supports in its current build diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index ff9fa4b25..25bcfc9c5 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -51,7 +51,7 @@ namespace Assimp { // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Wavefront OBJ. Prototyped and registered in Exporter.cpp -void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) +void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) { // invoke the exporter ObjExporter exporter(pFile, pScene); diff --git a/code/PlyExporter.cpp b/code/PlyExporter.cpp index e78cfd964..bd04dfcb3 100644 --- a/code/PlyExporter.cpp +++ b/code/PlyExporter.cpp @@ -50,7 +50,7 @@ namespace Assimp { // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to PLY. Prototyped and registered in Exporter.cpp -void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) +void ExportScenePly(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) { // invoke the exporter PlyExporter exporter(pFile, pScene); diff --git a/code/STLExporter.cpp b/code/STLExporter.cpp index e3df2fbff..d1765f446 100644 --- a/code/STLExporter.cpp +++ b/code/STLExporter.cpp @@ -50,7 +50,7 @@ namespace Assimp { // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Stereolithograpy. Prototyped and registered in Exporter.cpp -void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) +void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) { // invoke the exporter STLExporter exporter(pFile, pScene); @@ -63,7 +63,7 @@ void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } -void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) +void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) { // invoke the exporter STLExporter exporter(pFile, pScene, true); diff --git a/code/XFileExporter.cpp b/code/XFileExporter.cpp index 2f14dbbe4..e56dc3ce4 100644 --- a/code/XFileExporter.cpp +++ b/code/XFileExporter.cpp @@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef ASSIMP_BUILD_NO_EXPORT #ifndef ASSIMP_BUILD_NO_XFILE_EXPORTER #include "XFileExporter.h" - +#include "ConvertToLHProcess.h" #include "Bitmap.h" #include "fast_atof.h" #include "SceneCombiner.h" @@ -59,7 +59,7 @@ namespace Assimp // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp -void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) +void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) { std::string path = ""; std::string file = pFile; @@ -96,7 +96,7 @@ void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pSce // ------------------------------------------------------------------------------------------------ // Constructor for a specific scene to export -XFileExporter::XFileExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file) : mIOSystem(pIOSystem), mPath(path), mFile(file) +XFileExporter::XFileExporter(aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file) : mIOSystem(pIOSystem), mPath(path), mFile(file) { // make sure that all formatting happens using the standard, C locale and not the user's current locale mOutput.imbue( std::locale("C") ); @@ -128,6 +128,13 @@ void XFileExporter::WriteFile() mOutput.setf(_IOSfixed); mOutput.precision(6); // precission for float + // the scene is already in OpenGL, applying MakeLeftHandedProcess, makes it xFile left handed + MakeLeftHandedProcess convertProcess; + FlipWindingOrderProcess flipper; + + convertProcess.Execute(mScene); + flipper.Execute(mScene); + // entry of writing the file WriteHeader(); @@ -141,6 +148,10 @@ void XFileExporter::WriteFile() PopTag(); mOutput << startstr << "}" << endstr; + + // and back to OpenGL right handed + convertProcess.Execute(mScene); + flipper.Execute(mScene); } // ------------------------------------------------------------------------------------------------ @@ -277,11 +288,11 @@ void XFileExporter::WriteHeader() void XFileExporter::WriteFrameTransform(aiMatrix4x4& m) { mOutput << startstr << "FrameTransformMatrix {" << endstr << " "; - PushTag(); - mOutput << startstr << m.a1 << "," << m.a2 << "," << m.a3 << "," << m.a4 << "," - << m.b1 << "," << m.b2 << "," << m.b3 << "," << m.b4 << "," - << m.c1 << "," << m.c2 << "," << m.c3 << "," << m.c4 << "," - << m.d1 << "," << m.d2 << "," << m.d3 << "," << m.d4 << ";;" << endstr; + PushTag(); + mOutput << startstr << m.a1 << "," << m.b1 << "," << m.c1 << "," << m.d1 << "," << endstr; + mOutput << startstr << m.a2 << "," << m.b2 << "," << m.c2 << "," << m.d2 << "," << endstr; + mOutput << startstr << m.a3 << "," << m.b3 << "," << m.c3 << "," << m.d3 << "," << endstr; + mOutput << startstr << m.a4 << "," << m.b4 << "," << m.c4 << "," << m.d4 << ";;" << endstr; PopTag(); mOutput << startstr << "}" << endstr << endstr; } @@ -291,11 +302,12 @@ void XFileExporter::WriteFrameTransform(aiMatrix4x4& m) // Recursively writes the given node void XFileExporter::WriteNode( const aiNode* pNode) { - mOutput << startstr << "Frame " << pNode->mName.C_Str() << " {" << endstr; + + mOutput << startstr << "Frame " << pNode->mName.C_Str() << " {" << " // " << pNode->mName.C_Str() << endstr; PushTag(); - aiMatrix4x4 m;// = pNode->mTransformation; + aiMatrix4x4 m = pNode->mTransformation; WriteFrameTransform(m); @@ -353,6 +365,43 @@ void XFileExporter::WriteMesh(const aiMesh* mesh) mOutput << ";" << endstr; } + mOutput << endstr; + + if (mesh->HasTextureCoords(0)) + { + const aiMaterial* mat = mScene->mMaterials[mesh->mMaterialIndex]; + aiString relpath; + mat->Get(_AI_MATKEY_TEXTURE_BASE, aiTextureType_DIFFUSE, 0, relpath); + + mOutput << startstr << "MeshMaterialList {" << endstr; + PushTag(); + mOutput << startstr << "1;" << endstr; // number of materials + mOutput << startstr << mesh->mNumFaces << ";" << endstr; // number of faces + for( size_t a = 0; a < mesh->mNumFaces; ++a ) + { + mOutput << startstr << a; + if (a < mesh->mNumFaces - 1) + mOutput << "," << endstr; + else + mOutput << ";" << endstr; + } + mOutput << startstr << "Material {" << endstr; + PushTag(); + mOutput << startstr << "1.0; 1.0; 1.0; 1.000000;;" << endstr; + mOutput << startstr << "1.000000;" << endstr; // power + mOutput << startstr << "0.000000; 0.000000; 0.000000;;" << endstr; // specularity + mOutput << startstr << "0.000000; 0.000000; 0.000000;;" << endstr; // emission + mOutput << startstr << "TextureFilename { \""; + + writePath(relpath); + + mOutput << "\"; }" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + PopTag(); + mOutput << startstr << "}" << endstr; + } + // write normals (every vertex has one) mOutput << endstr; if (mesh->HasNormals()) @@ -400,10 +449,12 @@ void XFileExporter::WriteMesh(const aiMesh* mesh) mOutput << startstr << "MeshTextureCoords {" << endstr; mOutput << startstr << mesh->mNumVertices << ";" << endstr; for (size_t a = 0; a < mesh->mNumVertices; a++) + //for (int a = (int)mesh->mNumVertices-1; a >=0 ; a--) { aiVector3D& uv = mesh->mTextureCoords[0][a]; // uv of first uv layer for the vertex - mOutput << uv.x << ";" << uv.y; + mOutput << startstr << uv.x << ";" << uv.y; if (a < mesh->mNumVertices-1) + //if (a >0 ) mOutput << ";," << endstr; else mOutput << ";;" << endstr; @@ -449,6 +500,22 @@ void XFileExporter::WriteMesh(const aiMesh* mesh) } + +void XFileExporter::writePath(aiString path) +{ + std::string str = std::string(path.C_Str()); + BaseImporter::ConvertUTF8toISO8859_1(str); + + while( str.find( "\\\\") != std::string::npos) + str.replace( str.find( "\\\\"), 2, "\\"); + + while( str.find( "\\") != std::string::npos) + str.replace( str.find( "\\"), 1, "/"); + + mOutput << str; + +} + #endif #endif diff --git a/code/XFileExporter.h b/code/XFileExporter.h index 39660530e..5e4877c48 100644 --- a/code/XFileExporter.h +++ b/code/XFileExporter.h @@ -55,13 +55,13 @@ struct aiNode; namespace Assimp { -/// Helper class to export a given scene to a Collada file. Just for my personal -/// comfort when implementing it. +/// Helper class to export a given scene to a X-file. +/// Note: an xFile uses a left hand system. Assimp used a right hand system (OpenGL), therefore we have to transform everything class XFileExporter { public: /// Constructor for a specific scene to export - XFileExporter( const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file); + XFileExporter(aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file); /// Destructor virtual ~XFileExporter(); @@ -93,6 +93,10 @@ public: std::stringstream mOutput; protected: + + /// write a path + void writePath(aiString path); + /// The IOSystem for output IOSystem* mIOSystem; @@ -103,11 +107,12 @@ protected: const std::string mFile; /// The scene to be written - const aiScene* mScene; + aiScene* mScene; bool mSceneOwned; /// current line start string, contains the current indentation for simple stream insertion std::string startstr; + /// current line end string for simple stream insertion std::string endstr; diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp index b9318ae29..2c9a2e2af 100644 --- a/include/assimp/Exporter.hpp +++ b/include/assimp/Exporter.hpp @@ -81,7 +81,7 @@ class ASSIMP_API Exporter public: /** Function pointer type of a Export worker function */ - typedef void (*fpExportFunc)(const char*,IOSystem*,const aiScene*); + typedef void (*fpExportFunc)(const char*,IOSystem*, aiScene*); /** Internal description of an Assimp export format option */ struct ExportFormatEntry From edc7a950c4a19f04b2c1e3de4eb74aa6f274d484 Mon Sep 17 00:00:00 2001 From: Madrich Date: Wed, 11 Jun 2014 00:41:18 +0200 Subject: [PATCH 6/8] ReFix the stuff before Fix XFileExporter Normal Fix Collada (Triangle->Poly) --- code/ColladaExporter.cpp | 39 ++++--------------------- code/ConvertToLHProcess.cpp | 10 ------- code/Exporter.cpp | 17 ++++++----- code/ObjExporter.cpp | 2 +- code/PlyExporter.cpp | 2 +- code/STLExporter.cpp | 4 +-- code/XFileExporter.cpp | 58 +++++++++++++++++-------------------- code/XFileExporter.h | 6 ++-- include/assimp/Exporter.hpp | 2 +- 9 files changed, 49 insertions(+), 91 deletions(-) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 3a1c096bf..e4099b365 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -58,7 +58,7 @@ namespace Assimp // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp -void ExportSceneCollada(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) +void ExportSceneCollada(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) { std::string path = ""; std::string file = pFile; @@ -634,13 +634,11 @@ void ColladaExporter::WriteGeometry( size_t pIndex) // count the number of lines, triangles and polygon meshes int countLines = 0; - int countTriangles = 0; int countPoly = 0; for( size_t a = 0; a < mesh->mNumFaces; ++a ) { if (mesh->mFaces[a].mNumIndices == 2) countLines++; - else if (mesh->mFaces[a].mNumIndices == 3) countTriangles++; - else if (mesh->mFaces[a].mNumIndices > 3) countPoly++; + else if (mesh->mFaces[a].mNumIndices >= 3) countPoly++; } // lines @@ -662,34 +660,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) mOutput << startstr << "" << endstr; } - // triangles, note for collada, triangles are defined in a right hand system - if (countTriangles) - { - mOutput << startstr << "" << endstr; - PushTag(); - mOutput << startstr << "" << endstr; - mOutput << startstr << "" << endstr; - mOutput << startstr << "

"; - for( size_t a = 0; a < mesh->mNumFaces; ++a ) - { - const aiFace& face = mesh->mFaces[a]; - if (face.mNumIndices != 3) continue; - // write vertix indices - for( size_t b = 0; b < face.mNumIndices; ++b ) - { - mOutput << face.mIndices[b] << " "; - } - // write normal indices - for( size_t b = 0; b < face.mNumIndices; ++b ) - { - mOutput << face.mIndices[b] << " "; - } - - } - mOutput << "

" << endstr; - PopTag(); - mOutput << startstr << "" << endstr; - } + // triangle - dont use it, because compatibility problems // polygons if (countPoly) @@ -701,7 +672,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) mOutput << startstr << ""; for( size_t a = 0; a < mesh->mNumFaces; ++a ) { - if (mesh->mFaces[a].mNumIndices <= 3) continue; + if (mesh->mFaces[a].mNumIndices < 3) continue; mOutput << mesh->mFaces[a].mNumIndices << " "; } mOutput << "" << endstr; @@ -710,7 +681,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) for( size_t a = 0; a < mesh->mNumFaces; ++a ) { const aiFace& face = mesh->mFaces[a]; - if (face.mNumIndices <= 3) continue; + if (face.mNumIndices < 3) continue; for( size_t b = 0; b < face.mNumIndices; ++b ) mOutput << face.mIndices[b] << " "; } diff --git a/code/ConvertToLHProcess.cpp b/code/ConvertToLHProcess.cpp index 17e157c45..3a51daf57 100644 --- a/code/ConvertToLHProcess.cpp +++ b/code/ConvertToLHProcess.cpp @@ -140,16 +140,6 @@ void MakeLeftHandedProcess::ProcessMesh( aiMesh* pMesh) pMesh->mTangents[a].z *= -1.0f; pMesh->mBitangents[a].z *= -1.0f; } - - // texture coords for all channels - for (unsigned int c = 0; c < pMesh->GetNumUVChannels(); c++) - { - if (pMesh->HasTextureCoords(c)) - { - pMesh->mTextureCoords[c][a].y = 1.0f - pMesh->mTextureCoords[c][a].y; - } - } - } // mirror offset matrices of all bones diff --git a/code/Exporter.cpp b/code/Exporter.cpp index 37c36fb8c..a53639fac 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -72,13 +72,13 @@ void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out); // ------------------------------------------------------------------------------------------------ // Exporter worker function prototypes. Should not be necessary to #ifndef them, it's just a prototype // do not use const, because some exporter need to convert the scene temporary -void ExportSceneCollada(const char*,IOSystem*, aiScene*); -void ExportSceneXFile(const char*,IOSystem*, aiScene*); -void ExportSceneObj(const char*,IOSystem*, aiScene*); -void ExportSceneSTL(const char*,IOSystem*, aiScene*); -void ExportSceneSTLBinary(const char*,IOSystem*, aiScene*); -void ExportScenePly(const char*,IOSystem*, aiScene*); -void ExportScene3DS(const char*, IOSystem*, aiScene*) {} +void ExportSceneCollada(const char*,IOSystem*, const aiScene*); +void ExportSceneXFile(const char*,IOSystem*, const aiScene*); +void ExportSceneObj(const char*,IOSystem*, const aiScene*); +void ExportSceneSTL(const char*,IOSystem*, const aiScene*); +void ExportSceneSTLBinary(const char*,IOSystem*, const aiScene*); +void ExportScenePly(const char*,IOSystem*, const aiScene*); +void ExportScene3DS(const char*, IOSystem*, const aiScene*) {} // ------------------------------------------------------------------------------------------------ // global array of all export formats which Assimp supports in its current build @@ -89,7 +89,8 @@ Exporter::ExportFormatEntry gExporters[] = #endif #ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER - Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile), + Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile, + aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs), #endif #ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index 25bcfc9c5..ff9fa4b25 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -51,7 +51,7 @@ namespace Assimp { // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Wavefront OBJ. Prototyped and registered in Exporter.cpp -void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) +void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) { // invoke the exporter ObjExporter exporter(pFile, pScene); diff --git a/code/PlyExporter.cpp b/code/PlyExporter.cpp index bd04dfcb3..e78cfd964 100644 --- a/code/PlyExporter.cpp +++ b/code/PlyExporter.cpp @@ -50,7 +50,7 @@ namespace Assimp { // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to PLY. Prototyped and registered in Exporter.cpp -void ExportScenePly(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) +void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) { // invoke the exporter PlyExporter exporter(pFile, pScene); diff --git a/code/STLExporter.cpp b/code/STLExporter.cpp index d1765f446..e3df2fbff 100644 --- a/code/STLExporter.cpp +++ b/code/STLExporter.cpp @@ -50,7 +50,7 @@ namespace Assimp { // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Stereolithograpy. Prototyped and registered in Exporter.cpp -void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) +void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) { // invoke the exporter STLExporter exporter(pFile, pScene); @@ -63,7 +63,7 @@ void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) outfile->Write( exporter.mOutput.str().c_str(), static_cast(exporter.mOutput.tellp()),1); } -void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) +void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) { // invoke the exporter STLExporter exporter(pFile, pScene, true); diff --git a/code/XFileExporter.cpp b/code/XFileExporter.cpp index e56dc3ce4..e06382bcb 100644 --- a/code/XFileExporter.cpp +++ b/code/XFileExporter.cpp @@ -59,7 +59,7 @@ namespace Assimp // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp -void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) +void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) { std::string path = ""; std::string file = pFile; @@ -96,7 +96,7 @@ void ExportSceneXFile(const char* pFile,IOSystem* pIOSystem, aiScene* pScene) // ------------------------------------------------------------------------------------------------ // Constructor for a specific scene to export -XFileExporter::XFileExporter(aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file) : mIOSystem(pIOSystem), mPath(path), mFile(file) +XFileExporter::XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file) : mIOSystem(pIOSystem), mPath(path), mFile(file) { // make sure that all formatting happens using the standard, C locale and not the user's current locale mOutput.imbue( std::locale("C") ); @@ -128,13 +128,6 @@ void XFileExporter::WriteFile() mOutput.setf(_IOSfixed); mOutput.precision(6); // precission for float - // the scene is already in OpenGL, applying MakeLeftHandedProcess, makes it xFile left handed - MakeLeftHandedProcess convertProcess; - FlipWindingOrderProcess flipper; - - convertProcess.Execute(mScene); - flipper.Execute(mScene); - // entry of writing the file WriteHeader(); @@ -149,9 +142,6 @@ void XFileExporter::WriteFile() mOutput << startstr << "}" << endstr; - // and back to OpenGL right handed - convertProcess.Execute(mScene); - flipper.Execute(mScene); } // ------------------------------------------------------------------------------------------------ @@ -289,10 +279,10 @@ void XFileExporter::WriteFrameTransform(aiMatrix4x4& m) { mOutput << startstr << "FrameTransformMatrix {" << endstr << " "; PushTag(); - mOutput << startstr << m.a1 << "," << m.b1 << "," << m.c1 << "," << m.d1 << "," << endstr; - mOutput << startstr << m.a2 << "," << m.b2 << "," << m.c2 << "," << m.d2 << "," << endstr; - mOutput << startstr << m.a3 << "," << m.b3 << "," << m.c3 << "," << m.d3 << "," << endstr; - mOutput << startstr << m.a4 << "," << m.b4 << "," << m.c4 << "," << m.d4 << ";;" << endstr; + mOutput << startstr << m.a1 << ", " << m.b1 << ", " << m.c1 << ", " << m.d1 << "," << endstr; + mOutput << startstr << m.a2 << ", " << m.b2 << ", " << m.c2 << ", " << m.d2 << "," << endstr; + mOutput << startstr << m.a3 << ", " << m.b3 << ", " << m.c3 << ", " << m.d3 << "," << endstr; + mOutput << startstr << m.a4 << ", " << m.b4 << ", " << m.c4 << ", " << m.d4 << ";;" << endstr; PopTag(); mOutput << startstr << "}" << endstr << endstr; } @@ -300,10 +290,15 @@ void XFileExporter::WriteFrameTransform(aiMatrix4x4& m) // ------------------------------------------------------------------------------------------------ // Recursively writes the given node -void XFileExporter::WriteNode( const aiNode* pNode) +void XFileExporter::WriteNode( aiNode* pNode) { - - mOutput << startstr << "Frame " << pNode->mName.C_Str() << " {" << " // " << pNode->mName.C_Str() << endstr; + if (pNode->mName.length==0) + { + std::stringstream ss; + ss << "Node_" << pNode; + pNode->mName.Set(ss.str()); + } + mOutput << startstr << "Frame " << pNode->mName.C_Str() << " {" << endstr; PushTag(); @@ -330,7 +325,7 @@ void XFileExporter::WriteMesh(const aiMesh* mesh) PushTag(); // write all the vertices - mOutput << startstr << mesh->mNumVertices << ";" << endstr; + mOutput << startstr << mesh->mNumVertices << ";" << endstr; for (size_t a = 0; a < mesh->mNumVertices; a++) { aiVector3D &v = mesh->mVertices[a]; @@ -377,11 +372,12 @@ void XFileExporter::WriteMesh(const aiMesh* mesh) PushTag(); mOutput << startstr << "1;" << endstr; // number of materials mOutput << startstr << mesh->mNumFaces << ";" << endstr; // number of faces + mOutput << startstr; for( size_t a = 0; a < mesh->mNumFaces; ++a ) { - mOutput << startstr << a; + mOutput << "0"; // the material index if (a < mesh->mNumFaces - 1) - mOutput << "," << endstr; + mOutput << ", "; else mOutput << ";" << endstr; } @@ -403,15 +399,15 @@ void XFileExporter::WriteMesh(const aiMesh* mesh) } // write normals (every vertex has one) - mOutput << endstr; if (mesh->HasNormals()) { - mOutput << startstr << "MeshNormals {" << endstr; + mOutput << endstr << startstr << "MeshNormals {" << endstr; mOutput << startstr << mesh->mNumVertices << ";" << endstr; for (size_t a = 0; a < mesh->mNumVertices; a++) { aiVector3D &v = mesh->mNormals[a]; - mOutput << startstr << v[0] << ";"<< v[1] << ";" << v[2] << ";"; + // because we have a LHS and also changed wth winding, we need to invert the normals again + mOutput << startstr << -v[0] << ";"<< -v[1] << ";" << -v[2] << ";"; if (a < mesh->mNumVertices - 1) mOutput << "," << endstr; else @@ -446,7 +442,7 @@ void XFileExporter::WriteMesh(const aiMesh* mesh) // write texture UVs if available if (mesh->HasTextureCoords(0)) { - mOutput << startstr << "MeshTextureCoords {" << endstr; + mOutput << endstr << startstr << "MeshTextureCoords {" << endstr; mOutput << startstr << mesh->mNumVertices << ";" << endstr; for (size_t a = 0; a < mesh->mNumVertices; a++) //for (int a = (int)mesh->mNumVertices-1; a >=0 ; a--) @@ -465,7 +461,7 @@ void XFileExporter::WriteMesh(const aiMesh* mesh) // write color channel if available if (mesh->HasVertexColors(0)) { - mOutput << startstr << "MeshVertexColors {" << endstr; + mOutput << endstr << startstr << "MeshVertexColors {" << endstr; mOutput << startstr << mesh->mNumVertices << ";" << endstr; for (size_t a = 0; a < mesh->mNumVertices; a++) { @@ -478,15 +474,15 @@ void XFileExporter::WriteMesh(const aiMesh* mesh) } mOutput << startstr << "}" << endstr; } - // test ... + /* else { - mOutput << startstr << "MeshVertexColors {" << endstr; + mOutput << endstr << startstr << "MeshVertexColors {" << endstr; mOutput << startstr << mesh->mNumVertices << ";" << endstr; for (size_t a = 0; a < mesh->mNumVertices; a++) { aiColor4D* mColors = mesh->mColors[a]; - mOutput << startstr << a << ";0.500000;0.000000;0.000000;0.000000;;"; + mOutput << startstr << a << ";0.500000;0.000000;0.000000;0.500000;;"; if (a < mesh->mNumVertices-1) mOutput << "," << endstr; else @@ -494,7 +490,7 @@ void XFileExporter::WriteMesh(const aiMesh* mesh) } mOutput << startstr << "}" << endstr; } - + */ PopTag(); mOutput << startstr << "}" << endstr << endstr; diff --git a/code/XFileExporter.h b/code/XFileExporter.h index 5e4877c48..fa4e6d38e 100644 --- a/code/XFileExporter.h +++ b/code/XFileExporter.h @@ -61,7 +61,7 @@ class XFileExporter { public: /// Constructor for a specific scene to export - XFileExporter(aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file); + XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path, const std::string& file); /// Destructor virtual ~XFileExporter(); @@ -77,7 +77,7 @@ protected: void WriteFrameTransform(aiMatrix4x4& m); /// Recursively writes the given node - void WriteNode( const aiNode* pNode); + void WriteNode( aiNode* pNode ); /// write a mesh entry of the scene void WriteMesh(const aiMesh* mesh); @@ -107,7 +107,7 @@ protected: const std::string mFile; /// The scene to be written - aiScene* mScene; + const aiScene* mScene; bool mSceneOwned; /// current line start string, contains the current indentation for simple stream insertion diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp index 2c9a2e2af..a879a33c8 100644 --- a/include/assimp/Exporter.hpp +++ b/include/assimp/Exporter.hpp @@ -81,7 +81,7 @@ class ASSIMP_API Exporter public: /** Function pointer type of a Export worker function */ - typedef void (*fpExportFunc)(const char*,IOSystem*, aiScene*); + typedef void (*fpExportFunc)(const char*,IOSystem*, const aiScene*); /** Internal description of an Assimp export format option */ struct ExportFormatEntry From 1cb01c54a37ae7e4a9ff5d710fbf61e9c6694ef5 Mon Sep 17 00:00:00 2001 From: Madrich Date: Fri, 20 Jun 2014 00:08:11 +0200 Subject: [PATCH 7/8] Fix IOSFixed Fix Author/AuthoringTool in Collada by MetaData --- code/AssimpPCH.cpp | 2 -- code/ColladaExporter.cpp | 20 +++++++++++++++++--- code/XFileExporter.cpp | 2 +- include/assimp/scene.h | 9 --------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/code/AssimpPCH.cpp b/code/AssimpPCH.cpp index 2ee9e4b95..62df955de 100644 --- a/code/AssimpPCH.cpp +++ b/code/AssimpPCH.cpp @@ -88,8 +88,6 @@ ASSIMP_API aiScene::aiScene() , mNumCameras(0) , mCameras(NULL) , mPrivate(new Assimp::ScenePrivateData()) - , author("Assimp") - , authoringTool("Assimp Importer-Exporter") { } diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index e4099b365..963827966 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -58,7 +58,7 @@ namespace Assimp // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to Collada. Prototyped and registered in Exporter.cpp -void ExportSceneCollada(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene) +void ExportSceneCollada(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene) { std::string path = ""; std::string file = pFile; @@ -230,8 +230,22 @@ void ColladaExporter::WriteHeader() PushTag(); mOutput << startstr << "" << endstr; PushTag(); - mOutput << startstr << "" << mScene->author.C_Str() << "" << endstr; - mOutput << startstr << "" << mScene->authoringTool.C_Str() << "" << endstr; + + aiMetadata* meta = mScene->mRootNode->mMetaData; + aiString value; + if (!meta || !meta->Get("Author", value)) + mOutput << startstr << "" << "Assimp" << "" << endstr; + else + mOutput << startstr << "" << value.C_Str() << "" << endstr; + + if (!meta || !meta->Get("AuthoringTool", value)) + mOutput << startstr << "" << "Assimp Exporter" << "" << endstr; + else + mOutput << startstr << "" << value.C_Str() << "" << endstr; + + //mOutput << startstr << "" << mScene->author.C_Str() << "" << endstr; + //mOutput << startstr << "" << mScene->authoringTool.C_Str() << "" << endstr; + PopTag(); mOutput << startstr << "" << endstr; mOutput << startstr << "" << date_str << "" << endstr; diff --git a/code/XFileExporter.cpp b/code/XFileExporter.cpp index e06382bcb..2cd3c4d37 100644 --- a/code/XFileExporter.cpp +++ b/code/XFileExporter.cpp @@ -125,7 +125,7 @@ XFileExporter::~XFileExporter() void XFileExporter::WriteFile() { // note, that all realnumber values must be comma separated in x files - mOutput.setf(_IOSfixed); + mOutput.setf(std::ios::fixed); mOutput.precision(6); // precission for float // entry of writing the file diff --git a/include/assimp/scene.h b/include/assimp/scene.h index f40323126..87f13152f 100644 --- a/include/assimp/scene.h +++ b/include/assimp/scene.h @@ -375,15 +375,6 @@ struct aiScene */ C_STRUCT aiCamera** mCameras; - - /** a string representing the author - */ - aiString author; - - /** a string representing the authoringtool - */ - aiString authoringTool; - #ifdef __cplusplus //! Default constructor - set everything to 0/NULL From 2c34f24497b970442d93cedd60da64b68b825111 Mon Sep 17 00:00:00 2001 From: Madrich Date: Sat, 21 Jun 2014 17:23:30 +0200 Subject: [PATCH 8/8] Fix XFile define --- code/Exporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Exporter.cpp b/code/Exporter.cpp index a53639fac..08b03f92d 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -88,7 +88,7 @@ Exporter::ExportFormatEntry gExporters[] = Exporter::ExportFormatEntry( "collada", "COLLADA - Digital Asset Exchange Schema", "dae", &ExportSceneCollada), #endif -#ifndef ASSIMP_BUILD_NO_OBJ_EXPORTER +#ifndef ASSIMP_BUILD_NO_FXILE_EXPORTER Exporter::ExportFormatEntry( "x", "X Files", "x", &ExportSceneXFile, aiProcess_MakeLeftHanded | aiProcess_FlipWindingOrder | aiProcess_FlipUVs), #endif