Browse Source

support for UVs ByVertice Direct

ncannasse 12 năm trước cách đây
mục cha
commit
bec7a9fbdf
1 tập tin đã thay đổi với 10 bổ sung2 xóa
  1. 10 2
      h3d/fbx/Geometry.hx

+ 10 - 2
h3d/fbx/Geometry.hx

@@ -46,6 +46,7 @@ class Geometry {
 				index[pos] = i; // restore
 				count = 0;
 			}
+			pos++;
 		}
 		return { vidx : vout, idx : iout };
 	}
@@ -75,8 +76,15 @@ class Geometry {
 	
 	public function getUVs() {
 		var uvs = [];
-		for( v in root.getAll("LayerElementUV") )
-			uvs.push({ values : v.get("UV").getFloats(), index : v.get("UVIndex").getInts() });
+		for( v in root.getAll("LayerElementUV") ) {
+			var index = v.get("UVIndex", true);
+			var values = v.get("UV").getFloats();
+			var index = if( index == null ) {
+				// ByVertice/Direct (Maya sometimes...)
+				[for( i in getPolygons() ) if( i < 0 ) -i - 1 else i];
+			} else index.getInts();
+			uvs.push({ values : values, index : index });
+		}
 		return uvs;
 	}