• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Spine.SkeletonData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Spine.SkeletonData的典型用法代码示例。如果您正苦于以下问题:C# SkeletonData类的具体用法?C# SkeletonData怎么用?C# SkeletonData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SkeletonData类属于Spine命名空间,在下文中一共展示了SkeletonData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Skeleton

		public Skeleton (SkeletonData data) {
			if (data == null) throw new ArgumentNullException("data cannot be null.");
			this.data = data;

			bones = new ExposedList<Bone>(data.bones.Count);
			foreach (BoneData boneData in data.bones) {
				Bone parent = boneData.parent == null ? null : bones.Items[data.bones.IndexOf(boneData.parent)];
				Bone bone = new Bone(boneData, this, parent);
				if (parent != null) parent.children.Add(bone);
				bones.Add(bone);
			}

			slots = new ExposedList<Slot>(data.slots.Count);
			drawOrder = new ExposedList<Slot>(data.slots.Count);
			foreach (SlotData slotData in data.slots) {
				Bone bone = bones.Items[data.bones.IndexOf(slotData.boneData)];
				Slot slot = new Slot(slotData, bone);
				slots.Add(slot);
				drawOrder.Add(slot);
			}

			ikConstraints = new ExposedList<IkConstraint>(data.ikConstraints.Count);
			foreach (IkConstraintData ikConstraintData in data.ikConstraints)
				ikConstraints.Add(new IkConstraint(ikConstraintData, this));

			transformConstraints = new ExposedList<TransformConstraint>(data.transformConstraints.Count);
			foreach (TransformConstraintData transformConstraintData in data.transformConstraints)
				transformConstraints.Add(new TransformConstraint(transformConstraintData, this));

			UpdateCache();
			UpdateWorldTransform();
		}
开发者ID:czlc,项目名称:spine-runtimes,代码行数:32,代码来源:Skeleton.cs


示例2: AnimationPlayer

 public AnimationPlayer(SkeletonData skeletonData)
 {
     this.skeletonData = skeletonData;
     skeleton = new Skeleton(skeletonData);
     skeleton.SetSlotsToSetupPose();
     animationDataPool = new ObjectPool<AnimationData>(() => new AnimationData(), 10);
 }
开发者ID:ThirdPartyNinjas,项目名称:NinjaSharp,代码行数:7,代码来源:AnimationPlayer.cs


示例3: OnEnable

		void OnEnable () {

			SpineEditorUtilities.ConfirmInitialization();

			try {
				atlasAssets = serializedObject.FindProperty("atlasAssets");
				atlasAssets.isExpanded = true;
				skeletonJSON = serializedObject.FindProperty("skeletonJSON");
				scale = serializedObject.FindProperty("scale");
				fromAnimation = serializedObject.FindProperty("fromAnimation");
				toAnimation = serializedObject.FindProperty("toAnimation");
				duration = serializedObject.FindProperty("duration");
				defaultMix = serializedObject.FindProperty("defaultMix");
				#if SPINE_SKELETON_ANIMATOR
				controller = serializedObject.FindProperty("controller");
				#endif
				#if SPINE_TK2D
				spriteCollection = serializedObject.FindProperty("spriteCollection");
				#endif

				m_skeletonDataAsset = (SkeletonDataAsset)target;
				m_skeletonDataAssetGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_skeletonDataAsset));

				EditorApplication.update += Update;
			} catch {
				// TODO: WARNING: empty catch block supresses errors.

			}

			m_skeletonData = m_skeletonDataAsset.GetSkeletonData(true);

			showBaking = EditorPrefs.GetBool("SkeletonDataAssetInspector_showUnity", false);

			RepopulateWarnings();
		}
开发者ID:SirFelolis,项目名称:Snot-Ninja,代码行数:35,代码来源:SkeletonDataAssetInspector.cs


示例4: OnEnable

	void OnEnable () {

		SpineEditorUtilities.ConfirmInitialization();

		try {
			atlasAssets = serializedObject.FindProperty("atlasAssets");
			skeletonJSON = serializedObject.FindProperty("skeletonJSON");
			scale = serializedObject.FindProperty("scale");
			fromAnimation = serializedObject.FindProperty("fromAnimation");
			toAnimation = serializedObject.FindProperty("toAnimation");
			duration = serializedObject.FindProperty("duration");
			defaultMix = serializedObject.FindProperty("defaultMix");
			controller = serializedObject.FindProperty("controller");
#if SPINE_TK2D
			spriteCollection = serializedObject.FindProperty("spriteCollection");
#endif

			m_skeletonDataAsset = (SkeletonDataAsset)target;
			m_skeletonDataAssetGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_skeletonDataAsset));

			EditorApplication.update += Update;
		} catch {


		}

		m_skeletonData = m_skeletonDataAsset.GetSkeletonData(true);

		showUnity = EditorPrefs.GetBool("SkeletonDataAssetInspector_showUnity", true);

		RepopulateWarnings();
	}
开发者ID:wenhaoisbad,项目名称:kxsm,代码行数:32,代码来源:SkeletonDataAssetInspector.cs


示例5: MakeSkeletonAndAnimationData

    /*
     */
    private void MakeSkeletonAndAnimationData()
    {
        if(sprites == null) {
            Debug.LogWarning("Sprite collection not set for skeleton data asset: " + name,this);
            return;
        }

        if(skeletonJSON == null) {
            Debug.LogWarning("Skeleton JSON file not set for skeleton data asset: " + name,this);
            return;
        }

        SkeletonJson json = new SkeletonJson(new tk2dSpineAttachmentLoader(sprites.spriteCollection));
        json.Scale = scale;

        try {
            skeletonData = json.ReadSkeletonData(new StringReader(skeletonJSON.text));
        } catch (Exception ex) {
            Debug.Log("Error reading skeleton JSON file for skeleton data asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace,this);
            return;
        }

        stateData = new AnimationStateData(skeletonData);
        for(int i = 0, n = fromAnimation.Length; i < n; i++) {
            if(fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue;
            stateData.SetMix(fromAnimation[i],toAnimation[i],duration[i]);
        }
    }
开发者ID:anhuishuqi,项目名称:spine-runtimes,代码行数:30,代码来源:tk2dSpineSkeletonDataAsset.cs


示例6: Skeleton

		public Skeleton (SkeletonData data) {
			if (data == null) throw new ArgumentNullException("data cannot be null.");
			this.data = data;

			bones = new List<Bone>(data.bones.Count);
			foreach (BoneData boneData in data.bones) {
				Bone parent = boneData.parent == null ? null : bones[data.bones.IndexOf(boneData.parent)];
				bones.Add(new Bone(boneData, this, parent));
			}

			slots = new List<Slot>(data.slots.Count);
			drawOrder = new List<Slot>(data.slots.Count);
			foreach (SlotData slotData in data.slots) {
				Bone bone = bones[data.bones.IndexOf(slotData.boneData)];
				Slot slot = new Slot(slotData, bone);
				slots.Add(slot);
				drawOrder.Add(slot);
			}

			ikConstraints = new List<IkConstraint>(data.ikConstraints.Count);
			foreach (IkConstraintData ikConstraintData in data.ikConstraints)
				ikConstraints.Add(new IkConstraint(ikConstraintData, this));

			UpdateCache();
		}
开发者ID:KissCat,项目名称:spine-runtimes,代码行数:25,代码来源:Skeleton.cs


示例7: OnEnable

		void OnEnable () {
			SpineEditorUtilities.ConfirmInitialization();

			atlasAssets = serializedObject.FindProperty("atlasAssets");
			skeletonJSON = serializedObject.FindProperty("skeletonJSON");
			scale = serializedObject.FindProperty("scale");
			fromAnimation = serializedObject.FindProperty("fromAnimation");
			toAnimation = serializedObject.FindProperty("toAnimation");
			duration = serializedObject.FindProperty("duration");
			defaultMix = serializedObject.FindProperty("defaultMix");

			#if SPINE_SKELETON_ANIMATOR
			controller = serializedObject.FindProperty("controller");
			#endif

			#if SPINE_TK2D
			atlasAssets.isExpanded = false;
			spriteCollection = serializedObject.FindProperty("spriteCollection");
			#else
			atlasAssets.isExpanded = true;
			#endif

			#if SPINE_BAKING
			isBakingExpanded = EditorPrefs.GetBool(ShowBakingPrefsKey, false);
			#endif

			m_skeletonDataAsset = (SkeletonDataAsset)target;
			m_skeletonDataAssetGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_skeletonDataAsset));
			EditorApplication.update += EditorUpdate;
			m_skeletonData = m_skeletonDataAsset.GetSkeletonData(false);
			RepopulateWarnings();
		}
开发者ID:smartether,项目名称:spine-runtimes,代码行数:32,代码来源:SkeletonDataAssetInspector.cs


示例8: Skeleton

        public Skeleton(SkeletonData data)
        {
            if (data == null) throw new ArgumentNullException("data cannot be null.");
            Data = data;

            Bones = new List<Bone>(Data.Bones.Count);
            foreach (BoneData boneData in Data.Bones) {
                Bone parent = boneData.Parent == null ? null : Bones[Data.Bones.IndexOf(boneData.Parent)];
                Bones.Add(new Bone(boneData, parent));
            }

            Slots = new List<Slot>(Data.Slots.Count);
            DrawOrder = new List<Slot>(Data.Slots.Count);
            foreach (SlotData slotData in Data.Slots) {
                Bone bone = Bones[Data.Bones.IndexOf(slotData.BoneData)];
                Slot slot = new Slot(slotData, this, bone);
                Slots.Add(slot);
                DrawOrder.Add(slot);
            }

            R = 1;
            G = 1;
            B = 1;
            A = 1;
        }
开发者ID:niteshpurohit,项目名称:spine-runtimes,代码行数:25,代码来源:Skeleton.cs


示例9: LoadContent

        protected override void LoadContent()
        {
            Effect spriteBatchEffect = Content.Load<Effect>("SpriteBatchEffect");
            spriteBatch = new SpriteBatchEx(GraphicsDevice, spriteBatchEffect);

            Bone.yDown = true;
            skeletonData = Content.Load<SkeletonData>("spineboy/spineboy");
            skeleton = new Skeleton(skeletonData);
            skeleton.SetSlotsToSetupPose();

            AnimationStateData stateData = new AnimationStateData(skeleton.Data);
            animationState = new AnimationState(stateData);
            animationState.SetAnimation(0, "walk", true);

            skeleton.UpdateWorldTransform();
        }
开发者ID:ThirdPartyNinjas,项目名称:NinjaSharp,代码行数:16,代码来源:TestGame.cs


示例10: GetSkeletonData

	public SkeletonData GetSkeletonData (bool quiet) {
		if (atlasAsset == null) {
			if (!quiet)
				Debug.LogError("Atlas not set for SkeletonData asset: " + name, this);
			Reset();
			return null;
		}

		// if (skeletonJSON == null) {
        if (string.IsNullOrEmpty(skeletonJsonStr)) {
			if (!quiet)
				Debug.LogError("Skeleton JSON file not set for SkeletonData asset: " + name, this);
			Reset();
			return null;
		}

		Atlas atlas = atlasAsset.GetAtlas();
		if (atlas == null) {
			Reset();
			return null;
		}

		if (skeletonData != null)
			return skeletonData;

		SkeletonJson json = new SkeletonJson(atlas);
		json.Scale = scale;
		try {
            // skeletonData = json.ReadSkeletonData(new StringReader(skeletonJSON.text));
            skeletonData = json.ReadSkeletonData(new StringReader(skeletonJsonStr));
        }
        catch (Exception ex)
        {
			if (!quiet)
				Debug.LogError("Error reading skeleton JSON file for SkeletonData asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this);
			return null;
		}

		stateData = new AnimationStateData(skeletonData);
		stateData.DefaultMix = defaultMix;
		for (int i = 0, n = fromAnimation.Length; i < n; i++) {
			if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue;
			stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
		}

		return skeletonData;
	}
开发者ID:Henry-T,项目名称:UnityPG,代码行数:47,代码来源:SkeletonDataAsset.cs


示例11: GetSkeletonData

    public SkeletonData GetSkeletonData(bool quiet)
    {
        if (atlasAsset == null) {
            if (!quiet)
                Debug.LogWarning("Atlas not set for skeleton data asset: " + name, this);
            Clear();
            return null;
        }

        if (skeletonJSON == null) {
            if (!quiet)
                Debug.LogWarning("Skeleton JSON file not set for skeleton data asset: " + name, this);
            Clear();
            return null;
        }

        Atlas atlas = atlasAsset.GetAtlas();
        if (atlas == null) {
            Clear();
            return null;
        }

        if (skeletonData != null)
            return skeletonData;

        SkeletonJson json = new SkeletonJson(atlas);
        json.Scale = scale;
        try {
            skeletonData = json.ReadSkeletonData(new StringReader(skeletonJSON.text));
        } catch (Exception) {
            if (!quiet)
                Debug.LogException(new Exception("Error reading skeleton JSON file for skeleton data asset: " + name), this);
            return null;
        }

        stateData = new AnimationStateData(skeletonData);
        for (int i = 0, n = fromAnimation.Length; i < n; i++)
            stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);

        return skeletonData;
    }
开发者ID:EOG,项目名称:spine-runtimes,代码行数:41,代码来源:SkeletonDataAsset.cs


示例12: GetSkeletonData

	public SkeletonData GetSkeletonData (bool quiet) {
		if (spriteCollection == null) {
			if (!quiet)
				Debug.LogWarning("Sprite collection not set for skeleton data asset: " + name, this);
			Clear();
			return null;
		}

		if (skeletonJSON == null) {
			if (!quiet)
				Debug.LogWarning("Skeleton JSON file not set for skeleton data asset: " + name, this);
			Clear();
			return null;
		}

		if (skeletonData != null)
			return skeletonData;

		SkeletonJson json = new SkeletonJson(new SpriteCollectionAttachmentLoader(spriteCollection));
		json.Scale = 1.0f / (spriteCollection.invOrthoSize * spriteCollection.halfTargetHeight) * scale;

		try {
			skeletonData = json.ReadSkeletonData(new StringReader(skeletonJSON.text));
		} catch (Exception ex) {
			Debug.Log("Error reading skeleton JSON file for skeleton data asset: " + name + "\n" +
				ex.Message + "\n" + ex.StackTrace, this);
			return null;
		}

		stateData = new AnimationStateData(skeletonData);
		for (int i = 0, n = fromAnimation.Length; i < n; i++) {
			if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0)
				continue;
			stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
		}

		return skeletonData;
	}
开发者ID:rtumelty,项目名称:ridiculousrescue,代码行数:38,代码来源:SkeletonDataAsset.cs


示例13: readAnimation

        private void readAnimation(String name, Dictionary<String, Object> map, SkeletonData skeletonData)
        {
            var timelines = new List<Timeline>();
            float duration = 0;

            var bonesMap = (Dictionary<String, Object>)map["bones"];
            foreach (KeyValuePair<String, Object> entry in bonesMap) {
                String boneName = entry.Key;
                int boneIndex = skeletonData.FindBoneIndex(boneName);
                if (boneIndex == -1)
                    throw new Exception("Bone not found: " + boneName);

                Dictionary<String, Object> timelineMap = (Dictionary<String, Object>)entry.Value;
                foreach (KeyValuePair<String, Object> timelineEntry in timelineMap) {
                    List<Object> values = (List<Object>)timelineEntry.Value;
                    String timelineName = (String)timelineEntry.Key;
                    if (timelineName.Equals(TIMELINE_ROTATE)) {
                        RotateTimeline timeline = new RotateTimeline(values.Count);
                        timeline.BoneIndex = boneIndex;

                        int frameIndex = 0;
                        foreach (Dictionary<String, Object> valueMap in values) {
                            float time = (float)valueMap["time"];
                            timeline.SetFrame(frameIndex, time, (float)valueMap["angle"]);
                            readCurve(timeline, frameIndex, valueMap);
                            frameIndex++;
                        }
                        timelines.Add(timeline);
                        duration = Math.Max(duration, timeline.Frames[timeline.FrameCount * 2 - 2]);

                    } else if (timelineName.Equals(TIMELINE_TRANSLATE) || timelineName.Equals(TIMELINE_SCALE)) {
                        TranslateTimeline timeline;
                        float timelineScale = 1;
                        if (timelineName.Equals(TIMELINE_SCALE))
                            timeline = new ScaleTimeline(values.Count);
                        else {
                            timeline = new TranslateTimeline(values.Count);
                            timelineScale = Scale;
                        }
                        timeline.BoneIndex = boneIndex;

                        int frameIndex = 0;
                        foreach (Dictionary<String, Object> valueMap in values) {
                            float time = (float)valueMap["time"];
                            float x = valueMap.ContainsKey("x") ? (float)valueMap["x"] : 0;
                            float y = valueMap.ContainsKey("y") ? (float)valueMap["y"] : 0;
                            timeline.SetFrame(frameIndex, time, (float)x * timelineScale, (float)y * timelineScale);
                            readCurve(timeline, frameIndex, valueMap);
                            frameIndex++;
                        }
                        timelines.Add(timeline);
                        duration = Math.Max(duration, timeline.Frames[timeline.FrameCount * 3 - 3]);

                    } else
                        throw new Exception("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")");
                }
            }

            if (map.ContainsKey("slots")) {
                Dictionary<String, Object> slotsMap = (Dictionary<String, Object>)map["slots"];
                foreach (KeyValuePair<String, Object> entry in slotsMap) {
                    String slotName = entry.Key;
                    int slotIndex = skeletonData.FindSlotIndex(slotName);
                    Dictionary<String, Object> timelineMap = (Dictionary<String, Object>)entry.Value;

                    foreach (KeyValuePair<String, Object> timelineEntry in timelineMap) {
                        List<Object> values = (List<Object>)timelineEntry.Value;
                        String timelineName = (String)timelineEntry.Key;
                        if (timelineName.Equals(TIMELINE_COLOR)) {
                            ColorTimeline timeline = new ColorTimeline(values.Count);
                            timeline.SlotIndex = slotIndex;

                            int frameIndex = 0;
                            foreach (Dictionary<String, Object> valueMap in values) {
                                float time = (float)valueMap["time"];
                                String c = (String)valueMap["color"];
                                timeline.setFrame(frameIndex, time, toColor(c, 0), toColor(c, 1), toColor(c, 2), toColor(c, 3));
                                readCurve(timeline, frameIndex, valueMap);
                                frameIndex++;
                            }
                            timelines.Add(timeline);
                            duration = Math.Max(duration, timeline.Frames[timeline.FrameCount * 5 - 5]);

                        } else if (timelineName.Equals(TIMELINE_ATTACHMENT)) {
                            AttachmentTimeline timeline = new AttachmentTimeline(values.Count);
                            timeline.SlotIndex = slotIndex;

                            int frameIndex = 0;
                            foreach (Dictionary<String, Object> valueMap in values) {
                                float time = (float)valueMap["time"];
                                timeline.setFrame(frameIndex++, time, (String)valueMap["name"]);
                            }
                            timelines.Add(timeline);
                            duration = Math.Max(duration, timeline.Frames[timeline.FrameCount - 1]);

                        } else
                            throw new Exception("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")");
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:H4ch1k0,项目名称:spine-runtimes,代码行数:101,代码来源:SkeletonJson.cs


示例14: CCSkeletonAnimation

 public CCSkeletonAnimation(SkeletonData skeletonData)
     : base(skeletonData,false)
 {
     this.initializer();
 }
开发者ID:netonjm,项目名称:spine-runtimes,代码行数:5,代码来源:CCSkeletonAnimation.cs


示例15: ReadSkeletonData

		public SkeletonData ReadSkeletonData (TextReader reader) {
			if (reader == null) throw new ArgumentNullException("reader", "reader cannot be null.");

			var scale = this.Scale;
			var skeletonData = new SkeletonData();

			var root = Json.Deserialize(reader) as Dictionary<String, Object>;
			if (root == null) throw new Exception("Invalid JSON.");

			// Skeleton.
			if (root.ContainsKey("skeleton")) {
				var skeletonMap = (Dictionary<String, Object>)root["skeleton"];
				skeletonData.hash = (String)skeletonMap["hash"];
				skeletonData.version = (String)skeletonMap["spine"];
				skeletonData.width = GetFloat(skeletonMap, "width", 0);
				skeletonData.height = GetFloat(skeletonMap, "height", 0);
				skeletonData.fps = GetFloat(skeletonMap, "fps", 0);
				skeletonData.imagesPath = GetString(skeletonMap, "images", null);
			}

			// Bones.
			foreach (Dictionary<String, Object> boneMap in (List<Object>)root["bones"]) {
				BoneData parent = null;
				if (boneMap.ContainsKey("parent")) {
					parent = skeletonData.FindBone((String)boneMap["parent"]);
					if (parent == null)
						throw new Exception("Parent bone not found: " + boneMap["parent"]);
				}
				var data = new BoneData(skeletonData.Bones.Count, (String)boneMap["name"], parent);
				data.length = GetFloat(boneMap, "length", 0) * scale;
				data.x = GetFloat(boneMap, "x", 0) * scale;
				data.y = GetFloat(boneMap, "y", 0) * scale;
				data.rotation = GetFloat(boneMap, "rotation", 0);
				data.scaleX = GetFloat(boneMap, "scaleX", 1);
				data.scaleY = GetFloat(boneMap, "scaleY", 1);
				data.shearX = GetFloat(boneMap, "shearX", 0);
				data.shearY = GetFloat(boneMap, "shearY", 0);

				string tm = GetString(boneMap, "transform", TransformMode.Normal.ToString());
				data.transformMode = (TransformMode)Enum.Parse(typeof(TransformMode), tm, true);

				skeletonData.bones.Add(data);
			}

			// Slots.
			if (root.ContainsKey("slots")) {
				foreach (Dictionary<String, Object> slotMap in (List<Object>)root["slots"]) {
					var slotName = (String)slotMap["name"];
					var boneName = (String)slotMap["bone"];
					BoneData boneData = skeletonData.FindBone(boneName);
					if (boneData == null) throw new Exception("Slot bone not found: " + boneName);
					var data = new SlotData(skeletonData.Slots.Count, slotName, boneData);

					if (slotMap.ContainsKey("color")) {
						var color = (String)slotMap["color"];
						data.r = ToColor(color, 0);
						data.g = ToColor(color, 1);
						data.b = ToColor(color, 2);
						data.a = ToColor(color, 3);
					}
						
					data.attachmentName = GetString(slotMap, "attachment", null);
					if (slotMap.ContainsKey("blend"))
						data.blendMode = (BlendMode)Enum.Parse(typeof(BlendMode), (String)slotMap["blend"], false);
					else
						data.blendMode = BlendMode.normal;
					skeletonData.slots.Add(data);
				}
			}

			// IK constraints.
			if (root.ContainsKey("ik")) {
				foreach (Dictionary<String, Object> constraintMap in (List<Object>)root["ik"]) {
					IkConstraintData data = new IkConstraintData((String)constraintMap["name"]);
					data.order = GetInt(constraintMap, "order", 0);

					foreach (String boneName in (List<Object>)constraintMap["bones"]) {
						BoneData bone = skeletonData.FindBone(boneName);
						if (bone == null) throw new Exception("IK constraint bone not found: " + boneName);
						data.bones.Add(bone);
					}
					
					String targetName = (String)constraintMap["target"];
					data.target = skeletonData.FindBone(targetName);
					if (data.target == null) throw new Exception("Target bone not found: " + targetName);

					data.bendDirection = GetBoolean(constraintMap, "bendPositive", true) ? 1 : -1;
					data.mix = GetFloat(constraintMap, "mix", 1);

					skeletonData.ikConstraints.Add(data);
				}
			}

			// Transform constraints.
			if (root.ContainsKey("transform")) {
				foreach (Dictionary<String, Object> constraintMap in (List<Object>)root["transform"]) {
					TransformConstraintData data = new TransformConstraintData((String)constraintMap["name"]);
					data.order = GetInt(constraintMap, "order", 0);

					foreach (String boneName in (List<Object>)constraintMap["bones"]) {
//.........这里部分代码省略.........
开发者ID:EsotericSoftware,项目名称:spine-runtimes,代码行数:101,代码来源:SkeletonJson.cs


示例16: ReadAnimation

		private void ReadAnimation (Dictionary<String, Object> map, String name, SkeletonData skeletonData) {
			var scale = this.Scale;
			var timelines = new ExposedList<Timeline>();
			float duration = 0;

			// Slot timelines.
			if (map.ContainsKey("slots")) {
				foreach (KeyValuePair<String, Object> entry in (Dictionary<String, Object>)map["slots"]) {
					String slotName = entry.Key;
					int slotIndex = skeletonData.FindSlotIndex(slotName);
					var timelineMap = (Dictionary<String, Object>)entry.Value;
					foreach (KeyValuePair<String, Object> timelineEntry in timelineMap) {
						var values = (List<Object>)timelineEntry.Value;
						var timelineName = (String)timelineEntry.Key;
						if (timelineName == "color") {
							var timeline = new ColorTimeline(values.Count);
							timeline.slotIndex = slotIndex;

							int frameIndex = 0;
							foreach (Dictionary<String, Object> valueMap in values) {
								float time = (float)valueMap["time"];
								String c = (String)valueMap["color"];
								timeline.SetFrame(frameIndex, time, ToColor(c, 0), ToColor(c, 1), ToColor(c, 2), ToColor(c, 3));
								ReadCurve(valueMap, timeline, frameIndex);
								frameIndex++;
							}
							timelines.Add(timeline);
							duration = Math.Max(duration, timeline.frames[(timeline.FrameCount - 1) * ColorTimeline.ENTRIES]);

						} else if (timelineName == "attachment") {
							var timeline = new AttachmentTimeline(values.Count);
							timeline.slotIndex = slotIndex;

							int frameIndex = 0;
							foreach (Dictionary<String, Object> valueMap in values) {
								float time = (float)valueMap["time"];
								timeline.SetFrame(frameIndex++, time, (String)valueMap["name"]);
							}
							timelines.Add(timeline);
							duration = Math.Max(duration, timeline.frames[timeline.FrameCount - 1]);

						} else
							throw new Exception("Invalid timeline type for a slot: " + timelineName + " (" + slotName + ")");
					}
				}
			}

			// Bone timelines.
			if (map.ContainsKey("bones")) {
				foreach (KeyValuePair<String, Object> entry in (Dictionary<String, Object>)map["bones"]) {
					String boneName = entry.Key;
					int boneIndex = skeletonData.FindBoneIndex(boneName);
					if (boneIndex == -1) throw new Exception("Bone not found: " + boneName);
					var timelineMap = (Dictionary<String, Object>)entry.Value;
					foreach (KeyValuePair<String, Object> timelineEntry in timelineMap) {
						var values = (List<Object>)timelineEntry.Value;
						var timelineName = (String)timelineEntry.Key;
						if (timelineName == "rotate") {
							var timeline = new RotateTimeline(values.Count);
							timeline.boneIndex = boneIndex;

							int frameIndex = 0;
							foreach (Dictionary<String, Object> valueMap in values) {
								timeline.SetFrame(frameIndex, (float)valueMap["time"], (float)valueMap["angle"]);
								ReadCurve(valueMap, timeline, frameIndex);
								frameIndex++;
							}
							timelines.Add(timeline);
							duration = Math.Max(duration, timeline.frames[(timeline.FrameCount - 1) * RotateTimeline.ENTRIES]);

						} else if (timelineName == "translate" || timelineName == "scale" || timelineName == "shear") {
							TranslateTimeline timeline;
							float timelineScale = 1;
							if (timelineName == "scale")
								timeline = new ScaleTimeline(values.Count);
							else if (timelineName == "shear")
								timeline = new ShearTimeline(values.Count);
							else {
								timeline = new TranslateTimeline(values.Count);
								timelineScale = scale;
							}
							timeline.boneIndex = boneIndex;

							int frameIndex = 0;
							foreach (Dictionary<String, Object> valueMap in values) {
								float time = (float)valueMap["time"];
								float x = GetFloat(valueMap, "x", 0);
								float y = GetFloat(valueMap, "y", 0);
								timeline.SetFrame(frameIndex, time, x * timelineScale, y * timelineScale);
								ReadCurve(valueMap, timeline, frameIndex);
								frameIndex++;
							}
							timelines.Add(timeline);
							duration = Math.Max(duration, timeline.frames[(timeline.FrameCount - 1) * TranslateTimeline.ENTRIES]);

						} else
							throw new Exception("Invalid timeline type for a bone: " + timelineName + " (" + boneName + ")");
					}
				}
			}
//.........这里部分代码省略.........
开发者ID:EsotericSoftware,项目名称:spine-runtimes,代码行数:101,代码来源:SkeletonJson.cs


示例17: CreatePreviewInstances

		void CreatePreviewInstances () {
			this.DestroyPreviewInstances();

			var skeletonDataAsset = (SkeletonDataAsset)target;
			if (skeletonDataAsset.GetSkeletonData(false) == null)
				return;

			if (this.m_previewInstance == null) {
				string skinName = EditorPrefs.GetString(m_skeletonDataAssetGUID + "_lastSkin", "");
				m_previewInstance = SpineEditorUtilities.InstantiateSkeletonAnimation(skeletonDataAsset, skinName).gameObject;

				if (m_previewInstance != null) {
					m_previewInstance.hideFlags = HideFlags.HideAndDontSave;
					m_previewInstance.layer = 0x1f;
					m_skeletonAnimation = m_previewInstance.GetComponent<SkeletonAnimation>();
					m_skeletonAnimation.initialSkinName = skinName;
					m_skeletonAnimation.LateUpdate();
					m_skeletonData = m_skeletonAnimation.skeletonDataAsset.GetSkeletonData(true);
					m_previewInstance.GetComponent<Renderer>().enabled = false;
					m_initialized = true;
				}

				AdjustCameraGoals(true);
			}
		}
开发者ID:smartether,项目名称:spine-runtimes,代码行数:25,代码来源:SkeletonDataAssetInspector.cs


示例18: GetExtractionBone

	static Bone GetExtractionBone () {
		if (extractionBone != null)
			return extractionBone;

		SkeletonData skelData = new SkeletonData();
		BoneData data = new BoneData("temp", null);
		data.ScaleX = 1;
		data.ScaleY = 1;
		data.Length = 100;

		skelData.Bones.Add(data);

		Skeleton skeleton = new Skeleton(skelData);

		Bone bone = new Bone(data, skeleton, null);
		bone.UpdateWorldTransform();

		extractionBone = bone;

		return extractionBone;
	}
开发者ID:wenhaoisbad,项目名称:kxsm,代码行数:21,代码来源:SkeletonBaker.cs


示例19: ReadSkeletonData

		public SkeletonData ReadSkeletonData (TextReader reader) {
			if (reader == null) throw new ArgumentNullException("reader cannot be null.");

			SkeletonData skeletonData = new SkeletonData();

			var root = Json.Deserialize(reader) as Dictionary<String, Object>;
			if (root == null) throw new Exception("Invalid JSON.");

			// Bones.
			foreach (Dictionary<String, Object> boneMap in (List<Object>)root["bones"]) {
				BoneData parent = null;
				if (boneMap.ContainsKey("parent")) {
					parent = skeletonData.FindBone((String)boneMap["parent"]);
					if (parent == null)
						throw new Exception("Parent bone not found: " + boneMap["parent"]);
				}
				BoneData boneData = new BoneData((String)boneMap["name"], parent);
				boneData.length = GetFloat(boneMap, "length", 0) * Scale;
				boneData.x = GetFloat(boneMap, "x", 0) * Scale;
				boneData.y = GetFloat(boneMap, "y", 0) * Scale;
				boneData.rotation = GetFloat(boneMap, "rotation", 0);
				boneData.scaleX = GetFloat(boneMap, "scaleX", 1);
				boneData.scaleY = GetFloat(boneMap, "scaleY", 1);
				boneData.inheritScale = GetBoolean(boneMap, "inheritScale", true);
				boneData.inheritRotation = GetBoolean(boneMap, "inheritRotation", true);
				skeletonData.AddBone(boneData);
			}

			// Slots.
			if (root.ContainsKey("slots")) {
				foreach (Dictionary<String, Object> slotMap in (List<Object>)root["slots"]) {
					String slotName = (String)slotMap["name"];
					String boneName = (String)slotMap["bone"];
					BoneData boneData = skeletonData.FindBone(boneName);
					if (boneData == null)
						throw new Exception("Slot bone not found: " + boneName);
					SlotData slotData = new SlotData(slotName, boneData);

					if (slotMap.ContainsKey("color")) {
						String color = (String)slotMap["color"];
						slotData.r = ToColor(color, 0);
						slotData.g = ToColor(color, 1);
						slotData.b = ToColor(color, 2);
						slotData.a = ToColor(color, 3);
					}

					if (slotMap.ContainsKey("attachment"))
						slotData.attachmentName = (String)slotMap["attachment"];

					if (slotMap.ContainsKey("additive"))
						slotData.additiveBlending = (bool)slotMap["additive"];

					skeletonData.AddSlot(slotData);
				}
			}

			// Skins.
			if (root.ContainsKey("skins")) {
				foreach (KeyValuePair<String, Object> entry in (Dictionary<String, Object>)root["skins"]) {
					Skin skin = new Skin(entry.Key);
					foreach (KeyValuePair<String, Object> slotEntry in (Dictionary<String, Object>)entry.Value) {
						int slotIndex = skeletonData.FindSlotIndex(slotEntry.Key);
						foreach (KeyValuePair<String, Object> attachmentEntry in ((Dictionary<String, Object>)slotEntry.Value)) {
							Attachment attachment = ReadAttachment(skin, attachmentEntry.Key, (Dictionary<String, Object>)attachmentEntry.Value);
							if (attachment != null) skin.AddAttachment(slotIndex, attachmentEntry.Key, attachment);
						}
					}
					skeletonData.AddSkin(skin);
					if (skin.name == "default")
						skeletonData.defaultSkin = skin;
				}
			}

			// Events.
			if (root.ContainsKey("events")) {
				foreach (KeyValuePair<String, Object> entry in (Dictionary<String, Object>)root["events"]) {
					var entryMap = (Dictionary<String, Object>)entry.Value;
					EventData eventData = new EventData(entry.Key);
					eventData.Int = GetInt(entryMap, "int", 0);
					eventData.Float = GetFloat(entryMap, "float", 0);
					eventData.String = GetString(entryMap, "string", null);
					skeletonData.AddEvent(eventData);
				}
			}

			// Animations.
			if (root.ContainsKey("animations")) {
				foreach (KeyValuePair<String, Object> entry in (Dictionary<String, Object>)root["animations"])
					ReadAnimation(entry.Key, (Dictionary<String, Object>)entry.Value, skeletonData);
			}

			skeletonData.bones.TrimExcess();
			skeletonData.slots.TrimExcess();
			skeletonData.skins.TrimExcess();
			skeletonData.animations.TrimExcess();
			return skeletonData;
		}
开发者ID:jaimeBokoko,项目名称:spine-runtimes,代码行数:97,代码来源:SkeletonJson.cs


示例20: ReadAnimation

		private void ReadAnimation (String name, Dictionary<String, Object> map, SkeletonData skeletonData) {
			var timelines = new List<Timeline>();
			float duration = 0;

			if (map.ContainsKey("bones")) {
				foreach (KeyValuePair<String, Object> entry in (Dictionary<String, Object>)map["bones"]) {
					String boneName = entry.Key;
					int boneIndex = skeletonData.FindBoneIndex(boneName);
					if (boneIndex == -1)
						throw new Exception("Bone not found: " + boneName);

					var timelineMap = (Dictionary<String, Object>)entry.Value;
					foreach (KeyValuePair<String, Object> timelineEntry in timelineMap) {
						var values = (List<Object>)timelineEntry.Value;
						String timelineName = (String)timelineEntry.Key;
						if (timelineName.Equals(TIMELINE_ROTATE)) {
							RotateTimeline timeline = new RotateTimeline(values.Count);
							timeline.boneIndex = boneIndex;

							int frameIndex = 0;
							foreach (Dictionary<String, Object> valueMap in values) {
								float time = (float)valueMap["time"];
								timeline.SetFrame(frameIndex, time, (float)valueMap["angle"]);
								ReadCurve(timeline, frameIndex, valueMap);
								frameIndex++;
							}
							timelines.Add(timeline);
							duration = Math.Max(duration, timeline.frames[timeline.FrameCount * 2 - 2]);

						} else if (timelineName.Equals(TIMELINE_TRANSLATE) || timelineName.Equals(TIMELINE_SCALE)) {
							TranslateTimeline timeline;
							float timelineScale = 1;
							if (timelineName.Equals(TIMELINE_SCALE))
								timeline = new ScaleTimeline(values.Count);
							else {
								timeline = new TranslateTimeline(values.Count);
								timelineScale = Scale;
							}
							timeline.boneIndex = boneIndex;

							int frameIndex = 0;
							foreach (Dictionary<String, Obje 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Spine.Skin类代码示例发布时间:2022-05-26
下一篇:
C# Spine.Skeleton类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap