Page Menu
Home
Search
Configure Global Search
Log In
Files
F23531
patch.txt
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Daniel Jungmann (xaphier)
Nov 13 2013, 5:13 PM
Size
10 KB
Subscribers
None
patch.txt
View Options
Index: release/scripts/presets/operator/wm.collada_export/second_life_static.py
===================================================================
--- release/scripts/presets/operator/wm.collada_export/second_life_static.py (Revision 52432)
+++ release/scripts/presets/operator/wm.collada_export/second_life_static.py (Arbeitskopie)
@@ -8,6 +8,7 @@
op.include_children = False
op.include_armatures = False
op.deform_bones_only = False
+op.active_vcolor_only = True
op.active_uv_only = True
op.include_uv_textures = True
op.use_texture_copies = True
Index: release/scripts/presets/operator/wm.collada_export/second_life_rigged.py
===================================================================
--- release/scripts/presets/operator/wm.collada_export/second_life_rigged.py (Revision 52432)
+++ release/scripts/presets/operator/wm.collada_export/second_life_rigged.py (Arbeitskopie)
@@ -8,6 +8,7 @@
op.include_children = False
op.include_armatures = True
op.deform_bones_only = True
+op.active_vcolor_only = True
op.active_uv_only = True
op.include_uv_textures = True
op.use_texture_copies = True
Index: source/blender/collada/collada.h
===================================================================
--- source/blender/collada/collada.h (Revision 52432)
+++ source/blender/collada/collada.h (Arbeitskopie)
@@ -57,6 +57,8 @@
int include_armatures,
int deform_bones_only,
+ int active_vcolor_only,
+
int active_uv_only,
int include_uv_textures,
int include_material_textures,
Index: source/blender/collada/ExportSettings.h
===================================================================
--- source/blender/collada/ExportSettings.h (Revision 52432)
+++ source/blender/collada/ExportSettings.h (Arbeitskopie)
@@ -39,6 +39,8 @@
bool include_armatures;
bool deform_bones_only;
+ bool active_vcolor_only;
+
bool active_uv_only;
bool include_uv_textures;
bool include_material_textures;
Index: source/blender/collada/GeometryExporter.cpp
===================================================================
--- source/blender/collada/GeometryExporter.cpp (Revision 52432)
+++ source/blender/collada/GeometryExporter.cpp (Arbeitskopie)
@@ -298,9 +298,19 @@
}
}
- if (has_color) {
- COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::COLOR), has_uvs ? 3 : 2);
- til.push_back(input4);
+ num_layers = CustomData_number_of_layers(&me->fdata, CD_MCOL);
+ int active_vcolor_index = CustomData_get_active_layer_index(&me->fdata, CD_MCOL)-1;
+
+ for (i = 0; i < num_layers; i++) {
+ if (!this->export_settings->active_vcolor_only || i == active_vcolor_index) {
+ // char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i);
+ COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR,
+ makeUrl(makeVertexColorSourceId(geom_id, i)),
+ 3, // offset always 3
+ i // set number equals color map index
+ );
+ til.push_back(input4);
+ }
}
// sets <vcount>
@@ -373,40 +383,54 @@
}
+std::string GeometryExporter::makeVertexColorSourceId(std::string& geom_id, int layer_index)
+{
+ char suffix[20];
+ sprintf(suffix, "-%d", layer_index);
+ return getIdBySemantics(geom_id, COLLADASW::InputSemantic::COLOR) + suffix;
+}
+
void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
{
- if (!CustomData_has_layer(&me->fdata, CD_MCOL))
- return;
-
- MFace *f;
+ MFace *f = me->mface;
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.setAccessorStride(3);
+ int num_layers = CustomData_number_of_layers(&me->fdata, CD_MCOL);
+ int active_vcolor_index = CustomData_get_active_layer_index(&me->fdata, CD_MCOL)-1;
- COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
- param.push_back("R");
- param.push_back("G");
- param.push_back("B");
+ // write <source> for each layer
+ // each <source> will get id like meshName + "colors-channel-1"
+ int map_index = 0;
+ for (int a = 0; a < num_layers; a++) {
- source.prepareToAppendValues();
+ if (!this->export_settings->active_vcolor_only || a == active_vcolor_index) {
- int index = CustomData_get_active_layer_index(&me->fdata, CD_MCOL);
+ MCol *c = (MCol *)me->fdata.layers[a].data;
- MCol *mcol = (MCol *)me->fdata.layers[index].data;
- MCol *c = mcol;
+ COLLADASW::FloatSourceF source(mSW);
+ std::string layer_id = makeVertexColorSourceId(geom_id, map_index++);
+ source.setId(layer_id);
+ source.setArrayId(layer_id + ARRAY_ID_SUFFIX);
+
+ source.setAccessorCount(totcolor);
+ source.setAccessorStride(3);
+ COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
+ param.push_back("R");
+ param.push_back("G");
+ param.push_back("B");
+
+ source.prepareToAppendValues();
- 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);
-
- source.finish();
+ 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);
+
+ source.finish();
+ }
+ }
}
std::string GeometryExporter::makeTexcoordSourceId(std::string& geom_id, int layer_index)
Index: source/blender/collada/collada.cpp
===================================================================
--- source/blender/collada/collada.cpp (Revision 52432)
+++ source/blender/collada/collada.cpp (Arbeitskopie)
@@ -61,6 +61,7 @@
int include_armatures,
int deform_bones_only,
+ int active_vcolor_only,
int active_uv_only,
int include_uv_textures,
int include_material_textures,
@@ -91,6 +92,8 @@
export_settings.include_armatures = include_armatures != 0;
export_settings.deform_bones_only = deform_bones_only != 0;
+ export_settings.active_vcolor_only = active_vcolor_only != 0;
+
export_settings.active_uv_only = active_uv_only != 0;
export_settings.include_uv_textures = include_uv_textures != 0;
export_settings.include_material_textures= include_material_textures != 0;
Index: source/blender/collada/GeometryExporter.h
===================================================================
--- source/blender/collada/GeometryExporter.h (Revision 52432)
+++ source/blender/collada/GeometryExporter.h (Arbeitskopie)
@@ -83,6 +83,8 @@
// creates <source> for positions
void createVertsSource(std::string geom_id, Mesh *me);
+ std::string makeVertexColorSourceId(std::string& geom_id, int layer_index);
+
void createVertexColorSource(std::string geom_id, Mesh *me);
std::string makeTexcoordSourceId(std::string& geom_id, int layer_index);
Index: source/blender/editors/io/io_collada.c
===================================================================
--- source/blender/editors/io/io_collada.c (Revision 52432)
+++ source/blender/editors/io/io_collada.c (Arbeitskopie)
@@ -86,6 +86,8 @@
int include_armatures;
int deform_bones_only;
+ int active_vcolor_only;
+
int include_uv_textures;
int include_material_textures;
int use_texture_copies;
@@ -116,6 +118,8 @@
use_texture_copies = RNA_boolean_get(op->ptr, "use_texture_copies");
active_uv_only = RNA_boolean_get(op->ptr, "active_uv_only");
+ active_vcolor_only = RNA_boolean_get(op->ptr, "active_vcolor_only");
+
use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation");
sort_by_name = RNA_boolean_get(op->ptr, "sort_by_name");
second_life = RNA_boolean_get(op->ptr, "second_life");
@@ -132,6 +136,8 @@
include_armatures,
deform_bones_only,
+ active_vcolor_only,
+
active_uv_only,
include_uv_textures,
include_material_textures,
@@ -176,6 +182,9 @@
uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE);
uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
+ row = uiLayoutRow(box, FALSE);
+ uiItemR(row, imfptr, "active_vcolor_only", 0, NULL, ICON_NONE);
+
/* Texture options */
box = uiLayoutBox(layout);
row = uiLayoutRow(box, FALSE);
@@ -269,6 +278,8 @@
RNA_def_boolean(ot->srna, "deform_bones_only", 0, "Deform Bones only",
"Only export deforming bones with armatures");
+ RNA_def_boolean(ot->srna, "active_vcolor_only", 0, "Only Active Vertex Color layer",
+ "Only export active Vertex Color layer");
RNA_def_boolean(ot->srna, "active_uv_only", 0, "Only Active UV layer",
"Export textures assigned to the object UV maps");
Index: source/blender/makesrna/intern/rna_scene_api.c
===================================================================
--- source/blender/makesrna/intern/rna_scene_api.c (Revision 52432)
+++ source/blender/makesrna/intern/rna_scene_api.c (Arbeitskopie)
@@ -99,6 +99,8 @@
int include_armatures,
int deform_bones_only,
+ int active_vcolor_only,
+
int active_uv_only,
int include_uv_textures,
int include_material_textures,
@@ -110,8 +112,9 @@
{
collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected,
include_children, include_armatures, deform_bones_only,
- active_uv_only, include_uv_textures, include_material_textures,
- use_texture_copies, use_object_instantiation, sort_by_name, second_life);
+ active_vcolor_only, active_uv_only, include_uv_textures,
+ include_material_textures, use_texture_copies,
+ use_object_instantiation, sort_by_name, second_life);
}
#endif
@@ -147,6 +150,8 @@
parm = RNA_def_boolean(func, "include_armatures", 0, "Include Armatures", "Export related armatures (even if not selected)");
parm = RNA_def_boolean(func, "deform_bones_only", 0, "Deform Bones only", "Only export deforming bones with armatures");
+ parm = RNA_def_boolean(func, "active_vcolor_only", 0, "Active Vertex Color Layer only", "Export only the active Vertex Color Layer");
+
parm = RNA_def_boolean(func, "active_uv_only", 0, "Active UV Layer only", "Export only the active UV Layer");
parm = RNA_def_boolean(func, "include_uv_textures", 0, "Include UV Textures", "Export textures assigned to the object UV maps");
parm = RNA_def_boolean(func, "include_material_textures", 0, "Include Material Textures", "Export textures assigned to the object Materials");
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f5/ca/9c105db2727be2c21d88b66d830c
Event Timeline
Log In to Comment