Merge pull request #570 from wise86-android/colladaExportLightAndCamera
Collada export light and camerapull/571/head
commit
9538b7ed42
|
@ -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"
|
||||
|
||||
|
@ -127,6 +127,8 @@ void ColladaExporter::WriteFile()
|
|||
WriteTextures();
|
||||
WriteHeader();
|
||||
|
||||
WriteCamerasLibrary();
|
||||
WriteLightsLibrary();
|
||||
WriteMaterials();
|
||||
WriteGeometryLibrary();
|
||||
|
||||
|
@ -286,6 +288,201 @@ void ColladaExporter::WriteTextures() {
|
|||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Write the embedded textures
|
||||
void ColladaExporter::WriteCamerasLibrary() {
|
||||
if(mScene->HasCameras()) {
|
||||
|
||||
mOutput << startstr << "<library_cameras>" << endstr;
|
||||
PushTag();
|
||||
|
||||
for( size_t a = 0; a < mScene->mNumCameras; ++a)
|
||||
WriteCamera( a);
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_cameras>" << endstr;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ColladaExporter::WriteCamera(size_t pIndex){
|
||||
|
||||
const aiCamera *cam = mScene->mCameras[pIndex];
|
||||
const std::string idstrEscaped = XMLEscape(cam->mName.C_Str());
|
||||
|
||||
mOutput << startstr << "<camera id=\"" << idstrEscaped << "-camera\" name=\"" << idstrEscaped << "_name\" >" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<optics>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<technique_common>" << endstr;
|
||||
PushTag();
|
||||
//assimp doesn't support the import of orthographic cameras! se we write
|
||||
//always perspective
|
||||
mOutput << startstr << "<perspective>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<xfov sid=\"xfov\">"<<
|
||||
AI_RAD_TO_DEG(cam->mHorizontalFOV)
|
||||
<<"</xfov>" << endstr;
|
||||
mOutput << startstr << "<aspect_ratio>"
|
||||
<< cam->mAspect
|
||||
<< "</aspect_ratio>" << endstr;
|
||||
mOutput << startstr << "<znear sid=\"znear\">"
|
||||
<< cam->mClipPlaneNear
|
||||
<< "</znear>" << endstr;
|
||||
mOutput << startstr << "<zfar sid=\"zfar\">"
|
||||
<< cam->mClipPlaneFar
|
||||
<< "</zfar>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</perspective>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</technique_common>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</optics>" << endstr;
|
||||
PopTag();
|
||||
mOutput << startstr << "</camera>" << endstr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Write the embedded textures
|
||||
void ColladaExporter::WriteLightsLibrary() {
|
||||
if(mScene->HasLights()) {
|
||||
|
||||
mOutput << startstr << "<library_lights>" << endstr;
|
||||
PushTag();
|
||||
|
||||
for( size_t a = 0; a < mScene->mNumLights; ++a)
|
||||
WriteLight( a);
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</library_lights>" << endstr;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ColladaExporter::WriteLight(size_t pIndex){
|
||||
|
||||
const aiLight *light = mScene->mLights[pIndex];
|
||||
const std::string idstrEscaped = XMLEscape(light->mName.C_Str());
|
||||
|
||||
mOutput << startstr << "<light id=\"" << idstrEscaped << "-light\" name=\""
|
||||
<< idstrEscaped << "_name\" >" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<technique_common>" << 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 << "</technique_common>" << endstr;
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</light>" << endstr;
|
||||
|
||||
}
|
||||
|
||||
void ColladaExporter::WritePointLight(const aiLight *const light){
|
||||
const aiColor3D &color= light->mColorDiffuse;
|
||||
mOutput << startstr << "<point>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<color sid=\"color\">"
|
||||
<< color.r<<" "<<color.g<<" "<<color.b
|
||||
<<"</color>" << endstr;
|
||||
mOutput << startstr << "<constant_attenuation>"
|
||||
<< light->mAttenuationConstant
|
||||
<<"</constant_attenuation>" << endstr;
|
||||
mOutput << startstr << "<linear_attenuation>"
|
||||
<< light->mAttenuationLinear
|
||||
<<"</linear_attenuation>" << endstr;
|
||||
mOutput << startstr << "<quadratic_attenuation>"
|
||||
<< light->mAttenuationQuadratic
|
||||
<<"</quadratic_attenuation>" << endstr;
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</point>" << endstr;
|
||||
|
||||
}
|
||||
void ColladaExporter::WriteDirectionalLight(const aiLight *const light){
|
||||
const aiColor3D &color= light->mColorDiffuse;
|
||||
mOutput << startstr << "<directional>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<color sid=\"color\">"
|
||||
<< color.r<<" "<<color.g<<" "<<color.b
|
||||
<<"</color>" << endstr;
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</directional>" << endstr;
|
||||
|
||||
}
|
||||
void ColladaExporter::WriteSpotLight(const aiLight *const light){
|
||||
|
||||
const aiColor3D &color= light->mColorDiffuse;
|
||||
mOutput << startstr << "<spot>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<color sid=\"color\">"
|
||||
<< color.r<<" "<<color.g<<" "<<color.b
|
||||
<<"</color>" << endstr;
|
||||
mOutput << startstr << "<constant_attenuation>"
|
||||
<< light->mAttenuationConstant
|
||||
<<"</constant_attenuation>" << endstr;
|
||||
mOutput << startstr << "<linear_attenuation>"
|
||||
<< light->mAttenuationLinear
|
||||
<<"</linear_attenuation>" << endstr;
|
||||
mOutput << startstr << "<quadratic_attenuation>"
|
||||
<< light->mAttenuationQuadratic
|
||||
<<"</quadratic_attenuation>" << endstr;
|
||||
/*
|
||||
out->mAngleOuterCone = AI_DEG_TO_RAD (std::acos(std::pow(0.1f,1.f/srcLight->mFalloffExponent))+
|
||||
srcLight->mFalloffAngle);
|
||||
*/
|
||||
|
||||
const float fallOffAngle = AI_RAD_TO_DEG(light->mAngleInnerCone);
|
||||
mOutput << startstr <<"<falloff_angle sid=\"fall_off_angle\">"
|
||||
<< fallOffAngle
|
||||
<<"</falloff_angle>" << endstr;
|
||||
double temp = light->mAngleOuterCone-light->mAngleInnerCone;
|
||||
|
||||
temp = std::cos(temp);
|
||||
temp = std::log(temp)/std::log(0.1);
|
||||
temp = 1/temp;
|
||||
mOutput << startstr << "<falloff_exponent sid=\"fall_off_exponent\">"
|
||||
<< temp
|
||||
<<"</falloff_exponent>" << endstr;
|
||||
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</spot>" << endstr;
|
||||
|
||||
}
|
||||
|
||||
void ColladaExporter::WriteAmbienttLight(const aiLight *const light){
|
||||
|
||||
const aiColor3D &color= light->mColorAmbient;
|
||||
mOutput << startstr << "<ambient>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<color sid=\"color\">"
|
||||
<< color.r<<" "<<color.g<<" "<<color.b
|
||||
<<"</color>" << endstr;
|
||||
|
||||
PopTag();
|
||||
mOutput << startstr << "</ambient>" << 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 +1044,23 @@ void ColladaExporter::WriteNode(aiNode* pNode)
|
|||
mOutput << mat.d1 << " " << mat.d2 << " " << mat.d3 << " " << mat.d4;
|
||||
mOutput << "</matrix>" << endstr;
|
||||
|
||||
if(pNode->mNumMeshes==0){
|
||||
//check if it is a camera node
|
||||
for(size_t i=0; i<mScene->mNumCameras; i++){
|
||||
if(mScene->mCameras[i]->mName == pNode->mName){
|
||||
mOutput << startstr <<"<instance_camera url=\"#" << node_name_escaped << "-camera\"/>" << endstr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//check if it is a light node
|
||||
for(size_t i=0; i<mScene->mNumLights; i++){
|
||||
if(mScene->mLights[i]->mName == pNode->mName){
|
||||
mOutput << startstr <<"<instance_light url=\"#" << node_name_escaped << "-light\"/>" << endstr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}else
|
||||
// instance every geometry
|
||||
for( size_t a = 0; a < pNode->mNumMeshes; ++a )
|
||||
{
|
||||
|
@ -854,9 +1068,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 << "<instance_geometry url=\"#" << XMLEscape(GetMeshId( pNode->mMeshes[a])) << "\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<instance_geometry url=\"#" << XMLEscape(GetMeshId( pNode->mMeshes[a])) << "\">" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<bind_material>" << endstr;
|
||||
PushTag();
|
||||
mOutput << startstr << "<technique_common>" << endstr;
|
||||
|
|
|
@ -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 <sstream>
|
||||
#include <vector>
|
||||
|
@ -83,6 +84,22 @@ protected:
|
|||
/// Writes the material setup
|
||||
void WriteMaterials();
|
||||
|
||||
/// 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();
|
||||
|
||||
|
|
|
@ -349,8 +349,8 @@ void ColladaLoader::BuildLightsForNode( const ColladaParser& pParser, const Coll
|
|||
{
|
||||
// Need to rely on falloff_exponent. I don't know how to interpret it, so I need to guess ....
|
||||
// epsilon chosen to be 0.1
|
||||
out->mAngleOuterCone = AI_DEG_TO_RAD (std::acos(std::pow(0.1f,1.f/srcLight->mFalloffExponent))+
|
||||
srcLight->mFalloffAngle);
|
||||
out->mAngleOuterCone = std::acos(std::pow(0.1f,1.f/srcLight->mFalloffExponent))+
|
||||
out->mAngleInnerCone;
|
||||
}
|
||||
else {
|
||||
out->mAngleOuterCone = out->mAngleInnerCone + AI_DEG_TO_RAD( srcLight->mPenumbraAngle );
|
||||
|
|
|
@ -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<EFBFBD><EFBFBD>e der Struktur ge<67>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__)
|
||||
|
|
|
@ -40,6 +40,8 @@ SET( TEST_SRCS
|
|||
unit/utTriangulate.cpp
|
||||
unit/utVertexTriangleAdjacency.cpp
|
||||
unit/utNoBoostTest.cpp
|
||||
unit/utColladaExportCamera.cpp
|
||||
unit/utColladaExportLight.cpp
|
||||
)
|
||||
|
||||
SOURCE_GROUP( tests FILES ${TEST_SRCS} )
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
|
||||
<asset>
|
||||
<contributor>
|
||||
<author>Blender User</author>
|
||||
<authoring_tool>Blender 2.74.0 commit date:2015-03-31, commit time:13:39, hash:000dfc0</authoring_tool>
|
||||
</contributor>
|
||||
<created>2015-05-17T19:24:51</created>
|
||||
<modified>2015-05-17T19:24:51</modified>
|
||||
<unit name="meter" meter="1"/>
|
||||
<up_axis>Z_UP</up_axis>
|
||||
</asset>
|
||||
<library_cameras>
|
||||
<camera id="Camera-camera" name="Camera.001">
|
||||
<optics>
|
||||
<technique_common>
|
||||
<perspective>
|
||||
<xfov sid="xfov">49.13434</xfov>
|
||||
<aspect_ratio>1.777778</aspect_ratio>
|
||||
<znear sid="znear">0.1</znear>
|
||||
<zfar sid="zfar">100</zfar>
|
||||
</perspective>
|
||||
</technique_common>
|
||||
</optics>
|
||||
<extra>
|
||||
<technique profile="blender">
|
||||
<YF_dofdist>0</YF_dofdist>
|
||||
<shiftx>0</shiftx>
|
||||
<shifty>0</shifty>
|
||||
</technique>
|
||||
</extra>
|
||||
</camera>
|
||||
<camera id="Camera_002-camera" name="Camera.002">
|
||||
<optics>
|
||||
<technique_common>
|
||||
<orthographic>
|
||||
<xmag sid="xmag">3</xmag>
|
||||
<aspect_ratio>1.777778</aspect_ratio>
|
||||
<znear sid="znear">0.1</znear>
|
||||
<zfar sid="zfar">100</zfar>
|
||||
</orthographic>
|
||||
</technique_common>
|
||||
</optics>
|
||||
<extra>
|
||||
<technique profile="blender">
|
||||
<YF_dofdist>0</YF_dofdist>
|
||||
<shiftx>0</shiftx>
|
||||
<shifty>0</shifty>
|
||||
</technique>
|
||||
</extra>
|
||||
</camera>
|
||||
<camera id="Camera_003-camera" name="Camera.003">
|
||||
<optics>
|
||||
<technique_common>
|
||||
<perspective>
|
||||
<xfov sid="xfov">29.86284</xfov>
|
||||
<aspect_ratio>1.777778</aspect_ratio>
|
||||
<znear sid="znear">0.1</znear>
|
||||
<zfar sid="zfar">50</zfar>
|
||||
</perspective>
|
||||
</technique_common>
|
||||
</optics>
|
||||
<extra>
|
||||
<technique profile="blender">
|
||||
<YF_dofdist>0</YF_dofdist>
|
||||
<shiftx>0</shiftx>
|
||||
<shifty>0</shifty>
|
||||
</technique>
|
||||
</extra>
|
||||
</camera>
|
||||
</library_cameras>
|
||||
<library_images/>
|
||||
<library_controllers/>
|
||||
<library_visual_scenes>
|
||||
<visual_scene id="Scene" name="Scene">
|
||||
<node id="Camera" name="Camera" type="NODE">
|
||||
<matrix sid="transform">7.54979e-8 0 1 10 0 1 0 0 -1 0 7.54979e-8 0 0 0 0 1</matrix>
|
||||
<instance_camera url="#Camera-camera"/>
|
||||
</node>
|
||||
<node id="Camera_002" name="Camera_002" type="NODE">
|
||||
<matrix sid="transform">7.54979e-8 0 -1 -10 0 1 0 0 1 0 7.54979e-8 0 0 0 0 1</matrix>
|
||||
<instance_camera url="#Camera_002-camera"/>
|
||||
</node>
|
||||
<node id="Camera_003" name="Camera_003" type="NODE">
|
||||
<matrix sid="transform">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</matrix>
|
||||
<instance_camera url="#Camera_003-camera"/>
|
||||
</node>
|
||||
</visual_scene>
|
||||
</library_visual_scenes>
|
||||
<scene>
|
||||
<instance_visual_scene url="#Scene"/>
|
||||
</scene>
|
||||
</COLLADA>
|
|
@ -0,0 +1,380 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
|
||||
<asset>
|
||||
<contributor>
|
||||
<author>Blender User</author>
|
||||
<authoring_tool>Blender 2.74.0 commit date:2015-03-31, commit time:13:39, hash:000dfc0</authoring_tool>
|
||||
</contributor>
|
||||
<created>2015-05-17T21:55:44</created>
|
||||
<modified>2015-05-17T21:55:44</modified>
|
||||
<unit name="meter" meter="1"/>
|
||||
<up_axis>Z_UP</up_axis>
|
||||
</asset>
|
||||
<library_lights>
|
||||
<light id="Lamp-light" name="Lamp">
|
||||
<technique_common>
|
||||
<point>
|
||||
<color sid="color">1 1 1</color>
|
||||
<constant_attenuation>1</constant_attenuation>
|
||||
<linear_attenuation>0</linear_attenuation>
|
||||
<quadratic_attenuation>0.00111109</quadratic_attenuation>
|
||||
</point>
|
||||
</technique_common>
|
||||
<extra>
|
||||
<technique profile="blender">
|
||||
<adapt_thresh>0.000999987</adapt_thresh>
|
||||
<area_shape>1</area_shape>
|
||||
<area_size>0.1</area_size>
|
||||
<area_sizey>0.1</area_sizey>
|
||||
<area_sizez>1</area_sizez>
|
||||
<atm_distance_factor>1</atm_distance_factor>
|
||||
<atm_extinction_factor>1</atm_extinction_factor>
|
||||
<atm_turbidity>2</atm_turbidity>
|
||||
<att1>0</att1>
|
||||
<att2>1</att2>
|
||||
<backscattered_light>1</backscattered_light>
|
||||
<bias>1</bias>
|
||||
<blue>1</blue>
|
||||
<buffers>1</buffers>
|
||||
<bufflag>0</bufflag>
|
||||
<bufsize>2880</bufsize>
|
||||
<buftype>2</buftype>
|
||||
<clipend>30.002</clipend>
|
||||
<clipsta>1.000799</clipsta>
|
||||
<compressthresh>0.04999995</compressthresh>
|
||||
<dist sid="blender_dist">29.99998</dist>
|
||||
<energy sid="blender_energy">1</energy>
|
||||
<falloff_type>2</falloff_type>
|
||||
<filtertype>0</filtertype>
|
||||
<flag>0</flag>
|
||||
<gamma sid="blender_gamma">1</gamma>
|
||||
<green>1</green>
|
||||
<halo_intensity sid="blnder_halo_intensity">1</halo_intensity>
|
||||
<horizon_brightness>1</horizon_brightness>
|
||||
<mode>8192</mode>
|
||||
<ray_samp>1</ray_samp>
|
||||
<ray_samp_method>1</ray_samp_method>
|
||||
<ray_samp_type>0</ray_samp_type>
|
||||
<ray_sampy>1</ray_sampy>
|
||||
<ray_sampz>1</ray_sampz>
|
||||
<red>1</red>
|
||||
<samp>3</samp>
|
||||
<shadhalostep>0</shadhalostep>
|
||||
<shadow_b sid="blender_shadow_b">0</shadow_b>
|
||||
<shadow_g sid="blender_shadow_g">0</shadow_g>
|
||||
<shadow_r sid="blender_shadow_r">0</shadow_r>
|
||||
<sky_colorspace>0</sky_colorspace>
|
||||
<sky_exposure>1</sky_exposure>
|
||||
<skyblendfac>1</skyblendfac>
|
||||
<skyblendtype>1</skyblendtype>
|
||||
<soft>3</soft>
|
||||
<spotblend>0.15</spotblend>
|
||||
<spotsize>75</spotsize>
|
||||
<spread>1</spread>
|
||||
<sun_brightness>1</sun_brightness>
|
||||
<sun_effect_type>0</sun_effect_type>
|
||||
<sun_intensity>1</sun_intensity>
|
||||
<sun_size>1</sun_size>
|
||||
<type>0</type>
|
||||
</technique>
|
||||
</extra>
|
||||
</light>
|
||||
<light id="Sun-light" name="Sun">
|
||||
<technique_common>
|
||||
<directional>
|
||||
<color sid="color">1 1 1</color>
|
||||
</directional>
|
||||
</technique_common>
|
||||
<extra>
|
||||
<technique profile="blender">
|
||||
<adapt_thresh>0.000999987</adapt_thresh>
|
||||
<area_shape>0</area_shape>
|
||||
<area_size>0.1</area_size>
|
||||
<area_sizey>0.1</area_sizey>
|
||||
<area_sizez>0.1</area_sizez>
|
||||
<atm_distance_factor>1</atm_distance_factor>
|
||||
<atm_extinction_factor>1</atm_extinction_factor>
|
||||
<atm_turbidity>2</atm_turbidity>
|
||||
<att1>0</att1>
|
||||
<att2>1</att2>
|
||||
<backscattered_light>1</backscattered_light>
|
||||
<bias>1</bias>
|
||||
<blue>1</blue>
|
||||
<buffers>1</buffers>
|
||||
<bufflag>0</bufflag>
|
||||
<bufsize>512</bufsize>
|
||||
<buftype>2</buftype>
|
||||
<clipend>40</clipend>
|
||||
<clipsta>0.5</clipsta>
|
||||
<compressthresh>0.04999995</compressthresh>
|
||||
<dist sid="blender_dist">25</dist>
|
||||
<energy sid="blender_energy">1</energy>
|
||||
<falloff_type>2</falloff_type>
|
||||
<filtertype>0</filtertype>
|
||||
<flag>0</flag>
|
||||
<gamma sid="blender_gamma">1</gamma>
|
||||
<green>1</green>
|
||||
<halo_intensity sid="blnder_halo_intensity">1</halo_intensity>
|
||||
<horizon_brightness>1</horizon_brightness>
|
||||
<mode>1</mode>
|
||||
<ray_samp>1</ray_samp>
|
||||
<ray_samp_method>1</ray_samp_method>
|
||||
<ray_samp_type>0</ray_samp_type>
|
||||
<ray_sampy>1</ray_sampy>
|
||||
<ray_sampz>1</ray_sampz>
|
||||
<red>1</red>
|
||||
<samp>3</samp>
|
||||
<shadhalostep>0</shadhalostep>
|
||||
<shadow_b sid="blender_shadow_b">0</shadow_b>
|
||||
<shadow_g sid="blender_shadow_g">0</shadow_g>
|
||||
<shadow_r sid="blender_shadow_r">0</shadow_r>
|
||||
<sky_colorspace>2</sky_colorspace>
|
||||
<sky_exposure>1</sky_exposure>
|
||||
<skyblendfac>1</skyblendfac>
|
||||
<skyblendtype>1</skyblendtype>
|
||||
<soft>3</soft>
|
||||
<spotblend>0.15</spotblend>
|
||||
<spotsize>45</spotsize>
|
||||
<spread>1</spread>
|
||||
<sun_brightness>1</sun_brightness>
|
||||
<sun_effect_type>0</sun_effect_type>
|
||||
<sun_intensity>1</sun_intensity>
|
||||
<sun_size>1</sun_size>
|
||||
<type>1</type>
|
||||
</technique>
|
||||
</extra>
|
||||
</light>
|
||||
<light id="Spot-light" name="Spot">
|
||||
<technique_common>
|
||||
<spot>
|
||||
<color sid="color">1 1 1</color>
|
||||
<constant_attenuation>1</constant_attenuation>
|
||||
<linear_attenuation>0</linear_attenuation>
|
||||
<quadratic_attenuation>0.001599967</quadratic_attenuation>
|
||||
<falloff_angle sid="fall_off_angle">45</falloff_angle>
|
||||
<falloff_exponent sid="fall_off_exponent">0.15</falloff_exponent>
|
||||
</spot>
|
||||
</technique_common>
|
||||
<extra>
|
||||
<technique profile="blender">
|
||||
<adapt_thresh>0.000999987</adapt_thresh>
|
||||
<area_shape>0</area_shape>
|
||||
<area_size>0.1</area_size>
|
||||
<area_sizey>0.1</area_sizey>
|
||||
<area_sizez>0.1</area_sizez>
|
||||
<atm_distance_factor>1</atm_distance_factor>
|
||||
<atm_extinction_factor>1</atm_extinction_factor>
|
||||
<atm_turbidity>2</atm_turbidity>
|
||||
<att1>0</att1>
|
||||
<att2>1</att2>
|
||||
<backscattered_light>1</backscattered_light>
|
||||
<bias>1</bias>
|
||||
<blue>1</blue>
|
||||
<buffers>1</buffers>
|
||||
<bufflag>0</bufflag>
|
||||
<bufsize>512</bufsize>
|
||||
<buftype>2</buftype>
|
||||
<clipend>40</clipend>
|
||||
<clipsta>0.5</clipsta>
|
||||
<compressthresh>0.04999995</compressthresh>
|
||||
<dist sid="blender_dist">25</dist>
|
||||
<energy sid="blender_energy">1</energy>
|
||||
<falloff_type>2</falloff_type>
|
||||
<filtertype>0</filtertype>
|
||||
<flag>0</flag>
|
||||
<gamma sid="blender_gamma">1</gamma>
|
||||
<green>1</green>
|
||||
<halo_intensity sid="blnder_halo_intensity">1</halo_intensity>
|
||||
<horizon_brightness>1</horizon_brightness>
|
||||
<mode>1</mode>
|
||||
<ray_samp>1</ray_samp>
|
||||
<ray_samp_method>1</ray_samp_method>
|
||||
<ray_samp_type>0</ray_samp_type>
|
||||
<ray_sampy>1</ray_sampy>
|
||||
<ray_sampz>1</ray_sampz>
|
||||
<red>1</red>
|
||||
<samp>3</samp>
|
||||
<shadhalostep>0</shadhalostep>
|
||||
<shadow_b sid="blender_shadow_b">0</shadow_b>
|
||||
<shadow_g sid="blender_shadow_g">0</shadow_g>
|
||||
<shadow_r sid="blender_shadow_r">0</shadow_r>
|
||||
<sky_colorspace>2</sky_colorspace>
|
||||
<sky_exposure>1</sky_exposure>
|
||||
<skyblendfac>1</skyblendfac>
|
||||
<skyblendtype>1</skyblendtype>
|
||||
<soft>3</soft>
|
||||
<spotblend>0.15</spotblend>
|
||||
<spotsize>45</spotsize>
|
||||
<spread>1</spread>
|
||||
<sun_brightness>1</sun_brightness>
|
||||
<sun_effect_type>0</sun_effect_type>
|
||||
<sun_intensity>1</sun_intensity>
|
||||
<sun_size>1</sun_size>
|
||||
<type>2</type>
|
||||
</technique>
|
||||
</extra>
|
||||
</light>
|
||||
<light id="Hemi-light" name="Hemi">
|
||||
<technique_common>
|
||||
<ambient>
|
||||
<color>1 1 1</color>
|
||||
</ambient>
|
||||
</technique_common>
|
||||
<extra>
|
||||
<technique profile="blender">
|
||||
<adapt_thresh>0.000999987</adapt_thresh>
|
||||
<area_shape>0</area_shape>
|
||||
<area_size>0.1</area_size>
|
||||
<area_sizey>0.1</area_sizey>
|
||||
<area_sizez>0.1</area_sizez>
|
||||
<atm_distance_factor>1</atm_distance_factor>
|
||||
<atm_extinction_factor>1</atm_extinction_factor>
|
||||
<atm_turbidity>2</atm_turbidity>
|
||||
<att1>0</att1>
|
||||
<att2>1</att2>
|
||||
<backscattered_light>1</backscattered_light>
|
||||
<bias>1</bias>
|
||||
<blue>1</blue>
|
||||
<buffers>1</buffers>
|
||||
<bufflag>0</bufflag>
|
||||
<bufsize>512</bufsize>
|
||||
<buftype>2</buftype>
|
||||
<clipend>40</clipend>
|
||||
<clipsta>0.5</clipsta>
|
||||
<compressthresh>0.04999995</compressthresh>
|
||||
<dist sid="blender_dist">25</dist>
|
||||
<energy sid="blender_energy">1</energy>
|
||||
<falloff_type>2</falloff_type>
|
||||
<filtertype>0</filtertype>
|
||||
<flag>0</flag>
|
||||
<gamma sid="blender_gamma">1</gamma>
|
||||
<green>1</green>
|
||||
<halo_intensity sid="blnder_halo_intensity">1</halo_intensity>
|
||||
<horizon_brightness>1</horizon_brightness>
|
||||
<mode>1</mode>
|
||||
<ray_samp>1</ray_samp>
|
||||
<ray_samp_method>1</ray_samp_method>
|
||||
<ray_samp_type>0</ray_samp_type>
|
||||
<ray_sampy>1</ray_sampy>
|
||||
<ray_sampz>1</ray_sampz>
|
||||
<red>1</red>
|
||||
<samp>3</samp>
|
||||
<shadhalostep>0</shadhalostep>
|
||||
<shadow_b sid="blender_shadow_b">0</shadow_b>
|
||||
<shadow_g sid="blender_shadow_g">0</shadow_g>
|
||||
<shadow_r sid="blender_shadow_r">0</shadow_r>
|
||||
<sky_colorspace>2</sky_colorspace>
|
||||
<sky_exposure>1</sky_exposure>
|
||||
<skyblendfac>1</skyblendfac>
|
||||
<skyblendtype>1</skyblendtype>
|
||||
<soft>3</soft>
|
||||
<spotblend>0.15</spotblend>
|
||||
<spotsize>45</spotsize>
|
||||
<spread>1</spread>
|
||||
<sun_brightness>1</sun_brightness>
|
||||
<sun_effect_type>0</sun_effect_type>
|
||||
<sun_intensity>1</sun_intensity>
|
||||
<sun_size>1</sun_size>
|
||||
<type>3</type>
|
||||
</technique>
|
||||
</extra>
|
||||
</light>
|
||||
<light id="Area-light" name="Area">
|
||||
<technique_common>
|
||||
<point>
|
||||
<color sid="color">1 1 1</color>
|
||||
<constant_attenuation>1</constant_attenuation>
|
||||
<linear_attenuation>0</linear_attenuation>
|
||||
<quadratic_attenuation>0.001599967</quadratic_attenuation>
|
||||
</point>
|
||||
</technique_common>
|
||||
<extra>
|
||||
<technique profile="blender">
|
||||
<adapt_thresh>0.000999987</adapt_thresh>
|
||||
<area_shape>0</area_shape>
|
||||
<area_size>0.1</area_size>
|
||||
<area_sizey>0.1</area_sizey>
|
||||
<area_sizez>0.1</area_sizez>
|
||||
<atm_distance_factor>1</atm_distance_factor>
|
||||
<atm_extinction_factor>1</atm_extinction_factor>
|
||||
<atm_turbidity>2</atm_turbidity>
|
||||
<att1>0</att1>
|
||||
<att2>1</att2>
|
||||
<backscattered_light>1</backscattered_light>
|
||||
<bias>1</bias>
|
||||
<blue>1</blue>
|
||||
<buffers>1</buffers>
|
||||
<bufflag>0</bufflag>
|
||||
<bufsize>512</bufsize>
|
||||
<buftype>2</buftype>
|
||||
<clipend>40</clipend>
|
||||
<clipsta>0.5</clipsta>
|
||||
<compressthresh>0.04999995</compressthresh>
|
||||
<dist sid="blender_dist">25</dist>
|
||||
<energy sid="blender_energy">1</energy>
|
||||
<falloff_type>2</falloff_type>
|
||||
<filtertype>0</filtertype>
|
||||
<flag>0</flag>
|
||||
<gamma sid="blender_gamma">1</gamma>
|
||||
<green>1</green>
|
||||
<halo_intensity sid="blnder_halo_intensity">1</halo_intensity>
|
||||
<horizon_brightness>1</horizon_brightness>
|
||||
<mode>1</mode>
|
||||
<ray_samp>1</ray_samp>
|
||||
<ray_samp_method>1</ray_samp_method>
|
||||
<ray_samp_type>0</ray_samp_type>
|
||||
<ray_sampy>1</ray_sampy>
|
||||
<ray_sampz>1</ray_sampz>
|
||||
<red>1</red>
|
||||
<samp>3</samp>
|
||||
<shadhalostep>0</shadhalostep>
|
||||
<shadow_b sid="blender_shadow_b">0</shadow_b>
|
||||
<shadow_g sid="blender_shadow_g">0</shadow_g>
|
||||
<shadow_r sid="blender_shadow_r">0</shadow_r>
|
||||
<sky_colorspace>2</sky_colorspace>
|
||||
<sky_exposure>1</sky_exposure>
|
||||
<skyblendfac>1</skyblendfac>
|
||||
<skyblendtype>1</skyblendtype>
|
||||
<soft>3</soft>
|
||||
<spotblend>0.15</spotblend>
|
||||
<spotsize>45</spotsize>
|
||||
<spread>1</spread>
|
||||
<sun_brightness>1</sun_brightness>
|
||||
<sun_effect_type>0</sun_effect_type>
|
||||
<sun_intensity>1</sun_intensity>
|
||||
<sun_size>1</sun_size>
|
||||
<type>4</type>
|
||||
</technique>
|
||||
</extra>
|
||||
</light>
|
||||
</library_lights>
|
||||
<library_images/>
|
||||
<library_controllers/>
|
||||
<library_visual_scenes>
|
||||
<visual_scene id="Scene" name="Scene">
|
||||
<node id="Lamp" name="Lamp" type="NODE">
|
||||
<matrix sid="transform">1 0 0 0 0 1 0 1 0 0 1 1 0 0 0 1</matrix>
|
||||
<instance_light url="#Lamp-light"/>
|
||||
</node>
|
||||
<node id="Sun" name="Sun" type="NODE">
|
||||
<matrix sid="transform">1 0 0 7.076701 0 1 0 -5.572294 0 0 1 5.147222 0 0 0 1</matrix>
|
||||
<instance_light url="#Sun-light"/>
|
||||
</node>
|
||||
<node id="Spot" name="Spot" type="NODE">
|
||||
<matrix sid="transform">1 0 0 8.888217 0 1 0 -5.016863 0 0 1 5.336025 0 0 0 1</matrix>
|
||||
<instance_light url="#Spot-light"/>
|
||||
</node>
|
||||
<node id="Hemi" name="Hemi" type="NODE">
|
||||
<matrix sid="transform">1 0 0 7.326984 0 1 0 -4.602942 0 0 1 5.554852 0 0 0 1</matrix>
|
||||
<instance_light url="#Hemi-light"/>
|
||||
</node>
|
||||
<node id="Area" name="Area" type="NODE">
|
||||
<matrix sid="transform">1 0 0 8.063721 0 1 0 -4.19857 0 0 1 5.273283 0 0 0 1</matrix>
|
||||
<instance_light url="#Area-light"/>
|
||||
</node>
|
||||
</visual_scene>
|
||||
</library_visual_scenes>
|
||||
<scene>
|
||||
<instance_visual_scene url="#Scene"/>
|
||||
</scene>
|
||||
</COLLADA>
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* ColladaCameraExporter.cpp
|
||||
*
|
||||
* Created on: May 17, 2015
|
||||
* Author: wise
|
||||
*/
|
||||
|
||||
|
||||
#include "UnitTestPCH.h"
|
||||
|
||||
#include <assimp/cexport.h>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
|
||||
class ColladaExportCamera : 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(ColladaExportCamera, testExportCamera)
|
||||
{
|
||||
const char* file = "cameraExp.dae";
|
||||
|
||||
const aiScene* pTest = im->ReadFile("../test/models/Collada/cameras.dae",0);
|
||||
ASSERT_TRUE(pTest!=NULL);
|
||||
ASSERT_TRUE(pTest->HasCameras());
|
||||
|
||||
|
||||
EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
|
||||
|
||||
const aiScene* imported = im->ReadFile(file,0);
|
||||
|
||||
ASSERT_TRUE(imported!=NULL);
|
||||
|
||||
EXPECT_TRUE(imported->HasCameras());
|
||||
EXPECT_EQ(pTest->mNumCameras,imported->mNumCameras);
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* ColladaCameraExporter.cpp
|
||||
*
|
||||
* Created on: May 17, 2015
|
||||
* Author: wise
|
||||
*/
|
||||
|
||||
|
||||
#include "UnitTestPCH.h"
|
||||
|
||||
#include <assimp/cexport.h>
|
||||
#include <assimp/Exporter.hpp>
|
||||
#include <assimp/Importer.hpp>
|
||||
#include <assimp/scene.h>
|
||||
|
||||
#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->mNumLights;i++){
|
||||
|
||||
const aiLight *orig = pTest->mLights[i];
|
||||
const aiLight *read = imported->mLights[i];
|
||||
|
||||
EXPECT_TRUE(orig->mName==read->mName);
|
||||
EXPECT_EQ(orig->mType,read->mType);
|
||||
EXPECT_FLOAT_EQ(orig->mAttenuationConstant,read->mAttenuationConstant);
|
||||
EXPECT_FLOAT_EQ(orig->mAttenuationLinear,read->mAttenuationLinear);
|
||||
EXPECT_FLOAT_EQ(orig->mAttenuationQuadratic,read->mAttenuationQuadratic);
|
||||
|
||||
EXPECT_FLOAT_EQ(orig->mColorAmbient.r,read->mColorAmbient.r);
|
||||
EXPECT_FLOAT_EQ(orig->mColorAmbient.g,read->mColorAmbient.g);
|
||||
EXPECT_FLOAT_EQ(orig->mColorAmbient.b,read->mColorAmbient.b);
|
||||
|
||||
EXPECT_FLOAT_EQ(orig->mColorDiffuse.r,read->mColorDiffuse.r);
|
||||
EXPECT_FLOAT_EQ(orig->mColorDiffuse.g,read->mColorDiffuse.g);
|
||||
EXPECT_FLOAT_EQ(orig->mColorDiffuse.b,read->mColorDiffuse.b);
|
||||
|
||||
EXPECT_FLOAT_EQ(orig->mColorSpecular.r,read->mColorSpecular.r);
|
||||
EXPECT_FLOAT_EQ(orig->mColorSpecular.g,read->mColorSpecular.g);
|
||||
EXPECT_FLOAT_EQ(orig->mColorSpecular.b,read->mColorSpecular.b);
|
||||
|
||||
EXPECT_NEAR(orig->mAngleInnerCone,read->mAngleInnerCone,0.001);
|
||||
EXPECT_NEAR(orig->mAngleOuterCone,read->mAngleOuterCone,0.001);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue