Browse Source

added additivePose

Nicolas Cannasse 9 months ago
parent
commit
07bc22f601
1 changed files with 11 additions and 2 deletions
  1. 11 2
      h3d/scene/Skin.hx

+ 11 - 2
h3d/scene/Skin.hx

@@ -75,6 +75,7 @@ class Skin extends MultiMaterial {
 	var paletteChanged : Bool;
 	var skinShader : h3d.shader.SkinBase;
 	var jointsGraphics : Graphics;
+	var additivePose : Array<h3d.Matrix>;
 
 	public var showJoints : Bool;
 	public var enableRetargeting : Bool = true;
@@ -170,10 +171,14 @@ class Skin extends MultiMaterial {
 		return skinData;
 	}
 
-	public function setJointRelPosition( name : String, pos : h3d.Matrix ) {
+	public function setJointRelPosition( name : String, pos : h3d.Matrix, additive = false ) {
 		var j = skinData.namedJoints.get(name);
 		if( j == null ) return;
-		currentRelPose[j.index] = pos;
+		if( additive ) {
+			if( additivePose == null ) additivePose = [];
+			additivePose[j.index] = pos;
+		} else
+			currentRelPose[j.index] = pos;
 		jointsUpdated = true;
 	}
 
@@ -251,6 +256,10 @@ class Skin extends MultiMaterial {
 				m.multiply3x4inline(r, absPos);
 			else
 				m.multiply3x4inline(r, currentAbsPose[j.parent.index]);
+			if( additivePose != null ) {
+				var a = additivePose[id];
+				if( a != null ) m.multiply3x4inline(a, m);
+			}
 			if( bid >= 0 )
 				currentPalette[bid].multiply3x4inline(j.transPos, m);
 		}