Ver Fonte

FBX: support IndexToDirect format for normals at import (Blender version >= 4.X)

lviguier há 11 meses atrás
pai
commit
f5530727ba
1 ficheiros alterados com 14 adições e 0 exclusões
  1. 14 0
      hxd/fmt/fbx/Geometry.hx

+ 14 - 0
hxd/fmt/fbx/Geometry.hx

@@ -207,6 +207,7 @@ class Geometry {
 		var vect = root.get(layer + "." + name, opt);
 		var vect = root.get(layer + "." + name, opt);
 		if( vect == null ) return null;
 		if( vect == null ) return null;
 		var nrm = vect.getFloats();
 		var nrm = vect.getFloats();
+
 		// if by-vertice (Maya in some cases, unless maybe "Split per-Vertex Normals" is checked)
 		// if by-vertice (Maya in some cases, unless maybe "Split per-Vertex Normals" is checked)
 		// let's reindex based on polygon indexes
 		// let's reindex based on polygon indexes
 		if( root.get(layer+".MappingInformationType").props[0].toString() == "ByVertice" ) {
 		if( root.get(layer+".MappingInformationType").props[0].toString() == "ByVertice" ) {
@@ -220,6 +221,19 @@ class Geometry {
 			}
 			}
 			nrm = nout;
 			nrm = nout;
 		}
 		}
+
+		// Blender after version 4.X export normals with index to direct inforamtion type
+		if( root.get(layer+".ReferenceInformationType").props[0].toString() == "IndexToDirect" ) {
+			var nout = [];
+			var nrmIdx = root.get(layer+".NormalsIndex").getInts();
+			for (i in 0...nrmIdx.length) {
+				nout.push(nrm[nrmIdx[i] * 3]);
+				nout.push(nrm[nrmIdx[i] * 3 + 1]);
+				nout.push(nrm[nrmIdx[i] * 3 + 2]);
+			}
+			nrm = nout;
+		}
+
 		return nrm;
 		return nrm;
 	}
 	}