diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp
index 078ac0a56..c5d904c07 100644
--- a/code/ColladaExporter.cpp
+++ b/code/ColladaExporter.cpp
@@ -127,6 +127,7 @@ void ColladaExporter::WriteFile()
WriteTextures();
WriteHeader();
+ WriteCamerasLibrary();
WriteMaterials();
WriteGeometryLibrary();
@@ -286,6 +287,61 @@ void ColladaExporter::WriteTextures() {
}
}
+// ------------------------------------------------------------------------------------------------
+// Write the embedded textures
+void ColladaExporter::WriteCamerasLibrary() {
+ if(mScene->HasCameras()) {
+
+ mOutput << startstr << "" << endstr;
+ PushTag();
+
+ for( size_t a = 0; a < mScene->mNumCameras; ++a)
+ WriteCamera( a);
+
+ PopTag();
+ mOutput << startstr << "" << endstr;
+
+ }
+}
+
+void ColladaExporter::WriteCamera(size_t pIndex){
+
+ const aiCamera *cam = mScene->mCameras[pIndex];
+ const std::string idstrEscaped = XMLEscape(cam->mName.C_Str());
+
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ //assimp doesn't support the import of orthographic cameras! se we write
+ //always perspective
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << ""<<
+ AI_RAD_TO_DEG(cam->mHorizontalFOV)
+ <<"" << endstr;
+ mOutput << startstr << ""
+ << cam->mAspect
+ << "" << endstr;
+ mOutput << startstr << ""
+ << cam->mClipPlaneNear
+ << "" << endstr;
+ mOutput << startstr << ""
+ << cam->mClipPlaneFar
+ << "" << endstr;
+ PopTag();
+ mOutput << startstr << "" << endstr;
+ PopTag();
+ mOutput << startstr << "" << endstr;
+ PopTag();
+ mOutput << startstr << "" << endstr;
+ PopTag();
+ mOutput << startstr << "" << endstr;
+
+}
+
// ------------------------------------------------------------------------------------------------
// Reads a single surface entry from the given material keys
void ColladaExporter::ReadMaterialSurface( Surface& poSurface, const aiMaterial* pSrcMat, aiTextureType pTexture, const char* pKey, size_t pType, size_t pIndex)
@@ -847,6 +903,9 @@ void ColladaExporter::WriteNode(aiNode* pNode)
mOutput << mat.d1 << " " << mat.d2 << " " << mat.d3 << " " << mat.d4;
mOutput << "" << endstr;
+ if(pNode->mNumMeshes==0){
+ mOutput << startstr <<"" << endstr;
+ }else
// instance every geometry
for( size_t a = 0; a < pNode->mNumMeshes; ++a )
{
@@ -854,9 +913,8 @@ void ColladaExporter::WriteNode(aiNode* pNode)
// do not instanciate mesh if empty. I wonder how this could happen
if( mesh->mNumFaces == 0 || mesh->mNumVertices == 0 )
continue;
-
- mOutput << startstr << "mMeshes[a])) << "\">" << endstr;
- PushTag();
+ mOutput << startstr << "mMeshes[a])) << "\">" << endstr;
+ PushTag();
mOutput << startstr << "" << endstr;
PushTag();
mOutput << startstr << "" << endstr;
diff --git a/code/ColladaExporter.h b/code/ColladaExporter.h
index 9456508ce..4ded0d13d 100644
--- a/code/ColladaExporter.h
+++ b/code/ColladaExporter.h
@@ -83,6 +83,11 @@ protected:
/// Writes the material setup
void WriteMaterials();
+ /// Writes the cameras library
+ void WriteCamerasLibrary();
+
+ void WriteCamera(size_t pIndex);
+
/// Writes the geometry library
void WriteGeometryLibrary();
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f4b67bad6..9053f66d8 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -40,6 +40,7 @@ SET( TEST_SRCS
unit/utTriangulate.cpp
unit/utVertexTriangleAdjacency.cpp
unit/utNoBoostTest.cpp
+ unit/utColladaExportCamera.cpp
)
SOURCE_GROUP( tests FILES ${TEST_SRCS} )
diff --git a/test/models/Collada/cameras.dae b/test/models/Collada/cameras.dae
new file mode 100644
index 000000000..d514b0f3d
--- /dev/null
+++ b/test/models/Collada/cameras.dae
@@ -0,0 +1,93 @@
+
+
+
+
+ Blender User
+ Blender 2.74.0 commit date:2015-03-31, commit time:13:39, hash:000dfc0
+
+ 2015-05-17T19:24:51
+ 2015-05-17T19:24:51
+
+ Z_UP
+
+
+
+
+
+
+ 49.13434
+ 1.777778
+ 0.1
+ 100
+
+
+
+
+
+ 0
+ 0
+ 0
+
+
+
+
+
+
+
+ 3
+ 1.777778
+ 0.1
+ 100
+
+
+
+
+
+ 0
+ 0
+ 0
+
+
+
+
+
+
+
+ 29.86284
+ 1.777778
+ 0.1
+ 50
+
+
+
+
+
+ 0
+ 0
+ 0
+
+
+
+
+
+
+
+
+
+ 7.54979e-8 0 1 10 0 1 0 0 -1 0 7.54979e-8 0 0 0 0 1
+
+
+
+ 7.54979e-8 0 -1 -10 0 1 0 0 1 0 7.54979e-8 0 0 0 0 1
+
+
+
+ 3.09086e-8 -1 1.58933e-8 0 -3.09086e-8 1.58933e-8 1 5 -1 -3.09086e-8 -3.09086e-8 0 0 0 0 1
+
+
+
+
+
+
+
+