diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp
index c5d904c07..ba3530491 100644
--- a/code/ColladaExporter.cpp
+++ b/code/ColladaExporter.cpp
@@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "XMLTools.h"
#include "../include/assimp/IOSystem.hpp"
#include "../include/assimp/Exporter.hpp"
-#include "../include/assimp/scene.h"
+#include "../include/assimp/scene.h"
#include "Exceptional.h"
@@ -128,6 +128,7 @@ void ColladaExporter::WriteFile()
WriteHeader();
WriteCamerasLibrary();
+ WriteLightsLibrary();
WriteMaterials();
WriteGeometryLibrary();
@@ -342,6 +343,143 @@ void ColladaExporter::WriteCamera(size_t pIndex){
}
+
+// ------------------------------------------------------------------------------------------------
+// Write the embedded textures
+void ColladaExporter::WriteLightsLibrary() {
+ if(mScene->HasLights()) {
+
+ mOutput << startstr << "" << endstr;
+ PushTag();
+
+ for( size_t a = 0; a < mScene->mNumLights; ++a)
+ WriteLight( a);
+
+ PopTag();
+ mOutput << startstr << "" << endstr;
+
+ }
+}
+
+void ColladaExporter::WriteLight(size_t pIndex){
+
+ const aiLight *light = mScene->mLights[pIndex];
+ const std::string idstrEscaped = XMLEscape(light->mName.C_Str());
+
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ switch(light->mType){
+ case aiLightSource_AMBIENT:
+ WriteAmbienttLight(light);
+ break;
+ case aiLightSource_DIRECTIONAL:
+ WriteDirectionalLight(light);
+ break;
+ case aiLightSource_POINT:
+ WritePointLight(light);
+ break;
+ case aiLightSource_SPOT:
+ WriteSpotLight(light);
+ break;
+ case aiLightSource_UNDEFINED:
+ case _aiLightSource_Force32Bit:
+ break;
+ }
+ PopTag();
+ mOutput << startstr << "" << endstr;
+
+ PopTag();
+ mOutput << startstr << "" << endstr;
+
+}
+
+void ColladaExporter::WritePointLight(const aiLight *const light){
+ const aiColor3D &color= light->mColorDiffuse;
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << ""
+ << color.r<<" "<" << endstr;
+ mOutput << startstr << ""
+ << light->mAttenuationConstant
+ <<"" << endstr;
+ mOutput << startstr << ""
+ << light->mAttenuationLinear
+ <<"" << endstr;
+ mOutput << startstr << ""
+ << light->mAttenuationQuadratic
+ <<"" << endstr;
+
+ PopTag();
+ mOutput << startstr << "" << endstr;
+
+}
+void ColladaExporter::WriteDirectionalLight(const aiLight *const light){
+ const aiColor3D &color= light->mColorDiffuse;
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << ""
+ << color.r<<" "<" << endstr;
+
+ PopTag();
+ mOutput << startstr << "" << endstr;
+
+}
+void ColladaExporter::WriteSpotLight(const aiLight *const light){
+ /*
+ 1 1 1
+ 1
+ 0
+ 0.001599967
+ 45
+ 0.15
+
+ */
+ const aiColor3D &color= light->mColorDiffuse;
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << ""
+ << color.r<<" "<" << endstr;
+ mOutput << startstr << ""
+ << light->mAttenuationConstant
+ <<"" << endstr;
+ mOutput << startstr << ""
+ << light->mAttenuationLinear
+ <<"" << endstr;
+ mOutput << startstr << ""
+ << light->mAttenuationQuadratic
+ <<"" << endstr;
+/* mOutput << startstr << ""
+ << light->
+ <<"" << endstr;
+ mOutput << startstr << ""
+ << light->mAttenuationLinear
+ <<"" << endstr;
+*/
+
+ PopTag();
+ mOutput << startstr << "" << endstr;
+
+}
+
+void ColladaExporter::WriteAmbienttLight(const aiLight *const light){
+
+ const aiColor3D &color= light->mColorAmbient;
+ mOutput << startstr << "" << endstr;
+ PushTag();
+ mOutput << startstr << ""
+ << color.r<<" "<" << 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)
diff --git a/code/ColladaExporter.h b/code/ColladaExporter.h
index 4ded0d13d..73dc497fa 100644
--- a/code/ColladaExporter.h
+++ b/code/ColladaExporter.h
@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../include/assimp/ai_assert.h"
#include "../include/assimp/material.h"
#include "../include/assimp/mesh.h"
+#include "../include/assimp/light.h"
#include "../include/assimp/Exporter.hpp"
#include
#include
@@ -86,8 +87,19 @@ protected:
/// Writes the cameras library
void WriteCamerasLibrary();
+ // Write a camera entry
void WriteCamera(size_t pIndex);
+ /// Writes the cameras library
+ void WriteLightsLibrary();
+
+ // Write a camera entry
+ void WriteLight(size_t pIndex);
+ void WritePointLight(const aiLight *const light);
+ void WriteDirectionalLight(const aiLight *const light);
+ void WriteSpotLight(const aiLight *const light);
+ void WriteAmbienttLight(const aiLight *const light);
+
/// Writes the geometry library
void WriteGeometryLibrary();
diff --git a/include/assimp/defs.h b/include/assimp/defs.h
index 6b8ac3416..c21b3cf2b 100644
--- a/include/assimp/defs.h
+++ b/include/assimp/defs.h
@@ -209,7 +209,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#if (defined(__BORLANDC__) || defined (__BCPLUSPLUS__))
#error Currently, Borland is unsupported. Feel free to port Assimp.
-// "W8059 Packgröße der Struktur geändert"
+// "W8059 Packgr��e der Struktur ge�ndert"
#endif
//////////////////////////////////////////////////////////////////////////
@@ -257,8 +257,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_MATH_HALF_PI_F (AI_MATH_PI_F * 0.5f)
/* Tiny macro to convert from radians to degrees and back */
-#define AI_DEG_TO_RAD(x) (x*0.0174532925f)
-#define AI_RAD_TO_DEG(x) (x*57.2957795f)
+#define AI_DEG_TO_RAD(x) ((x)*0.0174532925f)
+#define AI_RAD_TO_DEG(x) ((x)*57.2957795f)
/* Support for big-endian builds */
#if defined(__BYTE_ORDER__)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 9053f66d8..287f51698 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -41,6 +41,7 @@ SET( TEST_SRCS
unit/utVertexTriangleAdjacency.cpp
unit/utNoBoostTest.cpp
unit/utColladaExportCamera.cpp
+ unit/utColladaExportLight.cpp
)
SOURCE_GROUP( tests FILES ${TEST_SRCS} )
diff --git a/test/models/Collada/lights.dae b/test/models/Collada/lights.dae
new file mode 100644
index 000000000..9e040aac6
--- /dev/null
+++ b/test/models/Collada/lights.dae
@@ -0,0 +1,380 @@
+
+
+
+
+ Blender User
+ Blender 2.74.0 commit date:2015-03-31, commit time:13:39, hash:000dfc0
+
+ 2015-05-17T21:55:44
+ 2015-05-17T21:55:44
+
+ Z_UP
+
+
+
+
+
+ 1 1 1
+ 1
+ 0
+ 0.00111109
+
+
+
+
+ 0.000999987
+ 1
+ 0.1
+ 0.1
+ 1
+ 1
+ 1
+ 2
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 2880
+ 2
+ 30.002
+ 1.000799
+ 0.04999995
+ 29.99998
+ 1
+ 2
+ 0
+ 0
+ 1
+ 1
+ 1
+ 1
+ 8192
+ 1
+ 1
+ 0
+ 1
+ 1
+ 1
+ 3
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 1
+ 1
+ 3
+ 0.15
+ 75
+ 1
+ 1
+ 0
+ 1
+ 1
+ 0
+
+
+
+
+
+
+ 1 1 1
+
+
+
+
+ 0.000999987
+ 0
+ 0.1
+ 0.1
+ 0.1
+ 1
+ 1
+ 2
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 512
+ 2
+ 40
+ 0.5
+ 0.04999995
+ 25
+ 1
+ 2
+ 0
+ 0
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 0
+ 1
+ 1
+ 1
+ 3
+ 0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 1
+ 1
+ 1
+ 3
+ 0.15
+ 45
+ 1
+ 1
+ 0
+ 1
+ 1
+ 4
+
+
+
+
+
+
+
+
+
+ 1 0 0 0 0 1 0 1 0 0 1 1 0 0 0 1
+
+
+
+ 1 0 0 7.076701 0 1 0 -5.572294 0 0 1 5.147222 0 0 0 1
+
+
+
+ 1 0 0 8.888217 0 1 0 -5.016863 0 0 1 5.336025 0 0 0 1
+
+
+
+ 1 0 0 7.326984 0 1 0 -4.602942 0 0 1 5.554852 0 0 0 1
+
+
+
+ 1 0 0 8.063721 0 1 0 -4.19857 0 0 1 5.273283 0 0 0 1
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/unit/utColladaExportLight.cpp b/test/unit/utColladaExportLight.cpp
new file mode 100644
index 000000000..044770be3
--- /dev/null
+++ b/test/unit/utColladaExportLight.cpp
@@ -0,0 +1,81 @@
+/*
+ * ColladaCameraExporter.cpp
+ *
+ * Created on: May 17, 2015
+ * Author: wise
+ */
+
+
+#include "UnitTestPCH.h"
+
+#include
+#include
+#include
+#include
+
+#ifndef ASSIMP_BUILD_NO_EXPORT
+
+class ColladaExportLight : public ::testing::Test {
+public:
+
+ virtual void SetUp()
+ {
+ ex = new Assimp::Exporter();
+ im = new Assimp::Importer();
+
+ }
+
+ virtual void TearDown()
+ {
+ delete ex;
+ delete im;
+ }
+
+protected:
+
+
+ Assimp::Exporter* ex;
+ Assimp::Importer* im;
+};
+
+// ------------------------------------------------------------------------------------------------
+TEST_F(ColladaExportLight, testExportLight)
+{
+ const char* file = "cameraExp.dae";
+
+ const aiScene* pTest = im->ReadFile("../test/models/Collada/lights.dae",0);
+ ASSERT_TRUE(pTest!=NULL);
+ ASSERT_TRUE(pTest->HasLights());
+
+
+ EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
+ EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada","/home/wise/lightsExp.dae"));
+
+ const aiScene* imported = im->ReadFile(file,0);
+
+ ASSERT_TRUE(imported!=NULL);
+
+ EXPECT_TRUE(imported->HasLights());
+ EXPECT_EQ(pTest->mNumLights,imported->mNumLights);
+/*
+ for(size_t i=0; i< pTest->mNumCameras;i++){
+
+ const aiCamera *orig = pTest->mCameras[i];
+ const aiCamera *read = imported->mCameras[i];
+
+ EXPECT_TRUE(orig->mName==read->mName);
+ EXPECT_FLOAT_EQ(orig->mHorizontalFOV,read->mHorizontalFOV);
+ EXPECT_FLOAT_EQ(orig->mClipPlaneNear,read->mClipPlaneNear);
+ EXPECT_FLOAT_EQ(orig->mClipPlaneFar,read->mClipPlaneFar);
+
+ EXPECT_FLOAT_EQ(orig->mPosition.x,read->mPosition.x);
+ EXPECT_FLOAT_EQ(orig->mPosition.y,read->mPosition.y);
+ EXPECT_FLOAT_EQ(orig->mPosition.z,read->mPosition.z);
+ }
+*/
+}
+
+
+#endif
+
+