Selaa lähdekoodia

Model: WIP merge tool in model view

lviguier 3 kuukautta sitten
vanhempi
commit
9d5603097c
2 muutettua tiedostoa jossa 15 lisäystä ja 7 poistoa
  1. 6 2
      h3d/prim/HMDModel.hx
  2. 9 5
      hxd/fmt/fbx/Writer.hx

+ 6 - 2
h3d/prim/HMDModel.hx

@@ -59,8 +59,12 @@ class HMDModel extends MeshPrimitive {
 		return lods[lod].indexCounts[material];
 	}
 
-	public function getDataBuffers(fmt, ?defaults,?material) {
-		return lib.getBuffers(data, fmt, defaults, material);
+	public function getDataBuffers(fmt, ?defaults, ?material) {
+		return getLodBuffers(fmt, 0, defaults, material);
+	}
+
+	public function getLodBuffers(fmt, lodIdx, ?defaults, ?material) {
+		return lib.getBuffers(lods[lodIdx], fmt, defaults, material);
 	}
 
 	public function loadSkin(skin) {

+ 9 - 5
hxd/fmt/fbx/Writer.hx

@@ -24,7 +24,7 @@ class Writer {
 		this.out = out;
 	}
 
-	function getPrimitiveInfos(prim : h3d.prim.Primitive) @:privateAccess {
+	public static function getPrimitiveInfos(prim : h3d.prim.Primitive, ?format: BufferFormat, ?lodIdx : Int = 0) @:privateAccess {
 		var infos : {
 			?vertexFormat : BufferFormat,
 			?vertexBuffer : Array<Float>,
@@ -36,8 +36,12 @@ class Writer {
 
 		var hmd = Std.downcast(prim, h3d.prim.HMDModel);
 		if (hmd != null) {
-			infos.vertexFormat = @:privateAccess hmd.data.vertexFormat;
-			var bufs = hmd.getDataBuffers(infos.vertexFormat);
+			if (format == null) {
+				infos.vertexFormat = @:privateAccess hmd.lods[lodIdx].vertexFormat;
+				format = infos.vertexFormat;
+			}
+			infos.vertexFormat = format;
+			var bufs = hmd.getLodBuffers(format, lodIdx);
 			infos.indexesBuffer = [for (i in 0...bufs.indexes.length) bufs.indexes[i]];
 			infos.vertexBuffer = [for (i in 0...bufs.vertexes.length) bufs.vertexes[i]];
 			infos.lib = hmd.lib;
@@ -711,7 +715,7 @@ class Writer {
 							{ name:"P", props: [PString("AlphaSource"), PString("enum"), PString(""), PString(""), PInt(2)], childs: null },
 						] },
 						{ name: "Media", props: [PString('Video::${t.name}')], childs: null },
-						{ name: "Filename", props: [PString(t.path)], childs: null },
+						{ name: "FileName", props: [PString(t.path)], childs: null },
 						{ name: "RelativeFilename", props: [PString("")], childs: null },
 						{ name: "ModelUVTranslation", props: [PFloat(0), PFloat(0)], childs: null },
 						{ name: "ModelUVScaling", props: [PFloat(1), PFloat(1)], childs: null },
@@ -740,7 +744,7 @@ class Writer {
 								{ name:"P", props: [PString("KString"), PString("XRefUrl"), PString(""), PString(t.path)], childs: null },
 							] },
 							{ name: "UseMipMap", props: [PInt(0)], childs: null },
-							{ name: "Filename", props: [PString(t.path)], childs: null },
+							{ name: "FileName", props: [PString(t.path)], childs: null },
 							{ name: "RelativeFilename", props: [PString("")], childs: null },
 						] };