123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using System;
- using System.Linq;
- using RootMotion.FinalIK;
- using UnityEngine;
- [Serializable]
- public class FABRIKCtrlData : IKCtrlData
- {
- public FABRIKCtrlData(FABRIK fabr_ik, Transform[] chain_bones, FullBodyIKCtrl ik_ctrl, bool attach_ik = false) : base(ik_ctrl, chain_bones.Last<Transform>(), false, attach_ik)
- {
- this.FABRIK = fabr_ik;
- this.FABRIK.fixTransforms = false;
- this.IKSolver.target = base.IKTarget;
- this.IKSolver.useRotationLimits = false;
- this.IKSolver.maxIterations = 4;
- this.IKSolver.Initiate(chain_bones[0]);
- this.IKSolver.SetChain(chain_bones, chain_bones[0]);
- this.FABRIK.enabled = false;
- this.m_ForceIKEnable = false;
- }
- public IKSolverFABRIK IKSolver
- {
- get
- {
- return this.FABRIK.solver;
- }
- }
- public override Transform[] ChainBones
- {
- get
- {
- return (from bone in this.IKSolver.bones
- select bone.transform).ToArray<Transform>();
- }
- }
- public override float PositionWeight
- {
- get
- {
- return this.IKSolver.IKPositionWeight;
- }
- set
- {
- this.IKSolver.IKPositionWeight = value;
- }
- }
- public override float RotationWeight { get; set; }
- public override void Update()
- {
- this.FABRIK.solver.Update();
- if (base.RotateIK.IsIKExec)
- {
- base.TargetBone.rotation = Quaternion.Lerp(base.TargetBone.rotation, base.IKTarget.rotation, this.RotationWeight);
- }
- }
- public readonly FABRIK FABRIK;
- }
|