浏览代码

added SmoothTarget.easing

Nicolas Cannasse 4 年之前
父节点
当前提交
9eccaef34b
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      h3d/anim/SmoothTarget.hx

+ 6 - 1
h3d/anim/SmoothTarget.hx

@@ -19,8 +19,9 @@ class SmoothTarget extends Animation {
 
 	@:s public var target : Animation;
 	@:s public var blend : Float;
-	@:s var duration : Float;
+	@:s public var duration : Float;
 	@:s public var ignoreTranslate = false;
+	@:s public var easing : Float = 0.;
 
 	public function new( target : h3d.anim.Animation, duration = 0.5 ) {
 		super("SmoothTarget(" + target.name+")", target.frameCount, target.sampling);
@@ -98,6 +99,10 @@ class SmoothTarget extends Animation {
 		if( decompose ) throw "assert";
 		var objects = getSmoothObjects();
 		target.sync(true);
+
+		var bpow = Math.pow(blend, 1 + easing);
+		var blend = bpow / (bpow + Math.pow(1 - blend, easing + 1));
+
 		for( o in objects ) {
 			var m = @:privateAccess if( o.targetSkin != null ) o.targetSkin.currentRelPose[o.targetJoint] else if( o.targetObject != null ) o.targetObject.defaultTransform else null;