[Bf-blender-cvs] [e2d3e36] master: Cycles standalone: add support for reading UV coordinates to the XML scene reader

Martijn Berger noreply at git.blender.org
Sat Jun 27 12:06:01 CEST 2015


Commit: e2d3e36ca7866916363a06310af840f7978e98c2
Author: Martijn Berger
Date:   Sat Jun 27 12:05:05 2015 +0200
Branches: master
https://developer.blender.org/rBe2d3e36ca7866916363a06310af840f7978e98c2

Cycles standalone: add support for reading UV coordinates to the XML scene reader

===================================================================

M	intern/cycles/app/cycles_xml.cpp

===================================================================

diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index 3ce2d47..edea8cd 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -906,6 +906,7 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node)
 
 	/* read vertices and polygons, RIB style */
 	vector<float3> P;
+	vector<float> UV;
 	vector<int> verts, nverts;
 
 	xml_read_float3_array(P, node, "P");
@@ -977,6 +978,31 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node)
 
 			index_offset += nverts[i];
 		}
+
+		if(xml_read_float_array(UV, node, "UV")) {
+			ustring name = ustring("UVMap");
+			Attribute *attr = mesh->attributes.add(ATTR_STD_UV, name);
+			float3 *fdata = attr->data_float3();
+
+			/* loop over the triangles */
+			index_offset = 0;
+			for(size_t i = 0; i < nverts.size(); i++) {
+				for(int j = 0; j < nverts[i]-2; j++) {
+					int v0 = verts[index_offset];
+					int v1 = verts[index_offset + j + 1];
+					int v2 = verts[index_offset + j + 2];
+
+					assert(v0*2+1 < (int)UV.size());
+					assert(v1*2+1 < (int)UV.size());
+					assert(v2*2+1 < (int)UV.size());
+
+					fdata[0] = make_float3(UV[v0*2], UV[v0*2+1], 0.0);
+					fdata[1] = make_float3(UV[v1*2], UV[v1*2+1], 0.0);
+					fdata[2] = make_float3(UV[v2*2], UV[v2*2+1], 0.0);
+					fdata += 3;
+				}
+			}
+		}
 	}
 
 	/* temporary for test compatibility */




More information about the Bf-blender-cvs mailing list