Beispiel #1
0
        private void Init()
        {
            if (Chain.Joints == null || Chain.Joints.Count != 3)
            {
                Debug.LogError("Fetal !: the chain joints are undefined");
                return;
            }

            Chain.InitiateJoints();
            Chain.Weight = 1;

            _EEAnimRot = Chain.GetEndEffector().rotation;
            EE         = Chain.GetEndEffector();

            _init = true;
        }
Beispiel #2
0
        /// <summary>
        /// Solve the cain
        /// </summary>
        /// <param name="chain">The chain required</param>
        /// <param name="lookAtAxis">Which axis of the end effector to consider</param>
        /// <param name="virtualEndEffector">Offset the end effector by this Transform (optional)</param>
        public static void Process(Core.Chain chain, Vector3 lookAtAxis, Transform virtualEndEffector)
        {
            Transform offset = virtualEndEffector ?? chain.GetEndEffector();

            for (int i = 0; i < chain.Iterations; i++)
            {
                Solve(chain, offset, lookAtAxis);
            }
        }
        // Token: 0x06003497 RID: 13463 RVA: 0x000E5648 File Offset: 0x000E3848
        public static void Process(Core.Chain chain, Vector3 lookAtAxis, Transform virtualEndEffector)
        {
            Transform endEffector = virtualEndEffector ?? chain.GetEndEffector();

            for (int i = 0; i < chain.iterations; i++)
            {
                DirectionalSwingSolver.Solve(chain, endEffector, lookAtAxis);
            }
        }
Beispiel #4
0
        private void DrawHumanoidScene(Core.Chain chain)
        {
            if (chain == null)
            {
                return;
            }
            if (chain.Joints.Count <= 0)
            {
                return;
            }

            Color yellow = Color.yellow;
            Color blue   = Color.blue;
            Color green  = Color.green;
            Color red    = Color.red;
            Dictionary <int, Color> colorMap = new Dictionary <int, Color>();

            Action <Vector3> drawSphere     = v => Handles.SphereHandleCap(0, v, Quaternion.identity, 0.04f, EventType.Repaint);
            Action <Vector3> drawCube       = v => Handles.CubeHandleCap(0, v, Quaternion.identity, 0.03f, EventType.Repaint);
            Action <int>     alternateColor = i => Handles.color = colorMap[(int)Mathf.Pow(-1, i)];

            colorMap.Add(1, yellow);
            colorMap.Add(-1, green);

            for (int i = 0; i < chain.Joints.Count - 1; i++)
            {
                if (!chain.Joints[i].joint)
                {
                    break;
                }
                alternateColor(i);
                Handles.DrawLine(chain.Joints[i].joint.position, chain.Joints[i + 1].joint.position);
                alternateColor(i + 1);
                drawSphere(chain.Joints[i].joint.position);
            }

            Func <float, Color> lerpColor = x => Color.Lerp(green, red, x);
            Action <Core.Chain> toTarget  = x => Handles.DrawLine(x.GetEndEffector().position, x.Target && x.Weight > 0 ? x.Target.position : x.GetEndEffector().position);

            Handles.color = lerpColor(chain.Weight);
            toTarget(chain);
            drawCube(chain.GetEndEffector().position);
            drawCube(chain.Target ? chain.Target.position : chain.GetEndEffector().position);
        }
Beispiel #5
0
 /// <summary>
 /// Solve the cain
 /// </summary>
 /// <param name="chain">The chain required</param>
 /// <param name="lookAtAxis">Which axis of the end effector to consider</param>
 public static void Process(Core.Chain chain, Vector3 lookAtAxis)
 {
     Process(chain, lookAtAxis, chain.GetEndEffector());
 }
 // Token: 0x06003496 RID: 13462 RVA: 0x000E5637 File Offset: 0x000E3837
 public static void Process(Core.Chain chain, Vector3 lookAtAxis)
 {
     DirectionalSwingSolver.Process(chain, lookAtAxis, chain.GetEndEffector());
 }