FindBone() публичный Метод

public FindBone ( String boneName ) : Bone
boneName String
Результат Bone
Пример #1
0
        public TransformConstraint(TransformConstraintData data, Skeleton skeleton)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data", "data cannot be null.");
            }
            if (skeleton == null)
            {
                throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
            }
            this.data = data;
            mixRotate = data.mixRotate;
            mixX      = data.mixX;
            mixY      = data.mixY;
            mixScaleX = data.mixScaleX;
            mixScaleY = data.mixScaleY;
            mixShearY = data.mixShearY;
            bones     = new ExposedList <Bone>();
            foreach (BoneData boneData in data.bones)
            {
                bones.Add(skeleton.FindBone(boneData.name));
            }

            target = skeleton.FindBone(data.target.name);
        }
Пример #2
0
        public TransformConstraint(TransformConstraintData data, Skeleton skeleton)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data cannot be null.");
            }
            if (skeleton == null)
            {
                throw new ArgumentNullException("skeleton cannot be null.");
            }
            this.data      = data;
            translateMix   = data.translateMix;
            rotateMix      = data.rotateMix;
            scaleMix       = data.scaleMix;
            shearMix       = data.shearMix;
            offsetRotation = data.offsetRotation;
            offsetX        = data.offsetX;
            offsetY        = data.offsetY;
            offsetScaleX   = data.offsetScaleX;
            offsetScaleY   = data.offsetScaleY;
            offsetShearY   = data.offsetShearY;

            bone   = skeleton.FindBone(data.bone.name);
            target = skeleton.FindBone(data.target.name);
        }
Пример #3
0
		public IkConstraint (IkConstraintData data, Skeleton skeleton) {
			this.data = data;
			mix = data.mix;
			bendDirection = data.bendDirection;

			bones = new List<Bone>(data.bones.Count);
			foreach (BoneData boneData in data.bones)
				bones.Add(skeleton.FindBone(boneData.name));
			target = skeleton.FindBone(data.target.name);
		}
Пример #4
0
		public TransformConstraint (TransformConstraintData data, Skeleton skeleton) {
			if (data == null) throw new ArgumentNullException("data cannot be null.");
			if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
			this.data = data;
			translateMix = data.translateMix;
			x = data.x;
			y = data.y;

			bone = skeleton.FindBone(data.bone.name);
			target = skeleton.FindBone(data.target.name);
		}
Пример #5
0
		public IkConstraint (IkConstraintData data, Skeleton skeleton) {
			if (data == null) throw new ArgumentNullException("data cannot be null.");
			if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
			this.data = data;
			mix = data.mix;
			bendDirection = data.bendDirection;

			bones = new ExposedList<Bone>(data.bones.Count);
			foreach (BoneData boneData in data.bones)
				bones.Add(skeleton.FindBone(boneData.name));
			target = skeleton.FindBone(data.target.name);
		}
Пример #6
0
        public IkConstraint(IkConstraintData data, Skeleton skeleton)
        {
            this.data     = data;
            mix           = data.mix;
            bendDirection = data.bendDirection;

            bones = new List <Bone>(data.bones.Count);
            foreach (BoneData boneData in data.bones)
            {
                bones.Add(skeleton.FindBone(boneData.name));
            }
            target = skeleton.FindBone(data.target.name);
        }
		public TransformConstraint (TransformConstraintData data, Skeleton skeleton) {
			if (data == null) throw new ArgumentNullException("data", "data cannot be null.");
			if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
			this.data = data;
			rotateMix = data.rotateMix;
			translateMix = data.translateMix;
			scaleMix = data.scaleMix;
			shearMix = data.shearMix;

			bones = new ExposedList<Bone>();
			foreach (BoneData boneData in data.bones)
				bones.Add (skeleton.FindBone (boneData.name));
			
			target = skeleton.FindBone(data.target.name);
		}
Пример #8
0
        public TransformConstraint(TransformConstraintData data, Skeleton skeleton)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data cannot be null.");
            }
            if (skeleton == null)
            {
                throw new ArgumentNullException("skeleton cannot be null.");
            }
            this.data    = data;
            translateMix = data.translateMix;
            x            = data.x;
            y            = data.y;

            bone   = skeleton.FindBone(data.bone.name);
            target = skeleton.FindBone(data.target.name);
        }
Пример #9
0
		public TransformConstraint (TransformConstraintData data, Skeleton skeleton) {
			if (data == null) throw new ArgumentNullException("data cannot be null.");
			if (skeleton == null) throw new ArgumentNullException("skeleton cannot be null.");
			this.data = data;
			translateMix = data.translateMix;
			rotateMix = data.rotateMix;
			scaleMix = data.scaleMix;
			shearMix = data.shearMix;
			offsetRotation = data.offsetRotation;
			offsetX = data.offsetX;
			offsetY = data.offsetY;
			offsetScaleX = data.offsetScaleX;
			offsetScaleY = data.offsetScaleY;
			offsetShearY = data.offsetShearY;

			bone = skeleton.FindBone(data.bone.name);
			target = skeleton.FindBone(data.target.name);
		}
Пример #10
0
 public IkConstraint(IkConstraintData data, Skeleton skeleton)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data", "data cannot be null.");
     }
     if (skeleton == null)
     {
         throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
     }
     this.data          = data;
     this.mix           = data.mix;
     this.bendDirection = data.bendDirection;
     this.bones         = new ExposedList <Bone>(data.bones.Count);
     foreach (BoneData data2 in data.bones)
     {
         this.bones.Add(skeleton.FindBone(data2.name));
     }
     this.target = skeleton.FindBone(data.target.name);
 }
Пример #11
0
		public PathConstraint (PathConstraintData data, Skeleton skeleton) {
			if (data == null) throw new ArgumentNullException("data", "data cannot be null.");
			if (skeleton == null) throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
			this.data = data;
			bones = new ExposedList<Bone>(data.Bones.Count);
			foreach (BoneData boneData in data.bones)
				bones.Add(skeleton.FindBone(boneData.name));
			target = skeleton.FindSlot(data.target.name);
			position = data.position;
			spacing = data.spacing;
			rotateMix = data.rotateMix;
			translateMix = data.translateMix;
		}
 public TransformConstraint(TransformConstraintData data, Skeleton skeleton)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data", "data cannot be null.");
     }
     if (skeleton == null)
     {
         throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
     }
     this.data         = data;
     this.rotateMix    = data.rotateMix;
     this.translateMix = data.translateMix;
     this.scaleMix     = data.scaleMix;
     this.shearMix     = data.shearMix;
     this.bones        = new ExposedList <Bone>();
     foreach (BoneData data2 in data.bones)
     {
         this.bones.Add(skeleton.FindBone(data2.name));
     }
     this.target = skeleton.FindBone(data.target.name);
 }
Пример #13
0
        public IkConstraint(IkConstraintData data, Skeleton skeleton)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data", "data cannot be null.");
            }
            if (skeleton == null)
            {
                throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
            }
            this.data     = data;
            mix           = data.mix;
            softness      = data.softness;
            bendDirection = data.bendDirection;
            compress      = data.compress;
            stretch       = data.stretch;

            bones = new ExposedList <Bone>(data.bones.Count);
            foreach (BoneData boneData in data.bones)
            {
                bones.Add(skeleton.FindBone(boneData.name));
            }
            target = skeleton.FindBone(data.target.name);
        }
Пример #14
0
 public IkConstraint(IkConstraintData data, Skeleton skeleton)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data cannot be null.");
     }
     if (skeleton == null)
     {
         throw new ArgumentNullException("skeleton cannot be null.");
     }
     this.data          = data;
     this.mix           = data.mix;
     this.bendDirection = data.bendDirection;
     this.bones         = new ExposedList <Bone>(data.bones.get_Count());
     using (List <BoneData> .Enumerator enumerator = data.bones.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             BoneData current = enumerator.get_Current();
             this.bones.Add(skeleton.FindBone(current.name));
         }
     }
     this.target = skeleton.FindBone(data.target.name);
 }
Пример #15
0
    void Start () {
		game = GameObject.Find ("Gui").GetComponent<GameHandler> ();
		boxCollider = GetComponent<BoxCollider2D> ();
		character = GetComponent<MeshRenderer> ();
		controller = GetComponent<Controller2D> ();
		anim = GetComponent<SkeletonAnimation> ();
		skeleton = anim.skeleton;
		arm = skeleton.FindBone ("RShoulder");
		backArm = skeleton.FindBone ("LShoulder");

		weap = skeleton.FindBone ("Weapon");
		skelRend = GetComponent<SkeletonRenderer> ();
		skeleton.FindSlot ("WeaponImage").Attachment = null;
		anim.state.ClearTrack(1);
		controller.CatchPlayer (this);
		crouchTap = new TapInfo (.6f, int.MaxValue);
		dashTap = new TapInfo (.6f, int.MaxValue);

        //Initiate the width of the HP bar, this may need to be placed in the Update portion if window scaling is changed.
        width = healthbar.GetComponent<RectTransform>().rect.width;
		startMaxXPos = healthbar.GetComponent<RectTransform>().offsetMax.x;

        UpdateGravity();
	}
Пример #16
0
 static int FindBone(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Spine.Skeleton obj  = (Spine.Skeleton)ToLua.CheckObject <Spine.Skeleton>(L, 1);
         string         arg0 = ToLua.CheckString(L, 2);
         Spine.Bone     o    = obj.FindBone(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 public PathConstraint(PathConstraintData data, Skeleton skeleton)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data", "data cannot be null.");
     }
     if (skeleton == null)
     {
         throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
     }
     this.data = data;
     bones     = new ExposedList <Bone>(data.Bones.Count);
     foreach (BoneData boneData in data.bones)
     {
         bones.Add(skeleton.FindBone(boneData.name));
     }
     target       = skeleton.FindSlot(data.target.name);
     position     = data.position;
     spacing      = data.spacing;
     rotateMix    = data.rotateMix;
     translateMix = data.translateMix;
 }
Пример #18
0
	public void Apply () {
		isActive = true;
		skeleton = skeletonAnim.Skeleton;
		mix = 1;

		var ragdollRootBone = skeleton.FindBone(startingBoneName);
		startingBone = ragdollRootBone;
		RecursivelyCreateBoneProxies(ragdollRootBone);

		rootRigidbody = boneTable[ragdollRootBone].GetComponent<Rigidbody2D>();
		rootRigidbody.isKinematic = pinStartBone;
		rootRigidbody.mass = rootMass;

		List<Collider2D> boneColliders = new List<Collider2D>();

		foreach (var pair in boneTable) {
			var b = pair.Key;
			var t = pair.Value;
			Bone parentBone = null;
			Transform parentTransform = transform;

			boneColliders.Add(t.GetComponent<Collider2D>());

			if (b != startingBone) {
				parentBone = b.Parent;
				parentTransform = boneTable[parentBone];
			} else {
				ragdollRoot = new GameObject("RagdollRoot").transform;
				ragdollRoot.parent = transform;

				if (b == skeleton.RootBone) {
					ragdollRoot.localPosition = new Vector3(b.WorldX, b.WorldY, 0);
					ragdollRoot.localRotation = Quaternion.Euler(0, 0, GetCompensatedRotationIK(b));
					parentTransform = ragdollRoot;
				} else {
					ragdollRoot.localPosition = new Vector3(b.Parent.WorldX, b.Parent.WorldY, 0);
					ragdollRoot.localRotation = Quaternion.Euler(0, 0, GetCompensatedRotationIK(b.Parent));
					parentTransform = ragdollRoot;
				}

				rootOffset = t.position - transform.position;
			}

			var rbParent = parentTransform.GetComponent<Rigidbody2D>();

			if (rbParent != null) {
				var joint = t.gameObject.AddComponent<HingeJoint2D>();
				joint.connectedBody = rbParent;
				Vector3 localPos = parentTransform.InverseTransformPoint(t.position);
				localPos.x *= 1;
				joint.connectedAnchor = localPos;
				joint.GetComponent<Rigidbody2D>().mass = joint.connectedBody.mass * massFalloffFactor;
				JointAngleLimits2D limits = new JointAngleLimits2D();
				limits.min = -rotationLimit;
				limits.max = rotationLimit;
				joint.limits = limits;
				joint.useLimits = true;
			}
		}

		for (int x = 0; x < boneColliders.Count; x++) {
			for (int y = 0; y < boneColliders.Count; y++) {
				if (x == y) continue;
				Physics2D.IgnoreCollision(boneColliders[x], boneColliders[y]);
			}
		}

		var utilityBones = GetComponentsInChildren<SkeletonUtilityBone>();
		if (utilityBones.Length > 0) {
			List<string> destroyedUtilityBoneNames = new List<string>();
			foreach (var ub in utilityBones) {
				if (ub.mode == SkeletonUtilityBone.Mode.Override) {
					destroyedUtilityBoneNames.Add(ub.gameObject.name);
					Destroy(ub.gameObject);
				}
			}

			if (destroyedUtilityBoneNames.Count > 0) {
				string msg = "Destroyed Utility Bones: ";
				for (int i = 0; i < destroyedUtilityBoneNames.Count; i++) {
					msg += destroyedUtilityBoneNames[i];
					if (i != destroyedUtilityBoneNames.Count - 1) {
						msg += ",";
					}
				}
				Debug.LogWarning(msg);
			}
		}

		if (disableIK) {
			foreach (IkConstraint ik in skeleton.IkConstraints) {
				ik.Mix = 0;
			}
		}

		skeletonAnim.UpdateWorld += UpdateWorld;
	}
Пример #19
0
    public void DoUpdate()
    {
        if (!valid)
        {
            Reset();
            return;
        }

        Spine.Skeleton skeleton = skeletonUtility.skeletonRenderer.skeleton;

        if (bone == null)
        {
            if (boneName == null || boneName.Length == 0)
            {
                return;
            }
            bone = skeleton.FindBone(boneName);
            if (bone == null)
            {
                Debug.LogError("Bone not found: " + boneName, this);
                return;
            }
        }



        float skeletonFlipRotation = (skeleton.flipX ^ skeleton.flipY) ? -1f : 1f;

        float flipCompensation = 0;

        if (flip && (flipX || (flipX != bone.flipX)) && bone.parent != null)
        {
            flipCompensation = bone.parent.WorldRotation * -2;
        }

        if (mode == Mode.Follow)
        {
            if (flip)
            {
                flipX = bone.flipX;
            }


            if (position)
            {
                cachedTransform.localPosition = new Vector3(bone.x, bone.y, 0);
            }

            if (rotation)
            {
                if (bone.Data.InheritRotation)
                {
                    if (bone.FlipX)
                    {
                        cachedTransform.localRotation = Quaternion.Euler(0, 180, bone.rotationIK - flipCompensation);
                    }
                    else
                    {
                        cachedTransform.localRotation = Quaternion.Euler(0, 0, bone.rotationIK);
                    }
                }
                else
                {
                    Vector3 euler = skeletonTransform.rotation.eulerAngles;
                    cachedTransform.rotation = Quaternion.Euler(euler.x, euler.y, skeletonTransform.rotation.eulerAngles.z + (bone.worldRotation * skeletonFlipRotation));
                }
            }

            if (scale)
            {
                cachedTransform.localScale = new Vector3(bone.scaleX, bone.scaleY, bone.worldFlipX ? -1 : 1);

                nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
            }
        }
        else if (mode == Mode.Override)
        {
            if (transformLerpComplete)
            {
                return;
            }

            if (parentReference == null)
            {
                if (position)
                {
                    bone.x = Mathf.Lerp(bone.x, cachedTransform.localPosition.x, overrideAlpha);
                    bone.y = Mathf.Lerp(bone.y, cachedTransform.localPosition.y, overrideAlpha);
                }

                if (rotation)
                {
                    float angle = Mathf.LerpAngle(bone.Rotation, cachedTransform.localRotation.eulerAngles.z, overrideAlpha) + flipCompensation;

                    if (flip)
                    {
                        if ((!flipX && bone.flipX))
                        {
                            angle -= flipCompensation;
                        }

                        //TODO fix this...
                        if (angle >= 360)
                        {
                            angle -= 360;
                        }
                        else if (angle <= -360)
                        {
                            angle += 360;
                        }
                    }

                    bone.Rotation   = angle;
                    bone.RotationIK = angle;
                }

                if (scale)
                {
                    bone.scaleX = Mathf.Lerp(bone.scaleX, cachedTransform.localScale.x, overrideAlpha);
                    bone.scaleY = Mathf.Lerp(bone.scaleY, cachedTransform.localScale.y, overrideAlpha);

                    nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
                }

                if (flip)
                {
                    bone.flipX = flipX;
                }
            }
            else
            {
                if (transformLerpComplete)
                {
                    return;
                }

                if (position)
                {
                    Vector3 pos = parentReference.InverseTransformPoint(cachedTransform.position);
                    bone.x = Mathf.Lerp(bone.x, pos.x, overrideAlpha);
                    bone.y = Mathf.Lerp(bone.y, pos.y, overrideAlpha);
                }

                if (rotation)
                {
                    float angle = Mathf.LerpAngle(bone.Rotation, Quaternion.LookRotation(flipX ? Vector3.forward * -1 : Vector3.forward, parentReference.InverseTransformDirection(cachedTransform.up)).eulerAngles.z, overrideAlpha) + flipCompensation;

                    if (flip)
                    {
                        if ((!flipX && bone.flipX))
                        {
                            angle -= flipCompensation;
                        }

                        //TODO fix this...
                        if (angle >= 360)
                        {
                            angle -= 360;
                        }
                        else if (angle <= -360)
                        {
                            angle += 360;
                        }
                    }

                    bone.Rotation   = angle;
                    bone.RotationIK = angle;
                }

                //TODO: Something about this
                if (scale)
                {
                    bone.scaleX = Mathf.Lerp(bone.scaleX, cachedTransform.localScale.x, overrideAlpha);
                    bone.scaleY = Mathf.Lerp(bone.scaleY, cachedTransform.localScale.y, overrideAlpha);

                    nonUniformScaleWarning = (bone.scaleX != bone.scaleY);
                }

                if (flip)
                {
                    bone.flipX = flipX;
                }
            }

            transformLerpComplete = true;
        }
    }