Commit to cope with API changes in OpenCOLLADA (latest for Windows right now r827).
authorNathan Letwory <nathan@letworyinteractive.com>
Thu, 27 Jan 2011 19:39:06 +0000 (19:39 +0000)
committerNathan Letwory <nathan@letworyinteractive.com>
Thu, 27 Jan 2011 19:39:06 +0000 (19:39 +0000)
CMakeLists.txt
SConstruct
build_files/scons/config/win32-vc-config.py
build_files/scons/config/win64-vc-config.py
source/blender/collada/ArmatureExporter.cpp
source/blender/collada/DocumentExporter.cpp
source/blender/collada/GeometryExporter.cpp
source/blender/collada/GeometryExporter.h
source/blender/collada/MeshImporter.cpp
source/blender/collada/MeshImporter.h

index 92c0fae57bd76d76f0b84aa8e6d3691b9de4165e..71a52c0c928982671de3191cf4ed1c2f6e09fb39 100644 (file)
@@ -528,7 +528,7 @@ elseif(WIN32)
                        set(OPENCOLLADA ${LIBDIR}/opencollada)
                        set(OPENCOLLADA_INC ${OPENCOLLADA}/include)
                        set(OPENCOLLADA_LIBPATH ${OPENCOLLADA}/lib)
-                       set(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa)
+                       set(OPENCOLLADA_LIB OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils OpenCOLLADAStreamWriter MathMLSolver GeneratedSaxParser xml2 buffer ftoa UTF)
                        set(PCRE_LIB pcre)
                endif()
                
index 48397347073e38c425b23e46fc5d57ba5ea743cf..afc7171b539a36a1abbd512f3a8078d6a3e289a3 100644 (file)
@@ -143,6 +143,11 @@ if not env:
     Exit()
 
 
+env.Append(RCFLAGS="TEST=\"test it\"")
+print env['RCFLAGS']
+Exit()
+
+
 cc = B.arguments.get('CC', None)
 cxx = B.arguments.get('CXX', None)
 if cc:
index a2d5c5af712e63beb0653b3946fe2689423e2536..219e7e0bce3795261c343a239a89b1b61441e6ee 100644 (file)
@@ -146,7 +146,7 @@ BF_COLLADA_LIB = 'bf_collada'
 
 BF_OPENCOLLADA = LIBDIR + '/opencollada'
 BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
-BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser MathMLSolver xml2 pcre buffer ftoa'
+BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser MathMLSolver xml2 pcre buffer ftoa UTF'
 BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
 
 WITH_BF_LCMS = False
index 5660b4c89882daf7cebd1d34db85a16f7457d0f7..950f9257b9933ee7ffa1a40336eea0bc8ebe0a9b 100644 (file)
@@ -148,7 +148,7 @@ BF_COLLADA_LIB = 'bf_collada'
 
 BF_OPENCOLLADA = LIBDIR + '/opencollada'
 BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include'
-BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser MathMLSolver xml2 pcre buffer ftoa'
+BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser MathMLSolver xml2 pcre buffer ftoa UTF'
 BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib'
 
 WITH_BF_LCMS = False
index 255fb03da10ad9998a5ab23f1fdc54ffab917405..1427c3331758a777de2641e5fc8f0c4fdc84c0a2 100644 (file)
@@ -265,9 +265,9 @@ void ArmatureExporter::add_joints_element(ListBase *defbase,
        COLLADASW::JointsElement joints(mSW);
        COLLADASW::InputList &input = joints.getInputList();
 
-       input.push_back(COLLADASW::Input(COLLADASW::JOINT, // constant declared in COLLADASWInputList.h
+       input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::JOINT, // constant declared in COLLADASWInputList.h
                                                           COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, joints_source_id)));
-       input.push_back(COLLADASW::Input(COLLADASW::BINDMATRIX,
+       input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::BINDMATRIX,
                                                           COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, inv_bind_mat_source_id)));
        joints.add();
 }
@@ -425,9 +425,9 @@ void ArmatureExporter::add_vertex_weights_element(const std::string& weights_sou
        COLLADASW::InputList &input = weights.getInputList();
 
        int offset = 0;
-       input.push_back(COLLADASW::Input(COLLADASW::JOINT, // constant declared in COLLADASWInputList.h
+       input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::JOINT, // constant declared in COLLADASWInputList.h
                                                                         COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, joints_source_id), offset++));
-       input.push_back(COLLADASW::Input(COLLADASW::WEIGHT,
+       input.push_back(COLLADASW::Input(COLLADASW::InputSemantic::WEIGHT,
                                                                         COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, weights_source_id), offset++));
 
        weights.setCount(me->totvert);
index 66a0b0cbdd49d0e1634858af756a549ca5f7fc42..ea91a42581a96d546d9bb139b705b9b210085808 100644 (file)
@@ -296,10 +296,11 @@ public:
 class AnimationExporter: COLLADASW::LibraryAnimations
 {
        Scene *scene;
+       COLLADASW::StreamWriter *sw;
 
 public:
 
-       AnimationExporter(COLLADASW::StreamWriter *sw): COLLADASW::LibraryAnimations(sw) {}
+       AnimationExporter(COLLADASW::StreamWriter *sw): COLLADASW::LibraryAnimations(sw) { this->sw = sw; }
 
        void exportAnimations(Scene *sce)
        {
@@ -357,22 +358,22 @@ protected:
                openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
 
                // create input source
-               std::string input_id = create_source_from_fcurve(Sampler::INPUT, fcu, anim_id, axis_name);
+               std::string input_id = create_source_from_fcurve(COLLADASW::InputSemantic::INPUT, fcu, anim_id, axis_name);
 
                // create output source
-               std::string output_id = create_source_from_fcurve(Sampler::OUTPUT, fcu, anim_id, axis_name);
+               std::string output_id = create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name);
 
                // create interpolations source
                std::string interpolation_id = create_interpolation_source(fcu->totvert, anim_id, axis_name);
 
                std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX;
-               COLLADASW::LibraryAnimations::Sampler sampler(sampler_id);
+               COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id);
                std::string empty;
-               sampler.addInput(Sampler::INPUT, COLLADABU::URI(empty, input_id));
-               sampler.addInput(Sampler::OUTPUT, COLLADABU::URI(empty, output_id));
+               sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id));
+               sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id));
 
                // this input is required
-               sampler.addInput(Sampler::INTERPOLATION, COLLADABU::URI(empty, interpolation_id));
+               sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id));
 
                addSampler(sampler);
 
@@ -533,28 +534,28 @@ protected:
                openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
 
                // create input source
-               std::string input_id = create_source_from_vector(Sampler::INPUT, fra, is_rot, anim_id, axis_name);
+               std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, fra, is_rot, anim_id, axis_name);
 
                // create output source
                std::string output_id;
                if (axis == -1)
                        output_id = create_xyz_source(v, fra.size(), anim_id);
                else
-                       output_id = create_source_from_array(Sampler::OUTPUT, v, fra.size(), is_rot, anim_id, axis_name);
+                       output_id = create_source_from_array(COLLADASW::InputSemantic::OUTPUT, v, fra.size(), is_rot, anim_id, axis_name);
 
                // create interpolations source
                std::string interpolation_id = create_interpolation_source(fra.size(), anim_id, axis_name);
 
                std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX;
-               COLLADASW::LibraryAnimations::Sampler sampler(sampler_id);
+               COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id);
                std::string empty;
-               sampler.addInput(Sampler::INPUT, COLLADABU::URI(empty, input_id));
-               sampler.addInput(Sampler::OUTPUT, COLLADABU::URI(empty, output_id));
+               sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id));
+               sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id));
 
                // TODO create in/out tangents source
 
                // this input is required
-               sampler.addInput(Sampler::INTERPOLATION, COLLADABU::URI(empty, interpolation_id));
+               sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id));
 
                addSampler(sampler);
 
@@ -574,18 +575,18 @@ protected:
                return COLLADABU::Math::Utils::radToDegF(angle);
        }
 
-       std::string get_semantic_suffix(Sampler::Semantic semantic)
+       std::string get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic)
        {
                switch(semantic) {
-               case Sampler::INPUT:
+               case COLLADASW::InputSemantic::INPUT:
                        return INPUT_SOURCE_ID_SUFFIX;
-               case Sampler::OUTPUT:
+               case COLLADASW::InputSemantic::OUTPUT:
                        return OUTPUT_SOURCE_ID_SUFFIX;
-               case Sampler::INTERPOLATION:
+               case COLLADASW::InputSemantic::INTERPOLATION:
                        return INTERPOLATION_SOURCE_ID_SUFFIX;
-               case Sampler::IN_TANGENT:
+               case COLLADASW::InputSemantic::IN_TANGENT:
                        return INTANGENT_SOURCE_ID_SUFFIX;
-               case Sampler::OUT_TANGENT:
+               case COLLADASW::InputSemantic::OUT_TANGENT:
                        return OUTTANGENT_SOURCE_ID_SUFFIX;
                default:
                        break;
@@ -594,13 +595,13 @@ protected:
        }
 
        void add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param,
-                                                          Sampler::Semantic semantic, bool is_rot, const char *axis)
+                                                          COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis)
        {
                switch(semantic) {
-               case Sampler::INPUT:
+               case COLLADASW::InputSemantic::INPUT:
                        param.push_back("TIME");
                        break;
-               case Sampler::OUTPUT:
+               case COLLADASW::InputSemantic::OUTPUT:
                        if (is_rot) {
                                param.push_back("ANGLE");
                        }
@@ -615,8 +616,8 @@ protected:
                                }
                        }
                        break;
-               case Sampler::IN_TANGENT:
-               case Sampler::OUT_TANGENT:
+               case COLLADASW::InputSemantic::IN_TANGENT:
+               case COLLADASW::InputSemantic::OUT_TANGENT:
                        param.push_back("X");
                        param.push_back("Y");
                        break;
@@ -625,14 +626,14 @@ protected:
                }
        }
 
-       void get_source_values(BezTriple *bezt, Sampler::Semantic semantic, bool rotation, float *values, int *length)
+       void get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool rotation, float *values, int *length)
        {
                switch (semantic) {
-               case Sampler::INPUT:
+               case COLLADASW::InputSemantic::INPUT:
                        *length = 1;
                        values[0] = convert_time(bezt->vec[1][0]);
                        break;
-               case Sampler::OUTPUT:
+               case COLLADASW::InputSemantic::OUTPUT:
                        *length = 1;
                        if (rotation) {
                                values[0] = convert_angle(bezt->vec[1][1]);
@@ -641,8 +642,8 @@ protected:
                                values[0] = bezt->vec[1][1];
                        }
                        break;
-               case Sampler::IN_TANGENT:
-               case Sampler::OUT_TANGENT:
+               case COLLADASW::InputSemantic::IN_TANGENT:
+               case COLLADASW::InputSemantic::OUT_TANGENT:
                        // XXX
                        *length = 2;
                        break;
@@ -652,7 +653,7 @@ protected:
                }
        }
 
-       std::string create_source_from_fcurve(Sampler::Semantic semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name)
+       std::string create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name)
        {
                std::string source_id = anim_id + get_semantic_suffix(semantic);
 
@@ -686,7 +687,7 @@ protected:
                return source_id;
        }
 
-       std::string create_source_from_array(Sampler::Semantic semantic, float *v, int tot, bool is_rot, const std::string& anim_id, const char *axis_name)
+       std::string create_source_from_array(COLLADASW::InputSemantic::Semantics semantic, float *v, int tot, bool is_rot, const std::string& anim_id, const char *axis_name)
        {
                std::string source_id = anim_id + get_semantic_suffix(semantic);
 
@@ -703,7 +704,7 @@ protected:
 
                for (int i = 0; i < tot; i++) {
                        float val = v[i];
-                       if (semantic == Sampler::INPUT)
+                       if (semantic == COLLADASW::InputSemantic::INPUT)
                                val = convert_time(val);
                        else if (is_rot)
                                val = convert_angle(val);
@@ -715,7 +716,7 @@ protected:
                return source_id;
        }
 
-       std::string create_source_from_vector(Sampler::Semantic semantic, std::vector<float> &fra, bool is_rot, const std::string& anim_id, const char *axis_name)
+       std::string create_source_from_vector(COLLADASW::InputSemantic::Semantics semantic, std::vector<float> &fra, bool is_rot, const std::string& anim_id, const char *axis_name)
        {
                std::string source_id = anim_id + get_semantic_suffix(semantic);
 
@@ -733,7 +734,7 @@ protected:
                std::vector<float>::iterator it;
                for (it = fra.begin(); it != fra.end(); it++) {
                        float val = *it;
-                       if (semantic == Sampler::INPUT)
+                       if (semantic == COLLADASW::InputSemantic::INPUT)
                                val = convert_time(val);
                        else if (is_rot)
                                val = convert_angle(val);
@@ -748,7 +749,7 @@ protected:
        // only used for sources with OUTPUT semantic
        std::string create_xyz_source(float *v, int tot, const std::string& anim_id)
        {
-               Sampler::Semantic semantic = Sampler::OUTPUT;
+               COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT;
                std::string source_id = anim_id + get_semantic_suffix(semantic);
 
                COLLADASW::FloatSourceF source(mSW);
@@ -774,7 +775,7 @@ protected:
 
        std::string create_interpolation_source(int tot, const std::string& anim_id, const char *axis_name)
        {
-               std::string source_id = anim_id + get_semantic_suffix(Sampler::INTERPOLATION);
+               std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION);
 
                COLLADASW::NameSource source(mSW);
                source.setId(source_id);
index 7b5b53979552f817c6e032d84c94597b106e5bfe..73ad6f475deb8f9877b05d5a604d1e08a1e229e8 100644 (file)
@@ -92,9 +92,9 @@ void GeometryExporter::operator()(Object *ob)
 
        // <vertices>
        COLLADASW::Vertices verts(mSW);
-       verts.setId(getIdBySemantics(geom_id, COLLADASW::VERTEX));
+       verts.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX));
        COLLADASW::InputList &input_list = verts.getInputList();
-       COLLADASW::Input input(COLLADASW::POSITION, getUrlBySemantics(geom_id, COLLADASW::POSITION));
+       COLLADASW::Input input(COLLADASW::InputSemantic::POSITION, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::POSITION));
        input_list.push_back(input);
        verts.add();
 
@@ -168,10 +168,10 @@ void GeometryExporter::createPolylist(int material_index,
        COLLADASW::InputList &til = polylist.getInputList();
                
        // creates <input> in <polylist> for vertices 
-       COLLADASW::Input input1(COLLADASW::VERTEX, getUrlBySemantics(geom_id, COLLADASW::VERTEX), 0);
+       COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0);
                
        // creates <input> in <polylist> for normals
-       COLLADASW::Input input2(COLLADASW::NORMAL, getUrlBySemantics(geom_id, COLLADASW::NORMAL), 1);
+       COLLADASW::Input input2(COLLADASW::InputSemantic::NORMAL, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL), 1);
                
        til.push_back(input1);
        til.push_back(input2);
@@ -181,7 +181,7 @@ void GeometryExporter::createPolylist(int material_index,
 
        for (i = 0; i < num_layers; i++) {
                // char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i);
-               COLLADASW::Input input3(COLLADASW::TEXCOORD,
+               COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD,
                                                                makeUrl(makeTexcoordSourceId(geom_id, i)),
                                                                2, // offset always 2, this is only until we have optimized UV sets
                                                                i  // set number equals UV layer index
@@ -190,7 +190,7 @@ void GeometryExporter::createPolylist(int material_index,
        }
 
        if (has_color) {
-               COLLADASW::Input input4(COLLADASW::COLOR, getUrlBySemantics(geom_id, COLLADASW::COLOR), has_uvs ? 3 : 2);
+               COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::COLOR), has_uvs ? 3 : 2);
                til.push_back(input4);
        }
                
@@ -240,8 +240,8 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
        MVert *verts = me->mvert;
        
        COLLADASW::FloatSourceF source(mSW);
-       source.setId(getIdBySemantics(geom_id, COLLADASW::POSITION));
-       source.setArrayId(getIdBySemantics(geom_id, COLLADASW::POSITION) +
+       source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION));
+       source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION) +
                                          ARRAY_ID_SUFFIX);
        source.setAccessorCount(totverts);
        source.setAccessorStride(3);
@@ -274,8 +274,8 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
                totcolor += f->v4 ? 4 : 3;
 
        COLLADASW::FloatSourceF source(mSW);
-       source.setId(getIdBySemantics(geom_id, COLLADASW::COLOR));
-       source.setArrayId(getIdBySemantics(geom_id, COLLADASW::COLOR) + ARRAY_ID_SUFFIX);
+       source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR));
+       source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR) + ARRAY_ID_SUFFIX);
        source.setAccessorCount(totcolor);
        source.setAccessorStride(3);
 
@@ -302,7 +302,7 @@ std::string GeometryExporter::makeTexcoordSourceId(std::string& geom_id, int lay
 {
        char suffix[20];
        sprintf(suffix, "-%d", layer_index);
-       return getIdBySemantics(geom_id, COLLADASW::TEXCOORD) + suffix;
+       return getIdBySemantics(geom_id, COLLADASW::InputSemantic::TEXCOORD) + suffix;
 }
 
 //creates <source> for texcoords
@@ -373,8 +373,8 @@ void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::v
 #endif
 
        COLLADASW::FloatSourceF source(mSW);
-       source.setId(getIdBySemantics(geom_id, COLLADASW::NORMAL));
-       source.setArrayId(getIdBySemantics(geom_id, COLLADASW::NORMAL) +
+       source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL));
+       source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL) +
                                          ARRAY_ID_SUFFIX);
        source.setAccessorCount((unsigned long)nor.size());
        source.setAccessorStride(3);
@@ -444,12 +444,12 @@ void GeometryExporter::create_normals(std::vector<Normal> &nor, std::vector<Face
        }
 }
 
-std::string GeometryExporter::getIdBySemantics(std::string geom_id, COLLADASW::Semantics type, std::string other_suffix) {
+std::string GeometryExporter::getIdBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix) {
        return geom_id + getSuffixBySemantic(type) + other_suffix;
 }
 
 
-COLLADASW::URI GeometryExporter::getUrlBySemantics(std::string geom_id, COLLADASW::Semantics type, std::string other_suffix) {
+COLLADASW::URI GeometryExporter::getUrlBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix) {
        
        std::string id(getIdBySemantics(geom_id, type, other_suffix));
        return COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, id);
index 27c837418b128d25b17751cbbb92d9e89e9287cb..b3013f7dadc54cf6d71d13ca52ba37da7a40d932 100644 (file)
@@ -83,9 +83,9 @@ public:
 
        void create_normals(std::vector<Normal> &nor, std::vector<Face> &ind, Mesh *me);
        
-       std::string getIdBySemantics(std::string geom_id, COLLADASW::Semantics type, std::string other_suffix = "");
+       std::string getIdBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix = "");
        
-       COLLADASW::URI getUrlBySemantics(std::string geom_id, COLLADASW::Semantics type, std::string other_suffix = "");
+       COLLADASW::URI getUrlBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix = "");
 
        COLLADASW::URI makeUrl(std::string id);
        
index 0f997a616e41ff0b6441d480ab2117cc8a3ff428..5faaf123bc79f41e922dbe0e3207f84e9b95bda3 100644 (file)
@@ -315,16 +315,19 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh)
 
 void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
 {
-       // vertices     
-       me->totvert = mesh->getPositions().getFloatValues()->getCount() / 3;
+       // vertices
+       COLLADAFW::MeshVertexData& pos = mesh->getPositions();
+       int stride = pos.getStride(0);
+       if(stride==0) stride = 3;
+       
+       me->totvert = mesh->getPositions().getFloatValues()->getCount() / stride;
        me->mvert = (MVert*)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
 
-       COLLADAFW::MeshVertexData& pos = mesh->getPositions();
        MVert *mvert;
        int i;
 
        for (i = 0, mvert = me->mvert; i < me->totvert; i++, mvert++) {
-               get_vector(mvert->co, pos, i);
+               get_vector(mvert->co, pos, i, stride);
        }
 }
 
@@ -634,10 +637,10 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris)
        geom_uid_mat_mapping_map[mesh->getUniqueId()] = mat_prim_map;
 }
 
-void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i)
+void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i, int stride)
 {
-       i *= 3;
-
+       i *= stride;
+       
        switch(arr.getType()) {
        case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
                {
@@ -647,6 +650,7 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i)
                        v[0] = (*values)[i++];
                        v[1] = (*values)[i++];
                        v[2] = (*values)[i];
+
                }
                break;
        case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
@@ -668,13 +672,13 @@ bool MeshImporter::flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor,
 {
        float a[3], b[3];
 
-       get_vector(a, nor, *nind);
+       get_vector(a, nor, *nind, 3);
        normalize_v3(a);
 
        nind++;
 
        for (int i = 1; i < count; i++, nind++) {
-               get_vector(b, nor, *nind);
+               get_vector(b, nor, *nind, 3);
                normalize_v3(b);
 
                float dp = dot_v3v3(a, b);
index c5ab6e94561fcd1bb657d26dbb05692a3a25a0f9..19a6ab96ddf4d41868d6dae4c45cfff8bb68612d 100644 (file)
@@ -118,7 +118,7 @@ private:
        // TODO: import uv set names
        void read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris);
 
-       void get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i);
+       void get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i, int stride);
 
        bool flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor, int count);