浏览代码

BlendShapes: add method to set blendshape weight by name

lviguier 1 月之前
父节点
当前提交
86ea0a851a
共有 2 个文件被更改,包括 9 次插入2 次删除
  1. 8 1
      h3d/prim/Blendshape.hx
  2. 1 1
      hxd/fmt/fbx/HMDOut.hx

+ 8 - 1
h3d/prim/Blendshape.hx

@@ -59,7 +59,7 @@ class Blendshape {
 		}
 	}
 
-	public function setBlendshapeAmount(blendshapeIdx: Int, amount: Float) {
+	public function setBlendshapeAmountByIndex(blendshapeIdx: Int, amount: Float) {
 		if (blendshapeIdx >= this.weights.length)
 			throw 'Blendshape at index ${blendshapeIdx} doesn\'t exist (there is only ${this.weights.length} blendshapes).';
 
@@ -67,6 +67,13 @@ class Blendshape {
 		uploadBlendshapeBytes();
 	}
 
+	public function setBlendShapeAmountByName(name: String, amount: Float) {
+		for (s in shapes)
+			if (s.name == name)
+				this.weights[shapes.indexOf(s)] = amount;
+		uploadBlendshapeBytes();
+	}
+
 	function getBlendshapeCount() {
 		if (hmdModel.lib.header.shapes == null)
 			return 0;

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

@@ -684,7 +684,7 @@ class HMDOut extends BaseLibrary {
 			var remapped = remappedShapes[i];
 			var s = shapes[i];
 			var shape = new BlendShape();
-			shape.name = s.name;
+			shape.name = s.props != null && s.props.length > 0 ? s.props[0].toString() : s.name;
 			shape.geom = -1;
 			var indexes = s.get("Indexes").getFloats();
 			var verts = s.get("Vertices").getFloats();