public HumHandPointingAni Set(IComplexHuman human, BodySide side, double seconds = 1) { Init(human, side); RotFingerToLocal(FingerName.Thumb, 1, fw_dn_sd(12, -5), v3.up); RotFingerToLocal(FingerName.Index, 1, fw_dn_sd(1, 5), v3.up); RotFingerToLocal(FingerName.Middle, 1, fw_dn(90), v3.fw); RotFingerToLocal(FingerName.Ring, 1, fw_dn(90), v3.fw); RotFingerToLocal(FingerName.Pinky, 1, fw_dn_sd(90, -10), v3.fw); RotFingerToLocal(FingerName.Thumb, 2, v3.forward, v3.fw); RotFingerToLocal(FingerName.Index, 2, fw_dn(1), v3.up); RotFingerToLocal(FingerName.Middle, 2, fw_dn(87), v3.fw); RotFingerToLocal(FingerName.Ring, 2, fw_dn(88), v3.fw); RotFingerToLocal(FingerName.Pinky, 2, fw_dn(89), v3.fw); RotFingerToLocal(FingerName.Thumb, 3, v3.forward, v3.fw); RotFingerToLocal(FingerName.Index, 3, fw_dn(1), v3.up); RotFingerToLocal(FingerName.Middle, 3, fw_dn(80), v3.fw); RotFingerToLocal(FingerName.Ring, 3, fw_dn(80), v3.fw); RotFingerToLocal(FingerName.Pinky, 3, fw_dn(80), v3.fw); StartFingerRotation(seconds); return(this.AsUniqueNamed((unique.Hand + side) + human.ID)); }
public RegisterSoftBodyConfig(IComplexHuman human, BodySide side, BodyPart part, SoftBodyConfig config) : base(human) { Side = side; Part = part; Config = config; }
public IHandAni Set(IComplexHuman human, BodySide side, double seconds = 1) { Init(human, side); RotFingerToLocal(FingerName.Thumb, 1, v3.fw, v3.up, funFastToSlow2); RotFingerToLocal(FingerName.Index, 1, v3.fw.RotUp(5), v3.up); RotFingerToLocal(FingerName.Middle, 1, v3.fw.RotDn(50), v3.up); RotFingerToLocal(FingerName.Ring, 1, v3.fw.RotDn(60), v3.up); RotFingerToLocal(FingerName.Pinky, 1, v3.fw.RotDn(60), v3.up); RotFingerToLocal(FingerName.Thumb, 2, v3.fw, v3.up); RotFingerToLocal(FingerName.Index, 2, v3.fw.RotUp(10), v3.up); RotFingerToLocal(FingerName.Middle, 2, v3.fw.RotDn(50), v3.up); RotFingerToLocal(FingerName.Ring, 2, v3.fw.RotDn(55), v3.up); RotFingerToLocal(FingerName.Pinky, 2, v3.fw.RotDn(50), v3.up); RotFingerToLocal(FingerName.Thumb, 3, v3.fw, v3.up); RotFingerToLocal(FingerName.Index, 3, v3.fw.RotUp(6), v3.up); RotFingerToLocal(FingerName.Middle, 3, v3.fw.RotDn(80), v3.up); RotFingerToLocal(FingerName.Ring, 3, v3.fw.RotDn(80), v3.up); RotFingerToLocal(FingerName.Pinky, 3, v3.fw.RotDn(60), v3.up); StartFingerRotation(seconds); return(this.AsUniqueNamed((unique.Hand + side) + human.ID)); }
public HumHandHalfOpenAni Set(IComplexHuman human, BodySide side, double seconds = 1) { Init(human, side); RotFingerToLocal(FingerName.Thumb, 1, fw_dn_sd(10, 5), up_sd(-20)); RotFingerToLocal(FingerName.Index, 1, fw_dn_sd(40, -3), v3.up); RotFingerToLocal(FingerName.Middle, 1, fw_dn(70), v3.up); RotFingerToLocal(FingerName.Ring, 1, fw_dn_sd(80, +3), v3.up); RotFingerToLocal(FingerName.Pinky, 1, fw_dn_sd(80, +6), v3.up); RotFingerToLocal(FingerName.Thumb, 2, v3.forward, v3.up); RotFingerToLocal(FingerName.Index, 2, fw_dn(40), v3.up); RotFingerToLocal(FingerName.Middle, 2, fw_dn(70), v3.up); RotFingerToLocal(FingerName.Ring, 2, fw_dn(70), v3.up); RotFingerToLocal(FingerName.Pinky, 2, fw_dn(70), v3.up); RotFingerToLocal(FingerName.Thumb, 3, v3.forward, v3.up); RotFingerToLocal(FingerName.Index, 3, fw_dn(30), v3.up); RotFingerToLocal(FingerName.Middle, 3, fw_dn(80), v3.up); RotFingerToLocal(FingerName.Ring, 3, fw_dn(110), v3.fw); RotFingerToLocal(FingerName.Pinky, 3, fw_dn(110), v3.fw); StartFingerRotation(seconds); return(this.AsUniqueNamed((unique.Hand + side) + human.ID)); }
void Start() { if (_human != null) { return; } get <IHumanBoneWrapper>(HumanoidType.MakeHuman) .Wrap(transform, PersonaID, CustomTag); var mhd = new MakeHumanDefinition(new PersonDetails { Persona = PersonaID, HasBreasts = HasBreasts }, transform); // subscribe to BeforeCreatingHuman to add extenders var evt = fireAndReturn(new BeforeCreatingHuman(mhd, CustomTag)); _human = get <IComplexHuman>().Set(mhd, evt.Extenders.ToArray()); fire(new HumanCreated(_human)); }
public HumHandSpreadAni Set(IComplexHuman human, BodySide side, double seconds = 1) { Init(human, side); RotFingerToLocal(FingerName.Thumb, 1, fw_sd(-20), v3.up); RotFingerToLocal(FingerName.Index, 1, fw_dn_sd(5, -12), v3.up); RotFingerToLocal(FingerName.Middle, 1, fw_dn(5), v3.up); RotFingerToLocal(FingerName.Ring, 1, fw_dn_sd(5, +8), v3.up); RotFingerToLocal(FingerName.Pinky, 1, fw_dn_sd(5, +16), v3.up); RotFingerToLocal(FingerName.Thumb, 2, v3.forward, v3.up); RotFingerToLocal(FingerName.Index, 2, fw_dn(5), v3.up); RotFingerToLocal(FingerName.Middle, 2, fw_dn(5), v3.up); RotFingerToLocal(FingerName.Ring, 2, fw_dn(5), v3.up); RotFingerToLocal(FingerName.Pinky, 2, fw_dn(5), v3.up); RotFingerToLocal(FingerName.Thumb, 3, v3.forward, v3.up); RotFingerToLocal(FingerName.Index, 3, fw_dn(5), v3.up); RotFingerToLocal(FingerName.Middle, 3, fw_dn(5), v3.up); RotFingerToLocal(FingerName.Ring, 3, fw_dn(5), v3.up); RotFingerToLocal(FingerName.Pinky, 3, fw_dn(5), v3.up); StartFingerRotation(seconds); return(this.AsUniqueNamed((unique.Hand + side) + human.ID)); }
public BraidChain(IComplexHuman human, params Transform[] nodes) : base(BodyPart.Braid) { _human = human; _nodes = nodes ?? throw new ArgumentException("No braid nodes found"); _tempPositions = new Vector3[_nodes.Length + 2]; // 1 x each node + 1 root + 1 handler _tempFw = new Vector3[_nodes.Length + 1]; // for each temp position except root _joinLengths = new float[_nodes.Length + 1]; _joinLengths[0] = _human.Head.position.DistanceTo(_nodes[0].position); for (var i = 1; i < _nodes.Length; ++i) { var last = _nodes[i - 1]; var curr = _nodes[i]; _joinLengths[i] = vDist(last.position, curr.position); } const float LastLen = 0.1f; _joinLengths[_joinLengths.Length - 1] = LastLen; var lastNode = nodes[nodes.Length - 1]; // hair6 _handle = CreateHandle(_human.Head.Holder, BodyPart.Braid, false, lastNode.position + lastNode.forward.By(LastLen), human.dn, human.bk); _iniRootPositions = new Vector3[_nodes.Length + 1]; // for each position except root for (var i = 0; i < _nodes.Length; ++i) { _iniRootPositions[i] = _nodes[i].position.AsLocalPoint(_human.Head); } _iniRootPositions[_iniRootPositions.Length - 1] = _handle.position.AsLocalPoint(_human.Head); _headToHandleDist = _handle.position.DistanceTo(_human.Head.position); _handleIniLocPos = _handle.localPosition; _pendulum = new PendulumPhysicsAgent( stiffness: 0.005, mass: 0.50, damping: 0.85, gravity: 0); }
public HumHandDefaultAni Set(IComplexHuman human, BodySide side, double seconds = 1) { Init(human, side); RotFingerToLocal(FingerName.Thumb, 1, v3.fw, v3.up); RotFingerToLocal(FingerName.Index, 1, v3.fw, v3.up); RotFingerToLocal(FingerName.Middle, 1, v3.fw, v3.up); RotFingerToLocal(FingerName.Ring, 1, v3.fw, v3.up); RotFingerToLocal(FingerName.Pinky, 1, v3.fw, v3.up); RotFingerToLocal(FingerName.Thumb, 2, v3.fw, v3.up); RotFingerToLocal(FingerName.Index, 2, v3.fw, v3.up); RotFingerToLocal(FingerName.Middle, 2, v3.fw, v3.up); RotFingerToLocal(FingerName.Ring, 2, v3.fw, v3.up); RotFingerToLocal(FingerName.Pinky, 2, v3.fw, v3.up); RotFingerToLocal(FingerName.Thumb, 3, v3.fw, v3.up); RotFingerToLocal(FingerName.Index, 3, v3.fw, v3.up); RotFingerToLocal(FingerName.Middle, 3, v3.fw, v3.up); RotFingerToLocal(FingerName.Ring, 3, v3.fw, v3.up); RotFingerToLocal(FingerName.Pinky, 3, v3.fw, v3.up); StartFingerRotation(seconds); return(this.AsUniqueNamed((unique.Hand + side) + human.ID)); }
public HumHandGrabbingAni Set(IComplexHuman human, BodySide side, double seconds = 1) { Init(human, side); RotFingerToLocal(FingerName.Thumb, 1, fw_dn_sd(0, -10), v3.up); RotFingerToLocal(FingerName.Index, 1, fw_dn_sd(40, -10), v3.up); RotFingerToLocal(FingerName.Middle, 1, fw_dn(40), v3.up); RotFingerToLocal(FingerName.Ring, 1, fw_dn_sd(40, +10), v3.up); RotFingerToLocal(FingerName.Pinky, 1, fw_dn_sd(40, +20), v3.up); RotFingerToLocal(FingerName.Thumb, 2, fw_dn(20), v3.up); RotFingerToLocal(FingerName.Index, 2, fw_dn(40), v3.up); RotFingerToLocal(FingerName.Middle, 2, fw_dn(40), v3.up); RotFingerToLocal(FingerName.Ring, 2, fw_dn(40), v3.up); RotFingerToLocal(FingerName.Pinky, 2, fw_dn(40), v3.up); RotFingerToLocal(FingerName.Thumb, 3, fw_dn(20), v3.up); RotFingerToLocal(FingerName.Index, 3, fw_dn(40), v3.up); RotFingerToLocal(FingerName.Middle, 3, fw_dn(40), v3.up); RotFingerToLocal(FingerName.Ring, 3, fw_dn(40), v3.up); RotFingerToLocal(FingerName.Pinky, 3, fw_dn(40), v3.up); StartFingerRotation(seconds); return(this.AsUniqueNamed((unique.Hand + side) + human.ID)); }
public HumHandHitchhikingAni Set(IComplexHuman human, BodySide side, double seconds = 1) { Init(human, side); if (human.IsGenesis8()) { RotFingerToLocal(FingerName.Thumb, 1, v3.fw.RotUp(10), v3.up); RotFingerToLocal(FingerName.Index, 1, fw_dn_sd(100, 5), v3.fw);// fw and not up because the new up is what it was fw RotFingerToLocal(FingerName.Middle, 1, fw_dn(100), v3.fw); RotFingerToLocal(FingerName.Ring, 1, fw_dn(100), v3.fw); RotFingerToLocal(FingerName.Pinky, 1, fw_dn_sd(100, -10), v3.fw); RotFingerToLocal(FingerName.Thumb, 2, v3.fw.RotUp(25), v3.up); RotFingerToLocal(FingerName.Index, 2, fw_dn(86), v3.fw); RotFingerToLocal(FingerName.Middle, 2, fw_dn(87), v3.fw); RotFingerToLocal(FingerName.Ring, 2, fw_dn(88), v3.fw); RotFingerToLocal(FingerName.Pinky, 2, fw_dn(89), v3.fw); RotFingerToLocal(FingerName.Thumb, 3, v3.fw, v3.up); RotFingerToLocal(FingerName.Index, 3, fw_dn(120), v3.fw); RotFingerToLocal(FingerName.Middle, 3, fw_dn(120), v3.fw); RotFingerToLocal(FingerName.Ring, 3, fw_dn(120), v3.fw); RotFingerToLocal(FingerName.Pinky, 3, fw_dn(120), v3.fw); } else { RotFingerToLocal(FingerName.Thumb, 1, v3.fw.RotUp(5), v3.up.RotDir(side.ToNormal(), -30)); RotFingerToLocal(FingerName.Index, 1, fw_dn_sd(70, 15), v3.fw);// fw and not up because the new up is what it was fw RotFingerToLocal(FingerName.Middle, 1, fw_dn(70), v3.fw); RotFingerToLocal(FingerName.Ring, 1, fw_dn(70), v3.fw); RotFingerToLocal(FingerName.Pinky, 1, fw_dn_sd(70, -10), v3.fw); RotFingerToLocal(FingerName.Thumb, 2, v3.fw.RotUp(10), v3.up); RotFingerToLocal(FingerName.Index, 2, fw_dn(75), v3.fw); RotFingerToLocal(FingerName.Middle, 2, fw_dn(75), v3.fw); RotFingerToLocal(FingerName.Ring, 2, fw_dn(75), v3.fw); RotFingerToLocal(FingerName.Pinky, 2, fw_dn(75), v3.fw); RotFingerToLocal(FingerName.Thumb, 3, v3.fw.RotUp(10), v3.up); RotFingerToLocal(FingerName.Index, 3, fw_dn(80), v3.fw); RotFingerToLocal(FingerName.Middle, 3, fw_dn(80), v3.fw); RotFingerToLocal(FingerName.Ring, 3, fw_dn(80), v3.fw); RotFingerToLocal(FingerName.Pinky, 3, fw_dn(80), v3.fw); } StartFingerRotation(seconds); return(this.AsUniqueNamed((unique.Hand + side) + human.ID)); }
protected void Init(IComplexHuman human, BodySide side) { _human = human; _side = side; var arm = side == BodySide.Left ? human.ArmL : human.ArmR; _fingers[FingerName.Thumb] = new Dictionary <int, Transform> { { 0, arm.Thumb1 }, { 1, arm.Thumb1 }, { 2, arm.Thumb2 }, { 3, arm.Thumb3 } }; _fingers[FingerName.Index] = new Dictionary <int, Transform> { { 0, arm.Index0 }, { 1, arm.Index1 }, { 2, arm.Index2 }, { 3, arm.Index3 } }; _fingers[FingerName.Middle] = new Dictionary <int, Transform> { { 0, arm.Middle0 }, { 1, arm.Middle1 }, { 2, arm.Middle2 }, { 3, arm.Middle3 } }; _fingers[FingerName.Ring] = new Dictionary <int, Transform> { { 0, arm.Ring0 }, { 1, arm.Ring1 }, { 2, arm.Ring2 }, { 3, arm.Ring3 } }; _fingers[FingerName.Pinky] = new Dictionary <int, Transform> { { 0, arm.Pinky0 }, { 1, arm.Pinky1 }, { 2, arm.Pinky2 }, { 3, arm.Pinky3 } }; }
static double GetBlinkBaseByTargetDirection(this IComplexHuman h, ref Vector3 targetDir) { var iniHeadUp = h.Head.up; var dp = dot(in targetDir, in iniHeadUp); var blinkBaseTarget = 0.20; if (dp > 0.050) { blinkBaseTarget = 0.00; } if (dp > 0.025) { blinkBaseTarget = 0.10; } if (dp < -0.025) { blinkBaseTarget = 0.30; } else if (dp < -0.050) { blinkBaseTarget = 0.40; } return(blinkBaseTarget); }
public static Vector3 GetCurrentFaceTarget(this IComplexHuman h) => h.NeckUpper.position + h.NeckUpper.forward.By(3);
public static Vector3 GetCurrentLookTarget(this IComplexHuman h) => h.IsGenesis8() ? h.GenFace.EyeR.position + h.GenFace.EyeR.forward.By(3) : h.MHFace.EyeR.position + h.MHFace.EyeR.forward.By(3);
public static bool IsForwardFacingHorizontal(this IComplexHuman h) => vector.PointSameDirection(h.forward, in v3.fw);
public static bool IsForwardFacing(this IComplexHuman h) => vector.PointSameDirection(h.rotation * new Vector3(0f, -0.7071068f, 0.7071067f), in v3.fw);
// 0f, -0.5f, 0.8660254f = Debug.Log(v3.fw.ToDn(30).s()); // 0f,-0.7071068f,0.7071067f = Debug.Log(">>"+v3.fw.ToDn(45).s()); public static Vector3 DownForward(this IComplexHuman h) => h.rotation * new Vector3(0f, -0.7071068f, 0.7071067f);
public static ulong GetActionLabel(this IComplexHuman h) => h.AniEntireBody.GetLabel();
public static Vector3 GetAbsLipBoneCenterPosition(this IComplexHuman h) { return(Vector3.Lerp(h.GenFace.LipCornerL.position, h.GenFace.LipCornerR.position, 0.5f)); }
public static ulong RemoveFlag(this IComplexHuman human, ulong flag) { human.Flags &= ~flag; return(human.Flags); }
public static ulong AddFlag(this IComplexHuman human, ulong flag) { human.Flags |= flag; return(human.Flags); }
IHandAni IHandAni.Set(IComplexHuman human, BodySide side, double seconds) { return(Set(human, side, seconds)); }
public static IComplexHuman MoveTowards(this IComplexHuman h, Vector3 target, double step = -1) { h.Model.MoveTowards(target, step); return(h); }
public static IComplexHuman RotateTowards(this IComplexHuman h, Vector3 forward, Vector3 up, double stepDegrees = -1) { h.Model.RotateTowards(forward, up, stepDegrees); return(h); }
public static IComplexHuman RotateTowards(this IComplexHuman h, Quaternion rotation, double stepDegrees = -1) { h.Model.RotateTowards(rotation, stepDegrees); return(h); }
public static bool IsInAction(this IComplexHuman h, ulong action) => h.AniEntireBody.IsRunningWithLabel(action);
public static bool IsPointProjectedToUpperBody(this IComplexHuman h, Vector3 point) { fun.point.ProjectOnLine(in point, h.position, h.Head.position, out var proj); return(fun.point.IsAbovePlane(in proj, h.up, h.Spine.AbdomenUpper.position)); }
/*public static bool TryLookAtTarget(this IComplexHuman h, double seconds, Func<Vector3> getTarget, Action onEnd = null) * { * onEnd = onEnd ?? new Action(() => { }); * * * var eyeL = h.GenFace.EyeL; * var eyeR = h.GenFace.EyeR; * var iniFw = eyeL.position.DirTo(getTarget()); * var blinkBaseTarget = h.GetBlinkBaseByTargetDirection(ref iniFw); * * h.AniLook?.ClearAllFollowUpActions().StopIfRunning(); * h.AniLook = play<FuncAni>().Set(seconds, _ => * { * h.FaceExp.BlinkBase01 = h.FaceExp.BlinkBase01.MoveTowards(blinkBaseTarget, fun.smoothDeltaTime * 2); * if (h.AniBlink.IsNotRunning()) h.FaceExp.Blink01 = 0; * * var p = getTarget(); * var fwL = eyeL.position.DirTo(p); * var fwR = eyeR.position.DirTo(p); * * if(angleIsLessThan(fwL, h.Head.forward, 30)) * { * var hUp = h.Head.up; * eyeL.RotateTowards(Quaternion.LookRotation(fwL, hUp), fun.smoothDeltaTime * 90); * eyeR.RotateTowards(Quaternion.LookRotation(fwR, hUp), fun.smoothDeltaTime * 90); * } * }) * .AsUniqueNamed(unique.Look + h.ID) * .Then(onEnd) * ; * return true; * }*/ public static Vector3 GetAbsMouthPosition(this IComplexHuman h) { var head = h.Head.Holder; return(Vector3.Lerp(h.GenFace.LipCornerL.position, h.GenFace.LipCornerR.position, 0.5f) + head.forward * 0.03f + head.up * -0.005f); }
public static bool IsMakeHuman(this IComplexHuman h) => h.Definition.HumanoidType == HumanoidType.MakeHuman;
public static bool IsGenesis8(this IComplexHuman h) => h.Definition.HumanoidType == HumanoidType.Genesis8;