Code style changes.

pull/421/head
Andreas Henne 2014-12-11 23:05:09 +01:00
parent 33f9745b62
commit ab7754ab2a
2 changed files with 15 additions and 9 deletions

View File

@ -114,7 +114,7 @@ Exporter::ExportFormatEntry gExporters[] =
Exporter::ExportFormatEntry( "ply", "Stanford Polygon Library", "ply" , &ExportScenePly, Exporter::ExportFormatEntry( "ply", "Stanford Polygon Library", "ply" , &ExportScenePly,
aiProcess_PreTransformVertices aiProcess_PreTransformVertices
), ),
Exporter::ExportFormatEntry( "plyb", "Stanford Polygon Library Binary", "ply", &ExportScenePlyBinary, Exporter::ExportFormatEntry( "plyb", "Stanford Polygon Library (binary)", "ply", &ExportScenePlyBinary,
aiProcess_PreTransformVertices aiProcess_PreTransformVertices
), ),
#endif #endif

View File

@ -116,16 +116,14 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
} }
mOutput << "ply" << endl; mOutput << "ply" << endl;
if (binary) if (binary) {
{
#if (defined AI_BUILD_BIG_ENDIAN) #if (defined AI_BUILD_BIG_ENDIAN)
mOutput << "format binary_big_endian 1.0" << endl; mOutput << "format binary_big_endian 1.0" << endl;
#else #else
mOutput << "format binary_little_endian 1.0" << endl; mOutput << "format binary_little_endian 1.0" << endl;
#endif #endif
} }
else else {
{
mOutput << "format ascii 1.0" << endl; mOutput << "format ascii 1.0" << endl;
} }
mOutput << "comment Created by Open Asset Import Library - http://assimp.sf.net (v" mOutput << "comment Created by Open Asset Import Library - http://assimp.sf.net (v"
@ -188,16 +186,20 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
mOutput << "end_header" << endl; mOutput << "end_header" << endl;
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) { for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
if (binary) if (binary) {
WriteMeshVertsBinary(pScene->mMeshes[i], components); WriteMeshVertsBinary(pScene->mMeshes[i], components);
else }
else {
WriteMeshVerts(pScene->mMeshes[i], components); WriteMeshVerts(pScene->mMeshes[i], components);
}
} }
for (unsigned int i = 0, ofs = 0; i < pScene->mNumMeshes; ++i) { for (unsigned int i = 0, ofs = 0; i < pScene->mNumMeshes; ++i) {
if (binary) if (binary) {
WriteMeshIndicesBinary(pScene->mMeshes[i], ofs); WriteMeshIndicesBinary(pScene->mMeshes[i], ofs);
else }
else {
WriteMeshIndices(pScene->mMeshes[i], ofs); WriteMeshIndices(pScene->mMeshes[i], ofs);
}
ofs += pScene->mMeshes[i]->mNumVertices; ofs += pScene->mMeshes[i]->mNumVertices;
} }
} }
@ -205,6 +207,8 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components) void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
{ {
// If a component (for instance normal vectors) is present in at least one mesh in the scene,
// then default values are written for meshes that do not contain this component.
for (unsigned int i = 0; i < m->mNumVertices; ++i) { for (unsigned int i = 0; i < m->mNumVertices; ++i) {
mOutput << mOutput <<
m->mVertices[i].x << " " << m->mVertices[i].x << " " <<
@ -270,6 +274,8 @@ void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void PlyExporter::WriteMeshVertsBinary(const aiMesh* m, unsigned int components) void PlyExporter::WriteMeshVertsBinary(const aiMesh* m, unsigned int components)
{ {
// If a component (for instance normal vectors) is present in at least one mesh in the scene,
// then default values are written for meshes that do not contain this component.
aiVector3D defaultNormal(0, 0, 0); aiVector3D defaultNormal(0, 0, 0);
aiVector2D defaultUV(-1, -1); aiVector2D defaultUV(-1, -1);
aiColor4D defaultColor(-1, -1, -1, -1); aiColor4D defaultColor(-1, -1, -1, -1);