protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);

            String name = "spineboy";             // "goblins";

            Atlas        atlas = new Atlas("data/" + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
            SkeletonJson json  = new SkeletonJson(atlas);

            skeleton = new Skeleton(json.ReadSkeletonData("data/" + name + ".json"));
            if (name == "goblins")
            {
                skeleton.SetSkin("goblingirl");
            }
            skeleton.SetSlotsToBindPose();             // Without this the skin attachments won't be attached. See SetSkin.

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            if (name == "spineboy")
            {
                stateData.SetMix("walk", "jump", 0.2f);
                stateData.SetMix("jump", "walk", 0.4f);
            }

            state = new AnimationState(stateData);
            state.SetAnimation("walk", false);
            state.AddAnimation("jump", false);
            state.AddAnimation("walk", true);

            skeleton.RootBone.X = 320;
            skeleton.RootBone.Y = 440;
            skeleton.UpdateWorldTransform();
        }
Ejemplo n.º 2
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonMeshRenderer(GraphicsDevice);
            skeletonRenderer.PremultipliedAlpha = true;

            // String name = "spineboy";
            String name = "goblins-ffd";

            Atlas        atlas = new Atlas(assetsFolder + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
            SkeletonJson json  = new SkeletonJson(atlas);

            if (name == "spineboy")
            {
                json.Scale = 0.6f;
            }
            skeleton = new Skeleton(json.ReadSkeletonData(assetsFolder + name + ".json"));
            if (name == "goblins-ffd")
            {
                skeleton.SetSkin("goblin");
            }

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            state = new AnimationState(stateData);

            if (name == "spineboy")
            {
                stateData.SetMix("run", "jump", 0.2f);
                stateData.SetMix("jump", "run", 0.4f);

                // Event handling for all animations.
                state.Start    += Start;
                state.End      += End;
                state.Complete += Complete;
                state.Event    += Event;

                state.SetAnimation(0, "test", false);
                TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
                entry.End += End;                 // Event handling for queued animations.
                state.AddAnimation(0, "run", true, 0);
            }
            else
            {
                state.SetAnimation(0, "walk", true);
            }

            skeleton.X = 400;
            skeleton.Y = 590;
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
Ejemplo n.º 3
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
            skeletonRenderer.PremultipliedAlpha = true;

            String name = "spineboy";             // "goblins";

            Atlas        atlas = new Atlas("data/" + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
            SkeletonJson json  = new SkeletonJson(atlas);

            skeleton = new Skeleton(json.ReadSkeletonData("data/" + name + ".json"));
            if (name == "goblins")
            {
                skeleton.SetSkin("goblingirl");
            }
            skeleton.SetSlotsToSetupPose();             // Without this the skin attachments won't be attached. See SetSkin.

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            if (name == "spineboy")
            {
                stateData.SetMix("walk", "jump", 0.2f);
                stateData.SetMix("jump", "walk", 0.4f);
            }

            state = new AnimationState(stateData);

            if (true)
            {
                // Event handling for all animations.
                state.Start    += Start;
                state.End      += End;
                state.Complete += Complete;
                state.Event    += Event;

                state.SetAnimation(0, "drawOrder", true);
            }
            else
            {
                state.SetAnimation(0, "walk", false);
                TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
                entry.End += End;                 // Event handling for queued animations.
                state.AddAnimation(0, "walk", true, 0);
            }

            skeleton.X = 320;
            skeleton.Y = 440;
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
    /*
     */
    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]);
        }
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Wendet alle zum Skeleton passenden AnimationMixes auf animationStateData an.
        /// </summary>
        public static void SetFadingSettings(AnimationStateData pAnimationStateData)
        {
            List<AnimationMix> AnimationFadingList;
            AnimationFadingList = AnimationFading[pAnimationStateData.SkeletonData.Name];

            foreach (AnimationMix animMix in AnimationFadingList)
            {
                pAnimationStateData.SetMix(animMix.From, animMix.To, animMix.Fading);
            }
        }
Ejemplo n.º 6
0
    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;
    }
Ejemplo n.º 7
0
	public SkeletonData GetSkeletonData (bool quiet) {
		if (spriteCollection == null) {
			if (!quiet)
				Debug.LogError("Sprite collection not set for skeleton data asset: " + name, this);
			Reset();
			return null;
		}
		
		if (skeletonJSON == null) {
			if (!quiet)
				Debug.LogError("Skeleton JSON file not set for skeleton data asset: " + name, this);
			Reset();
			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) {
			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;
	}
Ejemplo n.º 8
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonMeshRenderer(GraphicsDevice);
            skeletonRenderer.PremultipliedAlpha = true;

            // String name = "spineboy";
            // String name = "goblins-mesh";
            // String name = "raptor";
            String name = "tank";
            // String name = "star";
            bool binaryData = true;

            Atlas atlas = new Atlas(assetsFolder + name + ".atlas", new XnaTextureLoader(GraphicsDevice));

            float scale = 1;

            if (name == "spineboy")
            {
                scale = 0.6f;
            }
            if (name == "raptor")
            {
                scale = 0.5f;
            }
            if (name == "tank")
            {
                scale = 0.3f;
            }

            SkeletonData skeletonData;

            if (binaryData)
            {
                SkeletonBinary binary = new SkeletonBinary(atlas);
                binary.Scale = scale;
                skeletonData = binary.ReadSkeletonData(assetsFolder + name + ".skel");
            }
            else
            {
                SkeletonJson json = new SkeletonJson(atlas);
                json.Scale   = scale;
                skeletonData = json.ReadSkeletonData(assetsFolder + name + ".json");
            }
            skeleton = new Skeleton(skeletonData);
            if (name == "goblins-mesh")
            {
                skeleton.SetSkin("goblin");
            }

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            state = new AnimationState(stateData);

            if (name == "spineboy")
            {
                stateData.SetMix("run", "jump", 0.2f);
                stateData.SetMix("jump", "run", 0.4f);

                // Event handling for all animations.
                state.Start    += Start;
                state.End      += End;
                state.Complete += Complete;
                state.Event    += Event;

                state.SetAnimation(0, "test", false);
                TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
                entry.End += End;                 // Event handling for queued animations.
                state.AddAnimation(0, "run", true, 0);
            }
            else if (name == "raptor")
            {
                state.SetAnimation(0, "walk", true);
                state.AddAnimation(1, "gungrab", false, 2);
            }
            else if (name == "star")
            {
                // no animation in star
            }
            else if (name == "tank")
            {
                state.SetAnimation(0, "drive", true);
            }
            else
            {
                state.SetAnimation(0, "walk", true);
            }

            skeleton.X = 400 + (name == "tank" ? 300: 0);
            skeleton.Y = 580;
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
Ejemplo n.º 9
0
        protected override void LoadContent()
        {
            // Two color tint effect, comment line 80 to disable
            var spineEffect = Content.Load <Effect>("spine-xna-example-content\\SpineEffect");

            spineEffect.Parameters["World"].SetValue(Matrix.Identity);
            spineEffect.Parameters["View"].SetValue(Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 1.0f), Vector3.Zero, Vector3.Up));

            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
            skeletonRenderer.PremultipliedAlpha = false;
            skeletonRenderer.Effect             = spineEffect;

            skeletonDebugRenderer = new SkeletonDebugRenderer(GraphicsDevice);
            skeletonDebugRenderer.DisableAll();
            skeletonDebugRenderer.DrawClipping = true;

            // String name = "spineboy-ess";
            // String name = "goblins-pro";
            // String name = "raptor-pro";
            // String name = "tank-pro";
            String name      = "coin-pro";
            String atlasName = name.Replace("-pro", "").Replace("-ess", "");

            if (name == "goblins-pro")
            {
                atlasName = "goblins-mesh";
            }
            bool binaryData = false;

            Atlas atlas = new Atlas(assetsFolder + atlasName + ".atlas", new XnaTextureLoader(GraphicsDevice));

            float scale = 1;

            if (name == "spineboy-ess")
            {
                scale = 0.6f;
            }
            if (name == "raptor-pro")
            {
                scale = 0.5f;
            }
            if (name == "tank-pro")
            {
                scale = 0.3f;
            }
            if (name == "coin-pro")
            {
                scale = 1;
            }

            SkeletonData skeletonData;

            if (binaryData)
            {
                SkeletonBinary binary = new SkeletonBinary(atlas);
                binary.Scale = scale;
                skeletonData = binary.ReadSkeletonData(assetsFolder + name + ".skel");
            }
            else
            {
                SkeletonJson json = new SkeletonJson(atlas);
                json.Scale   = scale;
                skeletonData = json.ReadSkeletonData(assetsFolder + name + ".json");
            }
            skeleton = new Skeleton(skeletonData);
            if (name == "goblins-pro")
            {
                skeleton.SetSkin("goblin");
            }

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            state = new AnimationState(stateData);

            if (name == "spineboy-ess")
            {
                skeleton.SetAttachment("head-bb", "head");

                stateData.SetMix("run", "jump", 0.2f);
                stateData.SetMix("jump", "run", 0.4f);

                // Event handling for all animations.
                state.Start    += Start;
                state.End      += End;
                state.Complete += Complete;
                state.Event    += Event;

                state.SetAnimation(0, "run", true);
                TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
                entry.End += End;                 // Event handling for queued animations.
                state.AddAnimation(0, "run", true, 0);
            }
            else if (name == "raptor-pro")
            {
                state.SetAnimation(0, "walk", true);
                state.AddAnimation(1, "gun-grab", false, 2);
            }
            else if (name == "coin-pro")
            {
                state.SetAnimation(0, "animation", true);
            }
            else if (name == "tank-pro")
            {
                skeleton.X += 300;
                state.SetAnimation(0, "drive", true);
            }
            else
            {
                state.SetAnimation(0, "walk", true);
            }

            skeleton.X += 400;
            skeleton.Y += GraphicsDevice.Viewport.Height;
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
Ejemplo n.º 10
0
        protected override void LoadContent()
        {
            // Two color tint effect, comment line 76 to disable
            var spineEffect = Content.Load <Effect>("Content\\SpineEffect");

            spineEffect.Parameters["World"].SetValue(Matrix.Identity);
            spineEffect.Parameters["View"].SetValue(Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 1.0f), Vector3.Zero, Vector3.Up));

            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
            skeletonRenderer.PremultipliedAlpha = true;
            skeletonRenderer.Effect             = spineEffect;

            // String name = "spineboy";
            // String name = "goblins-mesh";
            // String name = "raptor";
            // String name = "tank";
            // String name = "coin";
            String name       = "TwoColorTest";
            bool   binaryData = true;

            Atlas atlas = new Atlas(assetsFolder + name + ".atlas", new XnaTextureLoader(GraphicsDevice));

            float scale = 1;

            if (name == "spineboy")
            {
                scale = 0.6f;
            }
            if (name == "raptor")
            {
                scale = 0.5f;
            }
            if (name == "tank")
            {
                scale = 0.3f;
            }
            if (name == "TwoColorTest")
            {
                scale = 0.5f;
            }

            SkeletonData skeletonData;

            if (binaryData)
            {
                SkeletonBinary binary = new SkeletonBinary(atlas);
                binary.Scale = scale;
                skeletonData = binary.ReadSkeletonData(assetsFolder + name + ".skel");
            }
            else
            {
                SkeletonJson json = new SkeletonJson(atlas);
                json.Scale   = scale;
                skeletonData = json.ReadSkeletonData(assetsFolder + name + ".json");
            }
            skeleton = new Skeleton(skeletonData);
            if (name == "goblins-mesh")
            {
                skeleton.SetSkin("goblin");
            }

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            state = new AnimationState(stateData);

            if (name == "spineboy")
            {
                stateData.SetMix("run", "jump", 0.2f);
                stateData.SetMix("jump", "run", 0.4f);

                // Event handling for all animations.
                state.Start    += Start;
                state.End      += End;
                state.Complete += Complete;
                state.Event    += Event;

                state.SetAnimation(0, "test", false);
                TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
                entry.End += End;                 // Event handling for queued animations.
                state.AddAnimation(0, "run", true, 0);
            }
            else if (name == "raptor")
            {
                state.SetAnimation(0, "walk", true);
                state.AddAnimation(1, "gungrab", false, 2);
            }
            else if (name == "coin")
            {
                state.SetAnimation(0, "rotate", true);
            }
            else if (name == "tank")
            {
                state.SetAnimation(0, "drive", true);
            }
            else if (name == "TwoColorTest")
            {
                state.SetAnimation(0, "animation", true);
            }
            else
            {
                state.SetAnimation(0, "walk", true);
            }

            skeleton.X = 400 + (name == "tank" ? 300: 0);
            skeleton.Y = 580 + (name == "TwoColorTest" ? -300 : 0);
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
Ejemplo n.º 11
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);

            String name = "spineboy"; // "goblins";

            Atlas atlas = new Atlas("data/" + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
            SkeletonJson json = new SkeletonJson(atlas);
            skeleton = new Skeleton(json.ReadSkeletonData("data/" + name + ".json"));
            if (name == "goblins") skeleton.SetSkin("goblingirl");
            skeleton.SetSlotsToSetupPose(); // Without this the skin attachments won't be attached. See SetSkin.

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);
            if (name == "spineboy") {
                stateData.SetMix("walk", "jump", 0.2f);
                stateData.SetMix("jump", "walk", 0.4f);
            }

            state = new AnimationState(stateData);

            if (true) {
                // Event handling for all animations.
                state.Start += new EventHandler(Start);
                state.End += new EventHandler(End);
                state.Complete += new EventHandler<CompleteArgs>(Complete);
                state.Event += new EventHandler<EventTriggeredArgs>(Event);

                state.SetAnimation("drawOrder", true);
            } else {
                state.SetAnimation("walk", false);
                QueueEntry entry = state.AddAnimation("jump", false);
                entry.End += new EventHandler(End); // Event handling for queued animations.
                state.AddAnimation("walk", true);
            }

            skeleton.X = 320;
            skeleton.Y = 440;
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
Ejemplo n.º 12
0
    public void SetSkeletonData(SkeletonData data)
    {
        this.skeletonData = data;

        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]);
        }

    }
Ejemplo n.º 13
0
        protected override void LoadContent()
        {
            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);

            String name = "spineboy"; // "goblins";

            Atlas atlas = new Atlas("data/" + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
            SkeletonJson json = new SkeletonJson(atlas);
            skeleton = new Skeleton(json.ReadSkeletonData("data/" + name + ".json"));
            if (name == "goblins") skeleton.SetSkin("goblingirl");
            skeleton.SetSlotsToBindPose(); // Without this the skin attachments won't be attached. See SetSkin.

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);
            if (name == "spineboy") {
                stateData.SetMix("walk", "jump", 0.2f);
                stateData.SetMix("jump", "walk", 0.4f);
            }

            state = new AnimationState(stateData);
            state.SetAnimation("walk", false);
            state.AddAnimation("jump", false);
            state.AddAnimation("walk", true);

            skeleton.RootBone.X = 320;
            skeleton.RootBone.Y = 440;
            skeleton.UpdateWorldTransform();
        }
Ejemplo n.º 14
0
		protected override void LoadContent () {
			skeletonRenderer = new SkeletonMeshRenderer(GraphicsDevice);
			skeletonRenderer.PremultipliedAlpha = true;

			// String name = "spineboy";
			// String name = "goblins-mesh";
			String name = "raptor";
			bool binaryData = true;

			Atlas atlas = new Atlas(assetsFolder + name + ".atlas", new XnaTextureLoader(GraphicsDevice));

			float scale = 1;
			if (name == "spineboy") scale = 0.6f;
			if (name == "raptor") scale = 0.5f;

			SkeletonData skeletonData;
			if (binaryData) {
				SkeletonBinary binary = new SkeletonBinary(atlas);
				binary.Scale = scale;
				skeletonData = binary.ReadSkeletonData(assetsFolder + name + ".skel");
			} else {
				SkeletonJson json = new SkeletonJson(atlas);
				json.Scale = scale;
				skeletonData = json.ReadSkeletonData(assetsFolder + name + ".json");
			}
			skeleton = new Skeleton(skeletonData);
			if (name == "goblins-mesh") skeleton.SetSkin("goblin");

			// Define mixing between animations.
			AnimationStateData stateData = new AnimationStateData(skeleton.Data);
			state = new AnimationState(stateData);

			if (name == "spineboy") {
				stateData.SetMix("run", "jump", 0.2f);
				stateData.SetMix("jump", "run", 0.4f);

				// Event handling for all animations.
				state.Start += Start;
				state.End += End;
				state.Complete += Complete;
				state.Event += Event;

				state.SetAnimation(0, "test", false);
				TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
				entry.End += End; // Event handling for queued animations.
				state.AddAnimation(0, "run", true, 0);
			} else if (name == "raptor") {
				state.SetAnimation(0, "walk", true);
				state.SetAnimation(1, "empty", false);
				state.AddAnimation(1, "gungrab", false, 2);
			} else {
				state.SetAnimation(0, "walk", true);
			}

			skeleton.X = 400;
			skeleton.Y = 590;
			skeleton.UpdateWorldTransform();

			headSlot = skeleton.FindSlot("head");
		}
Ejemplo n.º 15
0
        AnimationStateTests(string testJsonFilePath)
        {
            skeletonData = json.ReadSkeletonData(testJsonFilePath);

            TrackEntry entry;

            Setup("0.1 time step",                   // 1
                  Expect(0, "start", 0, 0),          //
                  Expect(0, "event 0", 0, 0),        //
                  Expect(0, "event 14", 0.5f, 0.5f), //
                  Expect(0, "event 30", 1, 1),       //
                  Expect(0, "complete", 1, 1),       //
                  Expect(0, "end", 1, 1.1f),         //
                  Expect(0, "dispose", 1, 1.1f)      //
                  );
            state.SetAnimation(0, "events0", false).TrackEnd = 1;
            Run(0.1f, 1000, null);

            Setup("1/60 time step, dispose queued",     // 2
                  Expect(0, "start", 0, 0),             //
                  Expect(0, "interrupt", 0, 0),         //
                  Expect(0, "end", 0, 0),               //
                  Expect(0, "dispose", 0, 0),           //
                  Expect(1, "dispose", 0, 0),           //
                  Expect(0, "dispose", 0, 0),           //
                  Expect(1, "dispose", 0, 0),           //

                  Note("First 2 set/addAnimation calls are done."),

                  Expect(0, "start", 0, 0),               //
                  Expect(0, "event 0", 0, 0),             //
                  Expect(0, "event 14", 0.483f, 0.483f),  //
                  Expect(0, "event 30", 1, 1),            //
                  Expect(0, "complete", 1, 1),            //
                  Expect(0, "end", 1, 1.017f),            //
                  Expect(0, "dispose", 1, 1.017f)         //
                  );
            state.SetAnimation(0, "events0", false);
            state.AddAnimation(0, "events1", false, 0);
            state.AddAnimation(0, "events0", false, 0);
            state.AddAnimation(0, "events1", false, 0);
            state.SetAnimation(0, "events0", false).TrackEnd = 1;
            Run(1 / 60f, 1000, null);

            Setup("30 time step",                // 3
                  Expect(0, "start", 0, 0),      //
                  Expect(0, "event 0", 0, 0),    //
                  Expect(0, "event 14", 30, 30), //
                  Expect(0, "event 30", 30, 30), //
                  Expect(0, "complete", 30, 30), //
                  Expect(0, "end", 30, 60),      //
                  Expect(0, "dispose", 30, 60)   //
                  );
            state.SetAnimation(0, "events0", false).TrackEnd = 1;
            Run(30, 1000, null);

            Setup("1 time step",               // 4
                  Expect(0, "start", 0, 0),    //
                  Expect(0, "event 0", 0, 0),  //
                  Expect(0, "event 14", 1, 1), //
                  Expect(0, "event 30", 1, 1), //
                  Expect(0, "complete", 1, 1), //
                  Expect(0, "end", 1, 2),      //
                  Expect(0, "dispose", 1, 2)   //
                  );
            state.SetAnimation(0, "events0", false).TrackEnd = 1;
            Run(1, 1.01f, null);

            Setup("interrupt",                        // 5
                  Expect(0, "start", 0, 0),           //
                  Expect(0, "event 0", 0, 0),         //
                  Expect(0, "event 14", 0.5f, 0.5f),  //
                  Expect(0, "event 30", 1, 1),        //
                  Expect(0, "complete", 1, 1),        //
                  Expect(0, "interrupt", 1.1f, 1.1f), //

                  Expect(1, "start", 0.1f, 1.1f),     //
                  Expect(1, "event 0", 0.1f, 1.1f),   //

                  Expect(0, "end", 1.1f, 1.2f),       //
                  Expect(0, "dispose", 1.1f, 1.2f),   //

                  Expect(1, "event 14", 0.5f, 1.5f),  //
                  Expect(1, "event 30", 1, 2),        //
                  Expect(1, "complete", 1, 2),        //
                  Expect(1, "interrupt", 1.1f, 2.1f), //

                  Expect(0, "start", 0.1f, 2.1f),     //
                  Expect(0, "event 0", 0.1f, 2.1f),   //

                  Expect(1, "end", 1.1f, 2.2f),       //
                  Expect(1, "dispose", 1.1f, 2.2f),   //

                  Expect(0, "event 14", 0.5f, 2.5f),  //
                  Expect(0, "event 30", 1, 3),        //
                  Expect(0, "complete", 1, 3),        //
                  Expect(0, "end", 1, 3.1f),          //
                  Expect(0, "dispose", 1, 3.1f)       //
                  );
            state.SetAnimation(0, "events0", false);
            state.AddAnimation(0, "events1", false, 0);
            state.AddAnimation(0, "events0", false, 0).TrackEnd = 1;
            Run(0.1f, 4f, null);

            Setup("interrupt with delay",             // 6
                  Expect(0, "start", 0, 0),           //
                  Expect(0, "event 0", 0, 0),         //
                  Expect(0, "event 14", 0.5f, 0.5f),  //
                  Expect(0, "interrupt", 0.6f, 0.6f), //

                  Expect(1, "start", 0.1f, 0.6f),     //
                  Expect(1, "event 0", 0.1f, 0.6f),   //

                  Expect(0, "end", 0.6f, 0.7f),       //
                  Expect(0, "dispose", 0.6f, 0.7f),   //

                  Expect(1, "event 14", 0.5f, 1.0f),  //
                  Expect(1, "event 30", 1, 1.5f),     //
                  Expect(1, "complete", 1, 1.5f),     //
                  Expect(1, "end", 1, 1.6f),          //
                  Expect(1, "dispose", 1, 1.6f)       //
                  );
            state.SetAnimation(0, "events0", false);
            state.AddAnimation(0, "events1", false, 0.5f).TrackEnd = 1;
            Run(0.1f, 1000, null);

            Setup("interrupt with delay and mix time",  // 7
                  Expect(0, "start", 0, 0),             //
                  Expect(0, "event 0", 0, 0),           //
                  Expect(0, "event 14", 0.5f, 0.5f),    //
                  Expect(0, "interrupt", 1, 1),         //

                  Expect(1, "start", 0.1f, 1),          //

                  Expect(0, "complete", 1, 1),          //

                  Expect(1, "event 0", 0.1f, 1),        //
                  Expect(1, "event 14", 0.5f, 1.4f),    //

                  Expect(0, "end", 1.6f, 1.7f),         //
                  Expect(0, "dispose", 1.6f, 1.7f),     //

                  Expect(1, "event 30", 1, 1.9f),       //
                  Expect(1, "complete", 1, 1.9f),       //
                  Expect(1, "end", 1, 2),               //
                  Expect(1, "dispose", 1, 2)            //
                  );
            stateData.SetMix("events0", "events1", 0.7f);
            state.SetAnimation(0, "events0", true);
            state.AddAnimation(0, "events1", false, 0.9f).TrackEnd = 1;
            Run(0.1f, 1000, null);

            Setup("animation 0 events do not fire during mix", // 8
                  Expect(0, "start", 0, 0),                    //
                  Expect(0, "event 0", 0, 0),                  //
                  Expect(0, "interrupt", 0.5f, 0.5f),          //

                  Expect(1, "start", 0.1f, 0.5f),              //
                  Expect(1, "event 0", 0.1f, 0.5f),            //
                  Expect(1, "event 14", 0.5f, 0.9f),           //

                  Expect(0, "complete", 1, 1),                 //
                  Expect(0, "end", 1.1f, 1.2f),                //
                  Expect(0, "dispose", 1.1f, 1.2f),            //

                  Expect(1, "event 30", 1, 1.4f),              //
                  Expect(1, "complete", 1, 1.4f),              //
                  Expect(1, "end", 1, 1.5f),                   //
                  Expect(1, "dispose", 1, 1.5f)                //
                  );
            stateData.DefaultMix = 0.7f;
            state.SetAnimation(0, "events0", false);
            state.AddAnimation(0, "events1", false, 0.4f).TrackEnd = 1;
            Run(0.1f, 1000, null);

            Setup("event threshold, some animation 0 events fire during mix", // 9
                  Expect(0, "start", 0, 0),                                   //
                  Expect(0, "event 0", 0, 0),                                 //
                  Expect(0, "interrupt", 0.5f, 0.5f),                         //

                  Expect(1, "start", 0.1f, 0.5f),                             //

                  Expect(0, "event 14", 0.5f, 0.5f),                          //

                  Expect(1, "event 0", 0.1f, 0.5f),                           //
                  Expect(1, "event 14", 0.5f, 0.9f),                          //

                  Expect(0, "complete", 1, 1),                                //
                  Expect(0, "end", 1.1f, 1.2f),                               //
                  Expect(0, "dispose", 1.1f, 1.2f),                           //

                  Expect(1, "event 30", 1, 1.4f),                             //
                  Expect(1, "complete", 1, 1.4f),                             //
                  Expect(1, "end", 1, 1.5f),                                  //
                  Expect(1, "dispose", 1, 1.5f)                               //
                  );
            stateData.SetMix("events0", "events1", 0.7f);
            state.SetAnimation(0, "events0", false).EventThreshold = 0.5f;
            state.AddAnimation(0, "events1", false, 0.4f).TrackEnd = 1;
            Run(0.1f, 1000, null);

            Setup("event threshold, all animation 0 events fire during mix", // 10
                  Expect(0, "start", 0, 0),                                  //
                  Expect(0, "event 0", 0, 0),                                //
                  Expect(0, "event 14", 0.5f, 0.5f),                         //
                  Expect(0, "interrupt", 0.9f, 0.9f),                        //

                  Expect(1, "start", 0.1f, 0.9f),                            //
                  Expect(1, "event 0", 0.1f, 0.9f),                          //

                  Expect(0, "event 30", 1, 1),                               //
                  Expect(0, "complete", 1, 1),                               //
                  Expect(0, "event 0", 1, 1),                                //

                  Expect(1, "event 14", 0.5f, 1.3f),                         //

                  Expect(0, "end", 1.5f, 1.6f),                              //
                  Expect(0, "dispose", 1.5f, 1.6f),                          //

                  Expect(1, "event 30", 1, 1.8f),                            //
                  Expect(1, "complete", 1, 1.8f),                            //
                  Expect(1, "end", 1, 1.9f),                                 //
                  Expect(1, "dispose", 1, 1.9f)                              //
                  );
            state.SetAnimation(0, "events0", true).EventThreshold = 1;
            entry             = state.AddAnimation(0, "events1", false, 0.8f);
            entry.MixDuration = 0.7f;
            entry.TrackEnd    = 1;
            Run(0.1f, 1000, null);

            Setup("looping",                         // 11
                  Expect(0, "start", 0, 0),          //
                  Expect(0, "event 0", 0, 0),        //
                  Expect(0, "event 14", 0.5f, 0.5f), //
                  Expect(0, "event 30", 1, 1),       //
                  Expect(0, "complete", 1, 1),       //
                  Expect(0, "event 0", 1, 1),        //
                  Expect(0, "event 14", 1.5f, 1.5f), //
                  Expect(0, "event 30", 2, 2),       //
                  Expect(0, "complete", 2, 2),       //
                  Expect(0, "event 0", 2, 2),        //
                  Expect(0, "event 14", 2.5f, 2.5f), //
                  Expect(0, "event 30", 3, 3),       //
                  Expect(0, "complete", 3, 3),       //
                  Expect(0, "event 0", 3, 3),        //
                  Expect(0, "event 14", 3.5f, 3.5f), //
                  Expect(0, "event 30", 4, 4),       //
                  Expect(0, "complete", 4, 4),       //
                  Expect(0, "event 0", 4, 4),        //
                  Expect(0, "end", 4.1f, 4.1f),      //
                  Expect(0, "dispose", 4.1f, 4.1f)   //
                  );
            state.SetAnimation(0, "events0", true);
            Run(0.1f, 4, null);

            Setup("not looping, track end past animation 0 duration", // 12
                  Expect(0, "start", 0, 0),                           //
                  Expect(0, "event 0", 0, 0),                         //
                  Expect(0, "event 14", 0.5f, 0.5f),                  //
                  Expect(0, "event 30", 1, 1),                        //
                  Expect(0, "complete", 1, 1),                        //
                  Expect(0, "interrupt", 2.1f, 2.1f),                 //

                  Expect(1, "start", 0.1f, 2.1f),                     //
                  Expect(1, "event 0", 0.1f, 2.1f),                   //

                  Expect(0, "end", 2.1f, 2.2f),                       //
                  Expect(0, "dispose", 2.1f, 2.2f),                   //

                  Expect(1, "event 14", 0.5f, 2.5f),                  //
                  Expect(1, "event 30", 1, 3),                        //
                  Expect(1, "complete", 1, 3),                        //
                  Expect(1, "end", 1, 3.1f),                          //
                  Expect(1, "dispose", 1, 3.1f)                       //
                  );
            state.SetAnimation(0, "events0", false);
            state.AddAnimation(0, "events1", false, 2).TrackEnd = 1;
            Run(0.1f, 4f, null);


            Setup("interrupt animation after first loop complete", // 13
                  Expect(0, "start", 0, 0),                        //
                  Expect(0, "event 0", 0, 0),                      //
                  Expect(0, "event 14", 0.5f, 0.5f),               //
                  Expect(0, "event 30", 1, 1),                     //
                  Expect(0, "complete", 1, 1),                     //
                  Expect(0, "event 0", 1, 1),                      //
                  Expect(0, "event 14", 1.5f, 1.5f),               //
                  Expect(0, "event 30", 2, 2),                     //
                  Expect(0, "complete", 2, 2),                     //
                  Expect(0, "event 0", 2, 2),                      //
                  Expect(0, "interrupt", 2.1f, 2.1f),              //

                  Expect(1, "start", 0.1f, 2.1f),                  //
                  Expect(1, "event 0", 0.1f, 2.1f),                //

                  Expect(0, "end", 2.1f, 2.2f),                    //
                  Expect(0, "dispose", 2.1f, 2.2f),                //

                  Expect(1, "event 14", 0.5f, 2.5f),               //
                  Expect(1, "event 30", 1, 3),                     //
                  Expect(1, "complete", 1, 3),                     //
                  Expect(1, "end", 1, 3.1f),                       //
                  Expect(1, "dispose", 1, 3.1f)                    //
                  );
            state.SetAnimation(0, "events0", true);
            Run(0.1f, 6, new TestListener(
                    (time) => {
                if (IsEqual(time, 1.4f))
                {
                    state.AddAnimation(0, "events1", false, 0).TrackEnd = 1;
                }
            }));

            Setup("add animation on empty track",         // 14
                  Expect(0, "start", 0, 0),               //
                  Expect(0, "event 0", 0, 0),             //
                  Expect(0, "event 14", 0.5f, 0.5f),      //
                  Expect(0, "event 30", 1, 1),            //
                  Expect(0, "complete", 1, 1),            //
                  Expect(0, "end", 1, 1.1f),              //
                  Expect(0, "dispose", 1, 1.1f)           //
                  );
            state.AddAnimation(0, "events0", false, 0).TrackEnd = 1;
            Run(0.1f, 1.9f, null);

            Setup("end time beyond non-looping animation duration", // 15
                  Expect(0, "start", 0, 0),                         //
                  Expect(0, "event 0", 0, 0),                       //
                  Expect(0, "event 14", 0.5f, 0.5f),                //
                  Expect(0, "event 30", 1, 1),                      //
                  Expect(0, "complete", 1, 1),                      //
                  Expect(0, "end", 9f, 9.1f),                       //
                  Expect(0, "dispose", 9f, 9.1f)                    //
                  );
            state.SetAnimation(0, "events0", false).TrackEnd = 9;
            Run(0.1f, 10, null);

            Setup("looping with animation start",         // 16
                  Expect(0, "start", 0, 0),               //
                  Expect(0, "event 30", 0.4f, 0.4f),      //
                  Expect(0, "complete", 0.4f, 0.4f),      //
                  Expect(0, "event 30", 0.8f, 0.8f),      //
                  Expect(0, "complete", 0.8f, 0.8f),      //
                  Expect(0, "event 30", 1.2f, 1.2f),      //
                  Expect(0, "complete", 1.2f, 1.2f),      //
                  Expect(0, "end", 1.4f, 1.4f),           //
                  Expect(0, "dispose", 1.4f, 1.4f)        //
                  );
            entry = state.SetAnimation(0, "events0", true);
            entry.AnimationLast  = 0.6f;
            entry.AnimationStart = 0.6f;
            Run(0.1f, 1.4f, null);

            Setup("looping with animation start and end", // 17
                  Expect(0, "start", 0, 0),               //
                  Expect(0, "event 14", 0.3f, 0.3f),      //
                  Expect(0, "complete", 0.6f, 0.6f),      //
                  Expect(0, "event 14", 0.9f, 0.9f),      //
                  Expect(0, "complete", 1.2f, 1.2f),      //
                  Expect(0, "event 14", 1.5f, 1.5f),      //
                  Expect(0, "end", 1.8f, 1.8f),           //
                  Expect(0, "dispose", 1.8f, 1.8f)        //
                  );
            entry = state.SetAnimation(0, "events0", true);
            entry.AnimationStart = 0.2f;
            entry.AnimationLast  = 0.2f;
            entry.AnimationEnd   = 0.8f;
            Run(0.1f, 1.8f, null);

            Setup("non-looping with animation start and end", // 18
                  Expect(0, "start", 0, 0),                   //
                  Expect(0, "event 14", 0.3f, 0.3f),          //
                  Expect(0, "complete", 0.6f, 0.6f),          //
                  Expect(0, "end", 1, 1.1f),                  //
                  Expect(0, "dispose", 1, 1.1f)               //
                  );
            entry = state.SetAnimation(0, "events0", false);
            entry.AnimationStart = 0.2f;
            entry.AnimationLast  = 0.2f;
            entry.AnimationEnd   = 0.8f;
            entry.TrackEnd       = 1;
            Run(0.1f, 1.8f, null);

            Setup("mix out looping with animation start and end", // 19
                  Expect(0, "start", 0, 0),                       //
                  Expect(0, "event 14", 0.3f, 0.3f),              //
                  Expect(0, "complete", 0.6f, 0.6f),              //
                  Expect(0, "interrupt", 0.8f, 0.8f),             //

                  Expect(1, "start", 0.1f, 0.8f),                 //
                  Expect(1, "event 0", 0.1f, 0.8f),               //

                  Expect(0, "event 14", 0.9f, 0.9f),              //
                  Expect(0, "complete", 1.2f, 1.2f),              //

                  Expect(1, "event 14", 0.5f, 1.2f),              //

                  Expect(0, "end", 1.4f, 1.5f),                   //
                  Expect(0, "dispose", 1.4f, 1.5f),               //

                  Expect(1, "event 30", 1, 1.7f),                 //
                  Expect(1, "complete", 1, 1.7f),                 //
                  Expect(1, "end", 1, 1.8f),                      //
                  Expect(1, "dispose", 1, 1.8f)                   //
                  );
            entry = state.SetAnimation(0, "events0", true);
            entry.AnimationStart = (0.2f);
            entry.AnimationLast  = (0.2f);
            entry.AnimationEnd   = (0.8f);
            entry.EventThreshold = 1;
            entry             = state.AddAnimation(0, "events1", false, 0.7f);
            entry.MixDuration = (0.7f);
            entry.TrackEnd    = 1;
            Run(0.1f, 20, null);

            Setup("setAnimation with track entry mix",    // 20
                  Expect(0, "start", 0, 0),               //
                  Expect(0, "event 0", 0, 0),             //
                  Expect(0, "event 14", 0.5f, 0.5f),      //
                  Expect(0, "event 30", 1, 1),            //
                  Expect(0, "complete", 1, 1),            //
                  Expect(0, "event 0", 1, 1),             //
                  Expect(0, "interrupt", 1, 1),           //

                  Expect(1, "start", 0, 1),               //

                  Expect(1, "event 0", 0.1f, 1.1f),       //
                  Expect(1, "event 14", 0.5f, 1.5f),      //

                  Expect(0, "end", 1.7f, 1.8f),           //
                  Expect(0, "dispose", 1.7f, 1.8f),       //

                  Expect(1, "event 30", 1, 2),            //
                  Expect(1, "complete", 1, 2),            //
                  Expect(1, "end", 1, 2.1f),              //
                  Expect(1, "dispose", 1, 2.1f)           //
                  );
            state.SetAnimation(0, "events0", true);
            Run(0.1f, 1000, new TestListener(
                    (time) => {
                if (IsEqual(time, 1f))
                {
                    TrackEntry ent  = state.SetAnimation(0, "events1", false);
                    ent.MixDuration = (0.7f);
                    ent.TrackEnd    = 1;
                }
            }));

            Setup("setAnimation twice",              // 21
                  Expect(0, "start", 0, 0),          //
                  Expect(0, "interrupt", 0, 0),      //
                  Expect(0, "end", 0, 0),            //
                  Expect(0, "dispose", 0, 0),        //

                  Expect(1, "start", 0, 0),          //
                  Expect(1, "event 0", 0, 0),        //
                  Expect(1, "event 14", 0.5f, 0.5f), //

                  Note("First 2 setAnimation calls are done."),

                  Expect(1, "interrupt", 0.8f, 0.8f),      //

                  Expect(0, "start", 0, 0.8f),             //
                  Expect(0, "interrupt", 0, 0.8f),         //
                  Expect(0, "end", 0, 0.8f),               //
                  Expect(0, "dispose", 0, 0.8f),           //

                  Expect(2, "start", 0, 0.8f),             //
                  Expect(2, "event 0", 0.1f, 0.9f),        //

                  Expect(1, "end", 0.9f, 1),               //
                  Expect(1, "dispose", 0.9f, 1),           //

                  Expect(2, "event 14", 0.5f, 1.3f),       //
                  Expect(2, "event 30", 1, 1.8f),          //
                  Expect(2, "complete", 1, 1.8f),          //
                  Expect(2, "end", 1, 1.9f),               //
                  Expect(2, "dispose", 1, 1.9f)            //
                  );
            state.SetAnimation(0, "events0", false);       // First should be ignored.
            state.SetAnimation(0, "events1", false);
            Run(0.1f, 1000, new TestListener(
                    (time) => {
                if (IsEqual(time, 0.8f))
                {
                    state.SetAnimation(0, "events0", false);                             // First should be ignored.
                    state.SetAnimation(0, "events2", false).TrackEnd = 1;
                }
            }));

            Setup("setAnimation twice with multiple mixing", // 22
                  Expect(0, "start", 0, 0),                  //
                  Expect(0, "interrupt", 0, 0),              //
                  Expect(0, "end", 0, 0),                    //
                  Expect(0, "dispose", 0, 0),                //

                  Expect(1, "start", 0, 0),                  //
                  Expect(1, "event 0", 0, 0),                //

                  Note("First 2 setAnimation calls are done."),

                  Expect(1, "interrupt", 0.2f, 0.2f),      //

                  Expect(0, "start", 0, 0.2f),             //
                  Expect(0, "interrupt", 0, 0.2f),         //
                  Expect(0, "end", 0, 0.2f),               //
                  Expect(0, "dispose", 0, 0.2f),           //

                  Expect(2, "start", 0, 0.2f),             //
                  Expect(2, "event 0", 0.1f, 0.3f),        //

                  Note("Second 2 setAnimation calls are done."),

                  Expect(2, "interrupt", 0.2f, 0.4f),      //

                  Expect(1, "start", 0, 0.4f),             //
                  Expect(1, "interrupt", 0, 0.4f),         //
                  Expect(1, "end", 0, 0.4f),               //
                  Expect(1, "dispose", 0, 0.4f),           //

                  Expect(0, "start", 0, 0.4f),             //
                  Expect(0, "event 0", 0.1f, 0.5f),        //

                  Expect(1, "end", 0.8f, 0.9f),            //
                  Expect(1, "dispose", 0.8f, 0.9f),        //

                  Expect(0, "event 14", 0.5f, 0.9f),       //

                  Expect(2, "end", 0.8f, 1.1f),            //
                  Expect(2, "dispose", 0.8f, 1.1f),        //

                  Expect(0, "event 30", 1, 1.4f),          //
                  Expect(0, "complete", 1, 1.4f),          //
                  Expect(0, "end", 1, 1.5f),               //
                  Expect(0, "dispose", 1, 1.5f)            //
                  );
            stateData.DefaultMix = 0.6f;
            state.SetAnimation(0, "events0", false);             // First should be ignored.
            state.SetAnimation(0, "events1", false);
            Run(0.1f, 1000, new TestListener(
                    (time) => {
                if (IsEqual(time, 0.2f))
                {
                    state.SetAnimation(0, "events0", false);                             // First should be ignored.
                    state.SetAnimation(0, "events2", false);
                }
                if (IsEqual(time, 0.4f))
                {
                    state.SetAnimation(0, "events1", false);                             // First should be ignored.
                    state.SetAnimation(0, "events0", false).TrackEnd = 1;
                }
            }));

            Setup("addAnimation with delay on empty track", // 23
                  Expect(0, "start", 0, 0),                 //
                  Expect(0, "event 0", 0, 5),               //
                  Expect(0, "event 14", 0.5f, 5.5f),        //
                  Expect(0, "event 30", 1, 6),              //
                  Expect(0, "complete", 1, 6),              //
                  Expect(0, "end", 1, 6.1f),                //
                  Expect(0, "dispose", 1, 6.1f)             //
                  );
            state.AddAnimation(0, "events0", false, 5).TrackEnd = 1;
            Run(0.1f, 10, null);

            Setup("setAnimation during AnimationStateListener");             // 24
            state.Start += (trackEntry) => {
                if (trackEntry.Animation.Name.Equals("events0"))
                {
                    state.SetAnimation(1, "events1", false);
                }
            };
            state.Interrupt += (trackEntry) => {
                state.AddAnimation(3, "events1", false, 0);
            };
            state.End += (trackEntry) => {
                if (trackEntry.Animation.Name.Equals("events0"))
                {
                    state.SetAnimation(0, "events1", false);
                }
            };
            state.Dispose += (trackEntry) => {
                if (trackEntry.Animation.Name.Equals("events0"))
                {
                    state.SetAnimation(1, "events1", false);
                }
            };
            state.Complete += (trackEntry) => {
                if (trackEntry.Animation.Name.Equals("events0"))
                {
                    state.SetAnimation(1, "events1", false);
                }
            };
            state.Event += (trackEntry, ev) => {
                if (trackEntry.TrackIndex != 2)
                {
                    state.SetAnimation(2, "events1", false);
                }
            };
            state.AddAnimation(0, "events0", false, 0);
            state.AddAnimation(0, "events1", false, 0);
            state.SetAnimation(1, "events1", false).TrackEnd = 1;
            Run(0.1f, 10, null);

            Setup("clearTrack",                      // 25
                  Expect(0, "start", 0, 0),          //
                  Expect(0, "event 0", 0, 0),        //
                  Expect(0, "event 14", 0.5f, 0.5f), //
                  Expect(0, "end", 0.7f, 0.7f),      //
                  Expect(0, "dispose", 0.7f, 0.7f)   //
                  );
            state.AddAnimation(0, "events0", false, 0).TrackEnd = 1;
            Run(0.1f, 10, new TestListener(
                    (time) => {
                if (IsEqual(time, 0.7f))
                {
                    state.ClearTrack(0);
                }
            }));

            Setup("setEmptyAnimation",                // 26
                  Expect(0, "start", 0, 0),           //
                  Expect(0, "event 0", 0, 0),         //
                  Expect(0, "event 14", 0.5f, 0.5f),  //
                  Expect(0, "interrupt", 0.7f, 0.7f), //

                  Expect(-1, "start", 0, 0.7f),       //
                  Expect(-1, "complete", 0.1f, 0.8f), //

                  Expect(0, "end", 0.8f, 0.9f),       //
                  Expect(0, "dispose", 0.8f, 0.9f),   //

                  Expect(-1, "end", 0.2f, 1),         //
                  Expect(-1, "dispose", 0.2f, 1)      //
                  );
            state.AddAnimation(0, "events0", false, 0).TrackEnd = 1;
            Run(0.1f, 10, new TestListener(
                    (time) => {
                if (IsEqual(time, 0.7f))
                {
                    state.SetEmptyAnimation(0, 0);
                }
            }));

            Setup("TrackEntry listener");             // 27
            int counter = 0;

            entry        = state.AddAnimation(0, "events0", false, 0);
            entry.Start += (trackEntry) => {
                Interlocked.Add(ref counter, 1 << 1);
            };
            entry.Interrupt += (trackEntry) => {
                Interlocked.Add(ref counter, 1 << 5);
            };
            entry.End += (trackEntry) => {
                Interlocked.Add(ref counter, 1 << 9);
            };
            entry.Dispose += (trackEntry) => {
                Interlocked.Add(ref counter, 1 << 13);
            };
            entry.Complete += (trackEntry) => {
                Interlocked.Add(ref counter, 1 << 17);
            };
            entry.Event += (trackEntry, ev) => {
                Interlocked.Add(ref counter, 1 << 21);
            };
            state.AddAnimation(0, "events0", false, 0);
            state.AddAnimation(0, "events1", false, 0);
            state.SetAnimation(1, "events1", false).TrackEnd = 1;
            Run(0.1f, 10, null);
            if (counter != 15082016)
            {
                string message = "TEST 27 FAILED! " + counter;
                Log(message);
                FailTestRun(message);
            }

#if RUN_ADDITIONAL_FORUM_RELATED_TEST
            Setup("0.1 time step, start and add",         // 2
                  Expect(0, "start", 0, 0),               //
                  Expect(0, "event 0", 0, 0),             //
                  Expect(0, "event 14", 0.5f, 0.5f),      //
                  Expect(0, "event 30", 1, 1),            //
                  Expect(0, "complete", 1, 1),            //
                  Expect(0, "interrupt", 1.1f, 1.1f),     //
                  Expect(1, "start", 0.1f, 1.1f),         //
                  Expect(1, "event 0", 0.1f, 1.1f),       //
                  Expect(0, "end", 1.3f, 1.4f),           //
                  Expect(0, "dispose", 1.3f, 1.4f),       //
                  Expect(1, "event 14", 0.5f, 1.5f),      //
                  Expect(1, "event 30", 1, 2),            //
                  Expect(1, "complete", 1, 2),            //
                  Expect(1, "end", 1, 2.1f),              //
                  Expect(1, "dispose", 1, 2.1f)           //
                  );
            state.SetAnimation(0, "events0", false);
            var entry1 = state.AddAnimation(0, "events1", false, 0);
            entry1.MixDuration = 0.25f;
            entry1.TrackEnd    = 1.0f;
            Run(0.1f, 1000, null);
#endif // RUN_ADDITIONAL_FORUM_RELATED_TEST

            Log("AnimationState tests passed.");
        }
Ejemplo n.º 16
0
        protected override void LoadContent()
        {
            bool   useNormalmapShader = false;
            Effect spineEffect;

            if (!useNormalmapShader)
            {
                // Two color tint effect. Note that you can also use the default BasicEffect instead.
                spineEffect = Content.Load <Effect>("spine-xna-example-content\\SpineEffect");
            }
            else
            {
                spineEffect = Content.Load <Effect>("spine-xna-example-content\\SpineEffectNormalmap");
                spineEffect.Parameters["Light0_Direction"].SetValue(new Vector3(-0.5265408f, 0.5735765f, -0.6275069f));
                spineEffect.Parameters["Light0_Diffuse"].SetValue(new Vector3(1, 0.9607844f, 0.8078432f));
                spineEffect.Parameters["Light0_Specular"].SetValue(new Vector3(1, 0.9607844f, 0.8078432f));
                spineEffect.Parameters["Light0_SpecularExponent"].SetValue(2.0f);
            }
            spineEffect.Parameters["World"].SetValue(Matrix.Identity);
            spineEffect.Parameters["View"].SetValue(Matrix.CreateLookAt(new Vector3(0.0f, 0.0f, 1.0f), Vector3.Zero, Vector3.Up));

            skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
            skeletonRenderer.PremultipliedAlpha = false;
            skeletonRenderer.Effect             = spineEffect;

            skeletonDebugRenderer = new SkeletonDebugRenderer(GraphicsDevice);
            skeletonDebugRenderer.DisableAll();
            skeletonDebugRenderer.DrawClipping = true;

            // String name = "spineboy-pro";
            String name = "raptor-pro";

            // String name = "tank-pro";
            //String name = "coin-pro";
            if (useNormalmapShader)
            {
                name = "raptor-pro";                 // we only have normalmaps for raptor
            }
            String atlasName = name.Replace("-pro", "").Replace("-ess", "");

            bool binaryData = false;

            Atlas atlas;

            if (!useNormalmapShader)
            {
                atlas = new Atlas(assetsFolder + atlasName + ".atlas", new XnaTextureLoader(GraphicsDevice));
            }
            else
            {
                atlas = new Atlas(assetsFolder + atlasName + ".atlas", new XnaTextureLoader(GraphicsDevice,
                                                                                            loadMultipleTextureLayers: true, textureSuffixes: new string[] { "", "_normals" }));
            }
            float scale = 1;

            if (name == "spineboy-pro")
            {
                scale = 0.6f;
            }
            if (name == "raptor-pro")
            {
                scale = 0.5f;
            }
            if (name == "tank-pro")
            {
                scale = 0.3f;
            }
            if (name == "coin-pro")
            {
                scale = 1;
            }

            SkeletonData skeletonData;

            if (binaryData)
            {
                SkeletonBinary binary = new SkeletonBinary(atlas);
                binary.Scale = scale;
                skeletonData = binary.ReadSkeletonData(assetsFolder + name + ".skel");
            }
            else
            {
                SkeletonJson json = new SkeletonJson(atlas);
                json.Scale   = scale;
                skeletonData = json.ReadSkeletonData(assetsFolder + name + ".json");
            }
            skeleton = new Skeleton(skeletonData);
            if (name == "goblins-pro")
            {
                skeleton.SetSkin("goblin");
            }

            // Define mixing between animations.
            AnimationStateData stateData = new AnimationStateData(skeleton.Data);

            state = new AnimationState(stateData);

            if (name == "spineboy-pro")
            {
                skeleton.SetAttachment("head-bb", "head");

                stateData.SetMix("run", "jump", 0.2f);
                stateData.SetMix("jump", "run", 0.4f);

                // Event handling for all animations.
                state.Start    += Start;
                state.End      += End;
                state.Complete += Complete;
                state.Event    += Event;

                state.SetAnimation(0, "run", true);
                TrackEntry entry = state.AddAnimation(0, "jump", false, 0);
                entry.End += End;                 // Event handling for queued animations.
                state.AddAnimation(0, "run", true, 0);
            }
            else if (name == "raptor-pro")
            {
                state.SetAnimation(0, "walk", true);
                state.AddAnimation(1, "gun-grab", false, 2);
            }
            else if (name == "coin-pro")
            {
                state.SetAnimation(0, "animation", true);
            }
            else if (name == "tank-pro")
            {
                skeleton.X += 300;
                state.SetAnimation(0, "drive", true);
            }
            else
            {
                state.SetAnimation(0, "walk", true);
            }

            skeleton.X += 400;
            skeleton.Y += GraphicsDevice.Viewport.Height;
            skeleton.UpdateWorldTransform();

            headSlot = skeleton.FindSlot("head");
        }
Ejemplo n.º 17
0
    public SkeletonData GetSkeletonData(bool quiet)
    {
        if (atlasAsset == null) {
            if (!quiet)
                Debug.LogError("Atlas not set for SkeletonData asset: " + name, this);
            Clear();
            return null;
        }

        if (skeletonJSON == null) {
            if (!quiet)
                Debug.LogError("Skeleton JSON file not set for SkeletonData 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 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);
        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;
    }