Page Menu
Home
Search
Configure Global Search
Log In
Files
F18035
collada-fix-texture-channels.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Daniel Balster (dbalster)
Nov 13 2013, 4:05 PM
Size
3 KB
Subscribers
None
collada-fix-texture-channels.patch
View Options
Index: source/blender/collada/GeometryExporter.cpp
===================================================================
--- source/blender/collada/GeometryExporter.cpp (revision 43994)
+++ source/blender/collada/GeometryExporter.cpp (working copy)
@@ -1,4 +1,4 @@
-/*
+/**
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -36,6 +36,7 @@
#include "GeometryExporter.h"
#include "DNA_meshdata_types.h"
+#include "DNA_material_types.h"
#include "BKE_customdata.h"
#include "BKE_material.h"
@@ -164,13 +165,16 @@
fprintf(stderr, "%s: no faces use material %d\n", id_name(ob).c_str(), material_index);
return;
}
-
+
Material *ma = ob->totcol ? give_current_material(ob, material_index + 1) : NULL;
COLLADASW::Polylist polylist(mSW);
-
+
+ // do not export normals if "shadeless"
+ bool has_normals = ma==0 || !(ma->mode & MA_SHLESS);
+
// sets count attribute in <polylist>
polylist.setCount(faces_in_polylist);
-
+
// sets material name
if (ma) {
std::ostringstream ostr;
@@ -181,14 +185,20 @@
COLLADASW::InputList &til = polylist.getInputList();
// creates <input> in <polylist> for vertices
- COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0);
-
- // creates <input> in <polylist> for normals
- COLLADASW::Input input2(COLLADASW::InputSemantic::NORMAL, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL), 1);
-
+ int offset = 0;
+
+ COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), offset);
+ offset++;
+
til.push_back(input1);
- til.push_back(input2);
-
+ // sets material name
+ if (has_normals) {
+ // creates <input> in <polylist> for normals
+ COLLADASW::Input input2(COLLADASW::InputSemantic::NORMAL, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL), offset);
+ offset++;
+ til.push_back(input2);
+ }
+
// if mesh has uv coords writes <input> for TEXCOORD
int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
@@ -196,14 +206,16 @@
// char *name = CustomData_get_layer_name(&me->fdata, CD_MTFACE, i);
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 map index
+ offset, // offset always 2, this is only until we have optimized UV sets
+ i // set number equals UV map index
);
+ offset++;
til.push_back(input3);
}
if (has_color) {
- COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::COLOR), has_uvs ? 3 : 2);
+ COLLADASW::Input input4(COLLADASW::InputSemantic::COLOR, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::COLOR), offset);
+ offset++;
til.push_back(input4);
}
@@ -224,11 +236,13 @@
unsigned int *n = &norind[i].v1;
for (int j = 0; j < (f->v4 == 0 ? 3 : 4); j++) {
polylist.appendValues(v[j]);
- polylist.appendValues(n[j]);
-
- if (has_uvs)
- polylist.appendValues(texindex + j);
-
+ if (has_normals)
+ polylist.appendValues(n[j]);
+ if (has_uvs) {
+ for (int k=0; k<num_layers; ++k) {
+ polylist.appendValues(texindex + j);
+ }
+ }
if (has_color)
polylist.appendValues(texindex + j);
}
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
29/fa/e9b0c79c078d560b599ae06a7ed5
Event Timeline
Log In to Comment