Esempio n. 1
0
 public void Initiate(IKSolverFullBody solver)
 {
     this.position = this.bone.position;
     this.rotation = this.bone.rotation;
     this.animatedPlaneRotation = Quaternion.identity;
     solver.GetChainAndNodeIndexes(this.bone, out this.chainIndex, out this.nodeIndex);
     this.childChainIndexes = new int[this.childBones.Length];
     this.childNodeIndexes  = new int[this.childBones.Length];
     for (int i = 0; i < this.childBones.Length; i++)
     {
         solver.GetChainAndNodeIndexes(this.childBones[i], out this.childChainIndexes[i], out this.childNodeIndexes[i]);
     }
     this.localPositions = new Vector3[this.childBones.Length];
     this.usePlaneNodes  = false;
     if (this.planeBone1 != null)
     {
         solver.GetChainAndNodeIndexes(this.planeBone1, out this.plane1ChainIndex, out this.plane1NodeIndex);
         if (this.planeBone2 != null)
         {
             solver.GetChainAndNodeIndexes(this.planeBone2, out this.plane2ChainIndex, out this.plane2NodeIndex);
             if (this.planeBone3 != null)
             {
                 solver.GetChainAndNodeIndexes(this.planeBone3, out this.plane3ChainIndex, out this.plane3NodeIndex);
                 this.usePlaneNodes = true;
             }
         }
         this.isEndEffector = true;
     }
     else
     {
         this.isEndEffector = false;
     }
 }
Esempio n. 2
0
 public void SetPlane(IKSolverFullBody solver, Transform planeBone1, Transform planeBone2, Transform planeBone3)
 {
     this.planeBone1 = planeBone1;
     this.planeBone2 = planeBone2;
     this.planeBone3 = planeBone3;
     solver.GetChainAndNodeIndexes(planeBone1, out this.plane1ChainIndex, out this.plane1NodeIndex);
     solver.GetChainAndNodeIndexes(planeBone2, out this.plane2ChainIndex, out this.plane2NodeIndex);
     solver.GetChainAndNodeIndexes(planeBone3, out this.plane3ChainIndex, out this.plane3NodeIndex);
     this.UpdatePlane(true, true);
 }
Esempio n. 3
0
        public void Initiate(IKSolverFullBody solver)
        {
            solver.GetChainAndNodeIndexes(this.bone1, out this.chainIndex1, out this.nodeIndex1);
            solver.GetChainAndNodeIndexes(this.bone2, out this.chainIndex2, out this.nodeIndex2);
            solver.GetChainAndNodeIndexes(this.bone3, out this.chainIndex3, out this.nodeIndex3);
            this.direction             = this.OrthoToBone1(solver, this.OrthoToLimb(solver, this.bone2.position - this.bone1.position));
            this.defaultLocalDirection = Quaternion.Inverse(this.bone1.rotation) * this.direction;
            Vector3 point = Vector3.Cross((this.bone3.position - this.bone1.position).normalized, this.direction);

            this.defaultChildDirection = Quaternion.Inverse(this.bone3.rotation) * point;
            this.initiated             = true;
        }
Esempio n. 4
0
        /*
         * Initiate the effector, set default values
         * */
        public void Initiate(IKSolverFullBody solver)
        {
            position = bone.position;
            rotation = bone.rotation;
            animatedPlaneRotation = Quaternion.identity;

            // Getting the node
            solver.GetChainAndNodeIndexes(bone, out chainIndex, out nodeIndex);

            // Child nodes
            childChainIndexes = new int[childBones.Length];
            childNodeIndexes  = new int[childBones.Length];

            for (int i = 0; i < childBones.Length; i++)
            {
                solver.GetChainAndNodeIndexes(childBones[i], out childChainIndexes[i], out childNodeIndexes[i]);
            }

            localPositions = new Vector3[childBones.Length];


            // Plane nodes
            usePlaneNodes = false;
            Debug.Log("bone = " + bone.name);
            //Debug.Log("target = " + target.name);
            for (int i = 0; i < childBones.Length; i++)
            {
                Debug.Log("childBones = " + childBones[i].name);
            }
            if (planeBone1 != null)
            {
                solver.GetChainAndNodeIndexes(planeBone1, out plane1ChainIndex, out plane1NodeIndex);
                Debug.Log("planeBone1 = " + planeBone1.name);
                if (planeBone2 != null)
                {
                    solver.GetChainAndNodeIndexes(planeBone2, out plane2ChainIndex, out plane2NodeIndex);
                    Debug.Log("planeBone2 = " + planeBone2.name);
                    if (planeBone3 != null)
                    {
                        solver.GetChainAndNodeIndexes(planeBone3, out plane3ChainIndex, out plane3NodeIndex);
                        Debug.Log("planeBone3 = " + planeBone3.name);
                        usePlaneNodes = true;
                    }
                }

                isEndEffector = true;
            }
            else
            {
                isEndEffector = false;
            }
        }
Esempio n. 5
0
			//private IKSolver.Node planeNode1, planeNode2, planeNode3;

			public void Initiate(Transform transform, IKSolverFullBody solver) {
				this.transform = transform;

				solver.GetChainAndNodeIndexes(transform, out chainIndex, out nodeIndex);
				//IKSolver.Point point = solver.GetPoint(transform);
				//this.node = point as IKSolver.Node;
			}
Esempio n. 6
0
            //private IKSolver.Node planeNode1, planeNode2, planeNode3;

            public void Initiate(Transform transform, IKSolverFullBody solver)
            {
                this.transform = transform;

                solver.GetChainAndNodeIndexes(transform, out chainIndex, out nodeIndex);
                //IKSolver.Point point = solver.GetPoint(transform);
                //this.node = point as IKSolver.Node;
            }
Esempio n. 7
0
        /*
         * Initiate the constraint and set defaults
         * */
        public void Initiate(IKSolverFullBody solver)
        {
            solver.GetChainAndNodeIndexes(bone1, out chainIndex1, out nodeIndex1);
            solver.GetChainAndNodeIndexes(bone2, out chainIndex2, out nodeIndex2);
            solver.GetChainAndNodeIndexes(bone3, out chainIndex3, out nodeIndex3);

            // Find the default bend direction orthogonal to the chain direction
            direction = OrthoToBone1(solver, OrthoToLimb(solver, bone2.position - bone1.position));

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

            // Default plane normal
            Vector3 defaultNormal = Vector3.Cross((bone3.position - bone1.position).normalized, direction);

            // Default plane normal relative to the third node
            defaultChildDirection = Quaternion.Inverse(bone3.rotation) * defaultNormal;

            initiated = true;
        }
Esempio n. 8
0
            /*
             * Sets the 3 points defining a plane for this bone
             * */
            public void SetPlane(IKSolverFullBody solver, Transform planeBone1, Transform planeBone2, Transform planeBone3)
            {
                this.planeBone1 = planeBone1;
                this.planeBone2 = planeBone2;
                this.planeBone3 = planeBone3;

                Debug.Log("planeBone1!!!!!!!!!!!!!!!!!! = " + planeBone1.name);
                Debug.Log("planeBone2!!!!!!!!!!!!!!!!! = " + planeBone2.name);
                Debug.Log("planeBone3 !!!!!!!!!!!!!!!= " + planeBone3.name);

                solver.GetChainAndNodeIndexes(planeBone1, out plane1ChainIndex, out plane1NodeIndex);
                solver.GetChainAndNodeIndexes(planeBone2, out plane2ChainIndex, out plane2NodeIndex);
                solver.GetChainAndNodeIndexes(planeBone3, out plane3ChainIndex, out plane3NodeIndex);

                //this.planeNode1 = planeNode1;
                //this.planeNode2 = planeNode2;
                //this.planeNode3 = planeNode3;

                UpdatePlane(true, true);
            }
		/*
		 * Initiate the constraint and set defaults
		 * */
		public void Initiate(IKSolverFullBody solver) {
			solver.GetChainAndNodeIndexes(bone1, out chainIndex1, out nodeIndex1);
			solver.GetChainAndNodeIndexes(bone2, out chainIndex2, out nodeIndex2);
			solver.GetChainAndNodeIndexes(bone3, out chainIndex3, out nodeIndex3);

			// Find the default bend direction orthogonal to the chain direction
			direction = OrthoToBone1(solver, OrthoToLimb(solver, bone2.position - bone1.position));

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

			// Default plane normal
			Vector3 defaultNormal = Vector3.Cross((bone3.position - bone1.position).normalized, direction);
			
			// Default plane normal relative to the third node
			defaultChildDirection = Quaternion.Inverse(bone3.rotation) * defaultNormal;

			initiated = true;
		}
Esempio n. 10
0
 public void Initiate(Transform transform, IKSolverFullBody solver)
 {
     this.transform = transform;
     solver.GetChainAndNodeIndexes(transform, out this.chainIndex, out this.nodeIndex);
 }
Esempio n. 11
0
		/*
		 * Initiate the effector, set default values
		 * */
		public void Initiate(IKSolverFullBody solver) {
			position = bone.position;
			rotation = bone.rotation;
			animatedPlaneRotation = Quaternion.identity;

			// Getting the node
			solver.GetChainAndNodeIndexes(bone, out chainIndex, out nodeIndex);

			// Child nodes
			childChainIndexes = new int[childBones.Length];
			childNodeIndexes = new int[childBones.Length];

			for (int i = 0; i < childBones.Length; i++) {
				solver.GetChainAndNodeIndexes(childBones[i], out childChainIndexes[i], out childNodeIndexes[i]);
			}

			localPositions = new Vector3[childBones.Length];

			// Plane nodes
			usePlaneNodes = false;

			if (planeBone1 != null) {
				solver.GetChainAndNodeIndexes(planeBone1, out plane1ChainIndex, out plane1NodeIndex);

				if (planeBone2 != null) {
					solver.GetChainAndNodeIndexes(planeBone2, out plane2ChainIndex, out plane2NodeIndex);

					if (planeBone3 != null) {
						solver.GetChainAndNodeIndexes(planeBone3, out plane3ChainIndex, out plane3NodeIndex);

						usePlaneNodes = true;
					}
				}

				isEndEffector = true;
			} else isEndEffector = false; 
		}
Esempio n. 12
0
			/*
			 * Sets the 3 points defining a plane for this bone
			 * */
			public void SetPlane(IKSolverFullBody solver, Transform planeBone1, Transform planeBone2, Transform planeBone3) {
				this.planeBone1 = planeBone1;
				this.planeBone2 = planeBone2;
				this.planeBone3 = planeBone3;

				solver.GetChainAndNodeIndexes(planeBone1, out plane1ChainIndex, out plane1NodeIndex);
				solver.GetChainAndNodeIndexes(planeBone2, out plane2ChainIndex, out plane2NodeIndex);
				solver.GetChainAndNodeIndexes(planeBone3, out plane3ChainIndex, out plane3NodeIndex);

				//this.planeNode1 = planeNode1;
				//this.planeNode2 = planeNode2;
				//this.planeNode3 = planeNode3;
				
				UpdatePlane(true, true);
			}