浏览代码

optimized unskinned terminal joints

Nicolas Cannasse 11 年之前
父节点
当前提交
9fde3c8059
共有 2 个文件被更改,包括 13 次插入2 次删除
  1. 1 1
      hxd/fmt/fbx/BaseLibrary.hx
  2. 12 1
      hxd/fmt/fbx/HMDOut.hx

+ 1 - 1
hxd/fmt/fbx/BaseLibrary.hx

@@ -963,7 +963,7 @@ class BaseLibrary {
 		}
 		}
 	}
 	}
 
 
-	function keepJoint( j : h3d.anim.Skin.Joint ) {
+	function keepJoint( j : h3d.anim.Skin.Joint ) : Bool {
 		return keepJoints.get(j.name);
 		return keepJoints.get(j.name);
 	}
 	}
 
 

+ 12 - 1
hxd/fmt/fbx/HMDOut.hx

@@ -10,6 +10,7 @@ class HMDOut extends BaseLibrary {
 	var filePath : String;
 	var filePath : String;
 	var tmp = haxe.io.Bytes.alloc(4);
 	var tmp = haxe.io.Bytes.alloc(4);
 	public var absoluteTexturePath : Bool;
 	public var absoluteTexturePath : Bool;
+	public var optimizeSkin = true;
 
 
 	function int32tof( v : Int ) : Float {
 	function int32tof( v : Int ) : Float {
 		tmp.set(0, v & 0xFF);
 		tmp.set(0, v & 0xFF);
@@ -19,7 +20,12 @@ class HMDOut extends BaseLibrary {
 		return tmp.getFloat(0);
 		return tmp.getFloat(0);
 	}
 	}
 
 
-	override function keepJoint(_) : Null<Bool> {
+	override function keepJoint(j:h3d.anim.Skin.Joint) {
+		if( !optimizeSkin )
+			return true;
+		// remove these unskinned terminal bones if they are not named in a special manner
+		if( ~/^Bip00[0-9] /.match(j.name) || ~/^Bone[0-9][0-9][0-9]$/.match(j.name) )
+			return false;
 		return true;
 		return true;
 	}
 	}
 
 
@@ -559,6 +565,11 @@ class HMDOut extends BaseLibrary {
 
 
 	public function toHMD( filePath : String, includeGeometry : Bool ) : Data {
 	public function toHMD( filePath : String, includeGeometry : Bool ) : Data {
 
 
+		// if we have only animation data, make sure to export all joints positions
+		// because they might be applied to a different model at runtime
+		if( !includeGeometry )
+			optimizeSkin = false;
+
 		leftHandConvert();
 		leftHandConvert();
 		autoMerge();
 		autoMerge();