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 | |
parent | f691ee06275652419e822d5a269c63cfa169a837 (diff) |
Collada: Added ngon support to Vertex Color exporter
-rw-r--r-- | source/blender/collada/EffectExporter.cpp | 6 | ||||
-rw-r--r-- | source/blender/collada/GeometryExporter.cpp | 30 | ||||
-rw-r--r-- | source/blender/collada/MeshImporter.cpp | 2 |
3 files changed, 20 insertions, 18 deletions
diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index e4a654dc99a..6741e92cb5c 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -323,10 +323,10 @@ void EffectsExporter::operator()(Material *ma, Object *ob) { if (me->pdata.layers[i].type == CD_MTEXPOLY) { MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data; - MFace *mface = me->mface; - for (int j = 0; j < me->totpoly; j++, mface++, txface++) { + MPoly *mpoly = me->mpoly; + for (int j = 0; j < me->totpoly; j++, mpoly++, txface++) { - Material *mat = give_current_material(ob, mface->mat_nr + 1); + Material *mat = give_current_material(ob, mpoly->mat_nr + 1); if (mat != ma) continue; 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(); } diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 1eb1460a9e2..7d8a0cf3bc0 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -555,7 +555,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me) int collada_meshtype = mp->getPrimitiveType(); - // since we cannot set mpoly->mat_nr here, we store a portion of me->mface in Primitive + // since we cannot set mpoly->mat_nr here, we store a portion of me->mpoly in Primitive Primitive prim = {mpoly, 0}; COLLADAFW::IndexListArray& index_list_array = mp->getUVCoordIndicesArray(); |