Inheritance: UnityEngine.Point
Esempio n. 1
0
 public bool IsValid(Warning.Logger logger = null)
 {
     if (this.nodes.Length == 0)
     {
         if (logger != null)
         {
             logger("FBIK chain contains no nodes.");
         }
         return(false);
     }
     IKSolver.Node[] array = this.nodes;
     for (int i = 0; i < array.Length; i++)
     {
         IKSolver.Node node = array[i];
         if (node.transform == null)
         {
             if (logger != null)
             {
                 logger("Node transform is null in FBIK chain.");
             }
             return(false);
         }
     }
     return(true);
 }
Esempio n. 2
0
 public void SetPlane(IKSolver.Node planeNode1, IKSolver.Node planeNode2, IKSolver.Node planeNode3)
 {
     this.planeNode1 = planeNode1;
     this.planeNode2 = planeNode2;
     this.planeNode3 = planeNode3;
     this.UpdatePlane(true, true);
 }
 private static Vector3 GetNodePosition(IKSolver.Node node)
 {
     if (Application.isPlaying)
     {
         return(node.solverPosition);
     }
     return(node.transform.position);
 }
Esempio n. 4
0
 public void Initiate(IKSolverFullBody solver)
 {
     this.chain1 = solver.GetChain(this.bone1);
     this.chain2 = solver.GetChain(this.bone2);
     this.node1  = this.chain1.nodes[0];
     this.node2  = this.chain2.nodes[0];
     this.OnPreSolve();
 }
Esempio n. 5
0
 /*
  * Set nodes to the following bone transforms.
  * */
 public void SetNodes(params Transform[] boneTransforms)
 {
     nodes = new IKSolver.Node[boneTransforms.Length];
     for (int i = 0; i < boneTransforms.Length; i++)
     {
         nodes[i] = new IKSolver.Node(boneTransforms[i]);
     }
 }
Esempio n. 6
0
 /*
  * Moves the bone to the solver position of it's node
  * */
 public void FixToNode(float weight, IKSolver.Node fixNode = null)
 {
     if (fixNode == null)
     {
         fixNode = node;
     }
     transform.position = Vector3.Lerp(transform.position, fixNode.solverPosition, weight);
 }
Esempio n. 7
0
 public void Initiate(Transform transform, IKSolver solver)
 {
     this.transform = transform;
     IKSolver.Point point = solver.GetPoint(transform);
     if (point != null)
     {
         this.node = (point as IKSolver.Node);
     }
 }
Esempio n. 8
0
			/*
			 * Initiating the constraint
			 * */
			public void Initiate(IKSolverFullBody solver) {
				chain1 = solver.GetChain(bone1);
				chain2 = solver.GetChain(bone2);
				
				node1 = chain1.nodes[0];
				node2 = chain2.nodes[0];
				
				OnPreSolve();
			}
Esempio n. 9
0
            /*
             * Initiating the constraint
             * */
            public void Initiate(IKSolverFullBody solver)
            {
                chain1 = solver.GetChain(bone1);
                chain2 = solver.GetChain(bone2);

                node1 = chain1.nodes[0];
                node2 = chain2.nodes[0];

                OnPreSolve();
            }
Esempio n. 10
0
        public void Initiate(IKSolverFullBody solver)
        {
            this.node1                 = (solver.GetPoint(this.bone1) as IKSolver.Node);
            this.node2                 = (solver.GetPoint(this.bone2) as IKSolver.Node);
            this.node3                 = (solver.GetPoint(this.bone3) as IKSolver.Node);
            this.direction             = this.OrthoToBone1(this.OrthoToLimb(this.node2.transform.position - this.node1.transform.position));
            this.defaultLocalDirection = Quaternion.Inverse(this.node1.transform.rotation) * this.direction;
            Vector3 point = Vector3.Cross((this.node3.transform.position - this.node1.transform.position).normalized, this.direction);

            this.defaultChildDirection = Quaternion.Inverse(this.node3.transform.rotation) * point;
            this.initiated             = true;
        }
Esempio n. 11
0
 public void FixToNode(IKSolverFullBody solver, float weight, IKSolver.Node fixNode = null)
 {
     if (fixNode == null)
     {
         fixNode = solver.GetNode(this.chainIndex, this.nodeIndex);
     }
     if (weight >= 1f)
     {
         this.transform.position = fixNode.solverPosition;
         return;
     }
     this.transform.position = Vector3.Lerp(this.transform.position, fixNode.solverPosition, weight);
 }
Esempio n. 12
0
 public void FixToNode(float weight, IKSolver.Node fixNode = null)
 {
     if (fixNode == null)
     {
         fixNode = this.node;
     }
     if (weight >= 1f)
     {
         this.transform.position = fixNode.solverPosition;
         return;
     }
     this.transform.position = Vector3.Lerp(this.transform.position, fixNode.solverPosition, weight);
 }
Esempio n. 13
0
        /*
         * Initiate the effector, set default values
         * */
        public void Initiate(IKSolver solver)
        {
            this.solver           = solver;
            position              = bone.position;
            rotation              = bone.rotation;
            animatedPlaneRotation = Quaternion.identity;

            // Getting the node
            node = solver.GetPoint(bone) as IKSolver.Node;

            // Child nodes
            if (childNodes == null || childNodes.Length != childBones.Length)
            {
                childNodes = new IKSolver.Node[childBones.Length];
            }

            for (int i = 0; i < childBones.Length; i++)
            {
                childNodes[i] = solver.GetPoint(childBones[i]) as IKSolver.Node;
            }

            if (localPositions == null || localPositions.Length != childBones.Length)
            {
                localPositions = new Vector3[childBones.Length];
            }

            // Plane nodes
            usePlaneNodes = false;

            if (planeBone1 != null)
            {
                planeNode1 = solver.GetPoint(planeBone1) as IKSolver.Node;

                if (planeBone2 != null)
                {
                    planeNode2 = solver.GetPoint(planeBone2) as IKSolver.Node;

                    if (planeBone3 != null)
                    {
                        planeNode3    = solver.GetPoint(planeBone3) as IKSolver.Node;
                        usePlaneNodes = true;
                    }
                }

                isEndEffector = true;
            }
            else
            {
                isEndEffector = false;
            }
        }
Esempio n. 14
0
            /*
             * Moves the bone to the solver position of it's node
             * */
            public void FixToNode(float weight, IKSolver.Node fixNode = null)
            {
                if (fixNode == null)
                {
                    fixNode = node;
                }

                if (weight >= 1f)
                {
                    transform.SetPosition(fixNode.solverPosition);
                    return;
                }

                transform.SetPosition(Vector3.Lerp(transform.position, fixNode.solverPosition, weight));
            }
Esempio n. 15
0
        /*
         * Solve simple linear constraint
         * */
        private void SolveLinearConstraint(IKSolver.Node node1, IKSolver.Node node2, float crossFade, float distance)
        {
            Vector3 dir = node2.solverPosition - node1.solverPosition;

            float force = 1f - distance / dir.magnitude;

            if (force == 0)
            {
                return;
            }

            Vector3 offset = dir * force;

            node1.solverPosition += offset * crossFade;
            node2.solverPosition -= offset * (1f - crossFade);
        }
Esempio n. 16
0
        /*
         * Solve simple linear constraint
         * */
        private static void SolveLinearConstraint(IKSolver.Node node1, IKSolver.Node node2, float crossFade, float distance)
        {
            float currentDistance = Vector3.Distance(node1.solverPosition, node2.solverPosition);

            float force = 1f - distance / currentDistance;

            if (force == 0)
            {
                return;
            }

            Vector3 offset = (node2.solverPosition - node1.solverPosition) * force;

            node1.solverPosition += offset * crossFade;
            node2.solverPosition -= offset * (1f - crossFade);
        }
Esempio n. 17
0
        /*
         * Initiate the constraint and set defaults
         * */
        public void Initiate(IKSolverFullBody solver)
        {
            node1 = solver.GetPoint(bone1) as IKSolver.Node;
            node2 = solver.GetPoint(bone2) as IKSolver.Node;
            node3 = solver.GetPoint(bone3) as IKSolver.Node;

            // Find the default bend direction orthogonal to the chain direction
            direction = OrthoToBone1(OrthoToLimb(node2.transform.position - node1.transform.position));

            // Default bend direction relative to the first node
            defaultLocalDirection = Quaternion.Inverse(node1.transform.rotation) * direction;

            // Default plane normal
            Vector3 defaultNormal = Vector3.Cross((node3.transform.position - node1.transform.position).normalized, direction);

            // Default plane normal relative to the third node
            defaultChildDirection = Quaternion.Inverse(node3.transform.rotation) * defaultNormal;
        }
Esempio n. 18
0
        /*
         * Initiate the constraint and set defaults
         * */
        public void Initiate(IKSolverFullBody solver)
        {
            node1 = solver.GetPoint(bone1) as IKSolver.Node;
            node2 = solver.GetPoint(bone2) as IKSolver.Node;
            node3 = solver.GetPoint(bone3) as IKSolver.Node;

            // Find the default bend direction orthogonal to the chain direction
            direction = OrthoToBone1(OrthoToLimb(node2.transform.position - node1.transform.position));

            // Default bend direction relative to the first node
            defaultLocalDirection = Quaternion.Inverse(node1.transform.rotation) * direction;

            // Default plane normal
            Vector3 defaultNormal = Vector3.Cross((node3.transform.position - node1.transform.position).normalized, direction);

            // Default plane normal relative to the third node
            defaultChildDirection = Quaternion.Inverse(node3.transform.rotation) * defaultNormal;
        }
Esempio n. 19
0
        private void SolveLinearConstraint(IKSolver.Node node1, IKSolver.Node node2, float crossFade, float distance)
        {
            Vector3 a         = node2.solverPosition - node1.solverPosition;
            float   magnitude = a.magnitude;

            if (distance == magnitude)
            {
                return;
            }
            if (magnitude == 0f)
            {
                return;
            }
            Vector3 a2 = a * (1f - distance / magnitude);

            node1.solverPosition += a2 * crossFade;
            node2.solverPosition -= a2 * (1f - crossFade);
        }
Esempio n. 20
0
 public void Initiate(IKSolver solver)
 {
     this.solver   = solver;
     this.position = this.bone.position;
     this.rotation = this.bone.rotation;
     this.animatedPlaneRotation = Quaternion.identity;
     this.node = (solver.GetPoint(this.bone) as IKSolver.Node);
     if (this.childNodes == null || this.childNodes.Length != this.childBones.Length)
     {
         this.childNodes = new IKSolver.Node[this.childBones.Length];
     }
     for (int i = 0; i < this.childBones.Length; i++)
     {
         this.childNodes[i] = (solver.GetPoint(this.childBones[i]) as IKSolver.Node);
     }
     if (this.localPositions == null || this.localPositions.Length != this.childBones.Length)
     {
         this.localPositions = new Vector3[this.childBones.Length];
     }
     this.usePlaneNodes = false;
     if (this.planeBone1 != null)
     {
         this.planeNode1 = (solver.GetPoint(this.planeBone1) as IKSolver.Node);
         if (this.planeBone2 != null)
         {
             this.planeNode2 = (solver.GetPoint(this.planeBone2) as IKSolver.Node);
             if (this.planeBone3 != null)
             {
                 this.planeNode3    = (solver.GetPoint(this.planeBone3) as IKSolver.Node);
                 this.usePlaneNodes = true;
             }
         }
         this.isEndEffector = true;
     }
     else
     {
         this.isEndEffector = false;
     }
 }
Esempio n. 21
0
 public void Initiate(IKSolver solver, FBIKChain[] chain)
 {
     this.initiated = false;
     IKSolver.Node[] array = this.nodes;
     for (int i = 0; i < array.Length; i++)
     {
         IKSolver.Node node = array[i];
         node.solverPosition = node.transform.position;
     }
     this.CalculateBoneLengths(chain);
     FBIKChain.ChildConstraint[] array2 = this.childConstraints;
     for (int j = 0; j < array2.Length; j++)
     {
         FBIKChain.ChildConstraint childConstraint = array2[j];
         childConstraint.Initiate(solver as IKSolverFullBody);
     }
     if (this.nodes.Length == 3)
     {
         this.bendConstraint.SetBones(this.nodes[0].transform, this.nodes[1].transform, this.nodes[2].transform);
         this.bendConstraint.Initiate(solver as IKSolverFullBody);
     }
     this.crossFades = new float[this.children.Length];
     this.initiated  = true;
 }
Esempio n. 22
0
		/*
		 * Initiate the effector, set default values
		 * */
		public void Initiate(IKSolver solver) {
			this.solver = solver;
			position = bone.position;
			rotation = bone.rotation;
			animatedPlaneRotation = Quaternion.identity;

			// Getting the node
			node = solver.GetPoint(bone) as IKSolver.Node;

			// Child nodes
			if (childNodes == null || childNodes.Length != childBones.Length) childNodes = new IKSolver.Node[childBones.Length];

			for (int i = 0; i < childBones.Length; i++) {
				childNodes[i] = solver.GetPoint(childBones[i]) as IKSolver.Node;
			}

			if (localPositions == null || localPositions.Length != childBones.Length) localPositions = new Vector3[childBones.Length];

			// Plane nodes
			usePlaneNodes = false;

			if (planeBone1 != null) {
				planeNode1 = solver.GetPoint(planeBone1) as IKSolver.Node;

				if (planeBone2 != null) {
					planeNode2 = solver.GetPoint(planeBone2) as IKSolver.Node;

					if (planeBone3 != null) {
						planeNode3 = solver.GetPoint(planeBone3) as IKSolver.Node;
						usePlaneNodes = true;
					}
				}

				isEndEffector = true;
			} else isEndEffector = false;
		}
Esempio n. 23
0
			public void Initiate(Transform transform, IKSolver solver) {
				this.transform = transform;

				IKSolver.Point point = solver.GetPoint(transform);
				if (point != null) this.node = point as IKSolver.Node;
			}
Esempio n. 24
0
			/*
			 * Sets the 3 points defining a plane for this bone
			 * */
			public void SetPlane(IKSolver.Node planeNode1, IKSolver.Node planeNode2, IKSolver.Node planeNode3) {
				this.planeNode1 = planeNode1;
				this.planeNode2 = planeNode2;
				this.planeNode3 = planeNode3;
				
				UpdatePlane(true, true);
			}
Esempio n. 25
0
		/*
		 * Set nodes to the following bone transforms.
		 * */
		public void SetNodes(params Transform[] boneTransforms) {
			nodes = new IKSolver.Node[boneTransforms.Length];
			for (int i = 0; i < boneTransforms.Length; i++) {
				nodes[i] = new IKSolver.Node(boneTransforms[i]);
			}
		}
Esempio n. 26
0
            }                                            // 0x00000001809A67C0-0x00000001809A6800

            public void FixToNode(IKSolverFullBody solver, float weight, IKSolver.Node fixNode = null)
            {
            }                                                                                // 0x00000001809A55C0-0x00000001809A57A0
Esempio n. 27
0
        /*
         * Calculates the bend direction based on the law of cosines (from IKSolverTrigonometric).
         * */
        protected Vector3 GetBendDirection(Vector3 direction, float directionMagnitude, IKSolver.Node node1, IKSolver.Node node2)
        {
            float sqrMag1 = node1.length * node1.length;
            float sqrMag2 = node2.length * node2.length;

            float x = ((directionMagnitude * directionMagnitude) + sqrMag1 - sqrMag2) / 2f / directionMagnitude;
            float y = (float)Math.Sqrt(Mathf.Clamp(sqrMag1 - x * x, 0, Mathf.Infinity));

            return(Quaternion.LookRotation(direction) * new Vector3(0f, y, x));
        }
Esempio n. 28
0
        }                                                                      // 0x000000018052DEA0-0x000000018052DF30

        private void SolveLinearConstraint(IKSolver.Node node1, IKSolver.Node node2, float crossFade, float distance)
        {
        }                                                                                                                        // 0x000000018052E460-0x000000018052E6E0