diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-03-04 17:12:56 +0400 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-03-04 17:12:56 +0400 |
commit | 86ff11fe4713672a58deb8b054c936330954a721 (patch) | |
tree | 895712cebfcc12038fd679ff94e6b75ef5576a70 /source/blender/collada/GeometryExporter.cpp | |
parent | f691ee06275652419e822d5a269c63cfa169a837 (diff) |
Collada: Added ngon support to Vertex Color exporter
Diffstat (limited to 'source/blender/collada/GeometryExporter.cpp')
-rw-r--r-- | source/blender/collada/GeometryExporter.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 87063891a5f..6644c46ac86 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -439,19 +439,14 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me) void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me) { - if (!CustomData_has_layer(&me->fdata, CD_MCOL)) + if (!CustomData_has_layer(&me->ldata, CD_MLOOPCOL)) return; - MFace *f; - int totcolor = 0, i, j; - - for (i = 0, f = me->mface; i < me->totface; i++, f++) - totcolor += f->v4 ? 4 : 3; COLLADASW::FloatSourceF source(mSW); source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR)); source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR) + ARRAY_ID_SUFFIX); - source.setAccessorCount(totcolor); + source.setAccessorCount(me->totloop); source.setAccessorStride(3); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); @@ -461,14 +456,21 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me) source.prepareToAppendValues(); - int index = CustomData_get_active_layer_index(&me->fdata, CD_MCOL); - - MCol *mcol = (MCol *)me->fdata.layers[index].data; - MCol *c = mcol; + int index = CustomData_get_active_layer_index(&me->ldata, CD_MLOOPCOL); + MCol *mcol = (MCol *)me->ldata.layers[index].data; - for (i = 0, f = me->mface; i < me->totface; i++, c += 4, f++) - for (j = 0; j < (f->v4 ? 4 : 3); j++) - source.appendValues(c[j].b / 255.0f, c[j].g / 255.0f, c[j].r / 255.0f); + MPoly *mpoly; + int i; + for (i = 0, mpoly = me->mpoly; i < me->totpoly; i++, mpoly++) { + MCol *color = mcol + mpoly->loopstart; + for (int j = 0; j < mpoly->totloop; j++, color++) { + source.appendValues( + color->b / 255.0f, + color->g / 255.0f, + color->r / 255.0f + ); + } + } source.finish(); } |