diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | config/linux2-config.py | 2 | ||||
-rw-r--r-- | config/win32-vc-config.py | 2 | ||||
-rw-r--r-- | projectfiles_vc9/blender/blender.vcproj | 4 | ||||
-rw-r--r-- | source/blender/collada/DocumentExporter.cpp | 76 | ||||
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 29 |
6 files changed, 71 insertions, 44 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 45b13e4b647..71830870d03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,7 +217,7 @@ IF(UNIX AND NOT APPLE) IF (WITH_OPENCOLLADA) SET(OPENCOLLADA /usr/local/opencollada CACHE FILEPATH "OpenCollada Directory") SET(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib) - SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa Buffer) + SET(OPENCOLLADA_LIB OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre ftoa buffer) SET(OPENCOLLADA_INC ${OPENCOLLADA}) SET(PCRE /usr CACHE FILEPATH "PCRE Directory") SET(PCRE_LIBPATH ${PCRE}/lib) diff --git a/config/linux2-config.py b/config/linux2-config.py index abe79ba5806..4314199f386 100644 --- a/config/linux2-config.py +++ b/config/linux2-config.py @@ -156,7 +156,7 @@ BF_COLLADA = '#source/blender/collada' BF_COLLADA_INC = '${BF_COLLADA}' BF_COLLADA_LIB = 'bf_collada' BF_OPENCOLLADA = '/usr' -BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre Buffer ftoa' +BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre buffer ftoa' BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib' BF_PCRE = '' BF_PCRE_LIB = 'pcre' diff --git a/config/win32-vc-config.py b/config/win32-vc-config.py index f18ed3e2007..4799f91647c 100644 --- a/config/win32-vc-config.py +++ b/config/win32-vc-config.py @@ -145,7 +145,7 @@ BF_COLLADA_LIB = 'bf_collada' BF_OPENCOLLADA = LIBDIR + '/opencollada' BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include' -BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver xml2 pcre' +BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver xml2 pcre buffer ftoa' BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib' #Ray trace optimization diff --git a/projectfiles_vc9/blender/blender.vcproj b/projectfiles_vc9/blender/blender.vcproj index 0d7f3c66ff0..5fda32fdefc 100644 --- a/projectfiles_vc9/blender/blender.vcproj +++ b/projectfiles_vc9/blender/blender.vcproj @@ -74,7 +74,7 @@ <Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
- AdditionalDependencies="libsamplerate.lib SDL.lib freetype2ST.lib gnu_gettext.lib qtmlClient.lib OpenAL32.lib wrap_oal.lib ws2_32.lib dxguid.lib opengl32.lib libjpeg.lib glu32.lib vfw32.lib winmm.lib libpng_st.lib zlib.lib python31.lib pthreadVSE2.lib pthreadVC2.lib libtiff.lib Half.lib Iex.lib IlmImf.lib Imath.lib IlmThread.lib avcodec-52.lib avformat-52.lib avutil-50.lib swscale-0.lib avdevice-52.lib libsndfile-1.lib OpenCOLLADABaseUtils.lib OpenCOLLADAFramework.lib OpenCOLLADAStreamWriter.lib OpenCOLLADASaxFrameworkLoader.lib pcre.lib UTF.lib GeneratedSaxParser.lib MathMLSolver.lib xml2.lib"
+ AdditionalDependencies="libsamplerate.lib SDL.lib freetype2ST.lib gnu_gettext.lib qtmlClient.lib OpenAL32.lib wrap_oal.lib ws2_32.lib dxguid.lib opengl32.lib libjpeg.lib glu32.lib vfw32.lib winmm.lib libpng_st.lib zlib.lib python31.lib pthreadVSE2.lib pthreadVC2.lib libtiff.lib Half.lib Iex.lib IlmImf.lib Imath.lib IlmThread.lib avcodec-52.lib avformat-52.lib avutil-50.lib swscale-0.lib avdevice-52.lib libsndfile-1.lib OpenCOLLADABaseUtils.lib OpenCOLLADAFramework.lib OpenCOLLADAStreamWriter.lib OpenCOLLADASaxFrameworkLoader.lib pcre.lib UTF.lib GeneratedSaxParser.lib MathMLSolver.lib xml2.lib buffer.lib ftoa.lib"
ShowProgress="0"
OutputFile="..\..\..\install\msvc_9\blender.exe"
LinkIncremental="1"
@@ -169,7 +169,7 @@ <Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386
"
- AdditionalDependencies="libsamplerate.lib SDL.lib freetype2ST.lib gnu_gettext.lib qtmlClient.lib OpenAL32.lib wrap_oal.lib ws2_32.lib dxguid.lib opengl32.lib libjpeg.lib glu32.lib vfw32.lib winmm.lib libpng_st.lib zlib.lib python31_d.lib pthreadVSE2.lib pthreadVC2.lib libtiff.lib Half_d.lib Iex_d.lib Imath_d.lib IlmImf_d.lib IlmThread_d.lib avcodec-52.lib avformat-52.lib avdevice-52.lib avutil-50.lib swscale-0.lib libsndfile-1.lib OpenCOLLADABaseUtils_d.lib OpenCOLLADAFramework_d.lib OpenCOLLADAStreamWriter_d.lib OpenCOLLADASaxFrameworkLoader_d.lib pcre_d.lib UTF_d.lib GeneratedSaxParser_d.lib MathMLSolver_d.lib xml2_d.lib"
+ AdditionalDependencies="libsamplerate.lib SDL.lib freetype2ST.lib gnu_gettext.lib qtmlClient.lib OpenAL32.lib wrap_oal.lib ws2_32.lib dxguid.lib opengl32.lib libjpeg.lib glu32.lib vfw32.lib winmm.lib libpng_st.lib zlib.lib python31_d.lib pthreadVSE2.lib pthreadVC2.lib libtiff.lib Half_d.lib Iex_d.lib Imath_d.lib IlmImf_d.lib IlmThread_d.lib avcodec-52.lib avformat-52.lib avdevice-52.lib avutil-50.lib swscale-0.lib libsndfile-1.lib OpenCOLLADABaseUtils_d.lib OpenCOLLADAFramework_d.lib OpenCOLLADAStreamWriter_d.lib OpenCOLLADASaxFrameworkLoader_d.lib pcre_d.lib UTF_d.lib GeneratedSaxParser_d.lib MathMLSolver_d.lib xml2_d.lib buffer_d.lib ftoa_d.lib"
ShowProgress="0"
OutputFile="..\..\..\install\msvc_9d\blender.exe"
LinkIncremental="2"
diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index f0dd24a735f..8a815418369 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -669,7 +669,7 @@ class TransformWriter : protected TransformBase protected: void add_node_transform(COLLADASW::Node& node, float mat[][4], float parent_mat[][4]) { - float loc[3], rot[3], size[3]; + float loc[3], rot[3], scale[3]; float local[4][4]; if (parent_mat) { @@ -681,27 +681,61 @@ protected: copy_m4_m4(local, mat); } - TransformBase::decompose(local, loc, rot, NULL, size); + TransformBase::decompose(local, loc, rot, NULL, scale); - /* - // this code used to create a single <rotate> representing object rotation - float quat[4]; - float axis[3]; - float angle; - double angle_deg; - eul_to_quat( quat,rot); - normalize_qt(quat); - quat_to_axis_angle( axis, &angle,quat); - angle_deg = angle * 180.0f / M_PI; - node.addRotate(axis[0], axis[1], axis[2], angle_deg); - */ - node.addTranslate("location", loc[0], loc[1], loc[2]); + add_transform(node, loc, rot, scale); + } + + void add_node_transform_ob(COLLADASW::Node& node, Object *ob) + { + float rot[3], loc[3], scale[3]; + + if (ob->parent) { + float C[4][4], D[4][4], tmat[4][4], imat[4][4], mat[4][4]; + + // factor out scale from obmat + + copy_v3_v3(scale, ob->size); + + ob->size[0] = ob->size[1] = ob->size[2] = 1.0f; + object_to_mat4(ob, C); + copy_v3_v3(ob->size, scale); + + mul_serie_m4(tmat, ob->parent->obmat, ob->parentinv, C, NULL, NULL, NULL, NULL, NULL); + + // calculate local mat + + invert_m4_m4(imat, ob->parent->obmat); + mul_m4_m4m4(mat, tmat, imat); + + // done + + mat4_to_eul(rot, mat); + copy_v3_v3(loc, mat[3]); + } + else { + copy_v3_v3(loc, ob->loc); + copy_v3_v3(rot, ob->rot); + copy_v3_v3(scale, ob->size); + } + + add_transform(node, loc, rot, scale); + } + + void add_node_transform_identity(COLLADASW::Node& node) + { + float loc[] = {0.0f, 0.0f, 0.0f}, scale[] = {1.0f, 1.0f, 1.0f}, rot[] = {0.0f, 0.0f, 0.0f}; + add_transform(node, loc, rot, scale); + } +private: + void add_transform(COLLADASW::Node& node, float loc[3], float rot[3], float scale[3]) + { + node.addTranslate("location", loc[0], loc[1], loc[2]); node.addRotateZ("rotationZ", COLLADABU::Math::Utils::radToDegF(rot[2])); node.addRotateY("rotationY", COLLADABU::Math::Utils::radToDegF(rot[1])); node.addRotateX("rotationX", COLLADABU::Math::Utils::radToDegF(rot[0])); - - node.addScale("scale", size[0], size[1], size[2]); + node.addScale("scale", scale[0], scale[1], scale[2]); } }; @@ -1238,15 +1272,11 @@ public: bool is_skinned_mesh = arm_exporter->is_skinned_mesh(ob); - float mat[4][4]; - if (ob->type == OB_MESH && is_skinned_mesh) // for skinned mesh we write obmat in <bind_shape_matrix> - unit_m4(mat); + TransformWriter::add_node_transform_identity(node); else - copy_m4_m4(mat, ob->obmat); - - TransformWriter::add_node_transform(node, mat, ob->parent ? ob->parent->obmat : NULL); + TransformWriter::add_node_transform_ob(node, ob); // <instance_geometry> if (ob->type == OB_MESH) { diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 39424797df6..8078ee2e6e0 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -1564,15 +1564,13 @@ public: return NULL; } - MTex *assign_textures_to_uvlayer(COLLADAFW::InstanceGeometry::TextureCoordinateBinding &ctexture, + MTex *assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture, Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map, MTex *color_texture) { - - COLLADAFW::TextureMapId texture_index = ctexture.textureMapId; - - char *uvname = CustomData_get_layer_name(&me->fdata, CD_MTFACE, ctexture.setIndex); - + COLLADAFW::TextureMapId texture_index = ctexture.getTextureMapId(); + char *uvname = CustomData_get_layer_name(&me->fdata, CD_MTFACE, ctexture.getSetIndex()); + if (texindex_texarray_map.find(texture_index) == texindex_texarray_map.end()) { fprintf(stderr, "Cannot find texture array by texture index.\n"); @@ -1595,7 +1593,7 @@ public: return color_texture; } - MTFace *assign_material_to_geom(COLLADAFW::InstanceGeometry::MaterialBinding cmaterial, + MTFace *assign_material_to_geom(COLLADAFW::MaterialBinding cmaterial, std::map<COLLADAFW::UniqueId, Material*>& uid_material_map, Object *ob, const COLLADAFW::UniqueId *geom_uid, MTex **color_texture, char *layername, MTFace *texture_face, @@ -1614,7 +1612,7 @@ public: Material *ma = uid_material_map[ma_uid]; assign_material(ob, ma, ob->totcol + 1); - COLLADAFW::InstanceGeometry::TextureCoordinateBindingArray& tex_array = + COLLADAFW::TextureCoordinateBindingArray& tex_array = cmaterial.getTextureCoordinateBindingArray(); TexIndexTextureArrayMap texindex_texarray_map = material_texture_mapping_map[ma]; unsigned int i; @@ -1714,7 +1712,7 @@ public: MTFace *texture_face = NULL; MTex *color_texture = NULL; - COLLADAFW::InstanceGeometry::MaterialBindingArray& mat_array = + COLLADAFW::MaterialBindingArray& mat_array = geom->getMaterialBindings(); // loop through geom's materials @@ -3130,7 +3128,7 @@ public: ob = create_lamp_object(lamp[0], ob, sce); } else if (controller.getCount() != 0) { - COLLADAFW::InstanceController *geom = (COLLADAFW::InstanceController*)controller[0]; + COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry*)controller[0]; ob = mesh_importer.create_mesh_object(node, geom, true, uid_material_map, material_texture_mapping_map); } // XXX instance_node is not supported yet @@ -3284,7 +3282,6 @@ public: int i = 0; COLLADAFW::Color col; - COLLADAFW::Texture ctex; MTex *mtex = NULL; TexIndexTextureArrayMap texindex_texarray_map; @@ -3298,7 +3295,7 @@ public: } // texture else if (ef->getDiffuse().isTexture()) { - ctex = ef->getDiffuse().getTexture(); + COLLADAFW::Texture ctex = ef->getDiffuse().getTexture(); mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); if (mtex != NULL) { mtex->mapto = MAP_COL; @@ -3316,7 +3313,7 @@ public: } // texture else if (ef->getAmbient().isTexture()) { - ctex = ef->getAmbient().getTexture(); + COLLADAFW::Texture ctex = ef->getAmbient().getTexture(); mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); if (mtex != NULL) { mtex->mapto = MAP_AMB; @@ -3333,7 +3330,7 @@ public: } // texture else if (ef->getSpecular().isTexture()) { - ctex = ef->getSpecular().getTexture(); + COLLADAFW::Texture ctex = ef->getSpecular().getTexture(); mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); if (mtex != NULL) { mtex->mapto = MAP_SPEC; @@ -3350,7 +3347,7 @@ public: } // texture else if (ef->getReflective().isTexture()) { - ctex = ef->getReflective().getTexture(); + COLLADAFW::Texture ctex = ef->getReflective().getTexture(); mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); if (mtex != NULL) { mtex->mapto = MAP_REF; @@ -3365,7 +3362,7 @@ public: } // texture else if (ef->getEmission().isTexture()) { - ctex = ef->getEmission().getTexture(); + COLLADAFW::Texture ctex = ef->getEmission().getTexture(); mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map); if (mtex != NULL) { mtex->mapto = MAP_EMIT; |