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