public override void Render(float deltaTime) { // Update the animation state and apply the animations // to the skeleton state.Update(deltaTime); state.Apply(skeleton); // Update the transformations of bones and other parts of the skeleton skeleton.UpdateWorldTransform(); // Clear the screen and setup the projection matrix of the skeleton renderer game.GraphicsDevice.Clear(Color.Black); ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0); // Draw the skeletons skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); // Check if the mouse button was clicked and switch scene if (mouseClicked) { game.currentScreen = new TankScreen(game); } }
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(); }
public Animation(string AnimationFile) { skeletonRenderer = new SkeletonRenderer(); String name = AnimationFile; Atlas atlas = new Atlas("Data/" + name + ".atlas", new GLImpTextureLoader()); SkeletonJson json = new SkeletonJson(atlas); skeleton = new Skeleton(json.ReadSkeletonData("Data/" + name + ".json")); skeleton.SetSlotsToSetupPose(); // Define mixing between animations. stateData = new AnimationStateData(skeleton.Data); state = new AnimationState(stateData); //state.SetAnimation("idle", true); skeleton.X = 0; skeleton.Y = 0.1f; skeleton.UpdateWorldTransform(); drawtime = new Stopwatch(); drawtime.Start(); Program.MiddleDrawQueue += Draw; }
/* * Actual draw. Pipeline is 'deferred' list of GDI calls */ public static void Draw(Skeleton skeleton, Pipeline pipeline) { skeleton.UpdateWorldTransform(); foreach (Slot slot in skeleton.Slots) { if (slot.Attachment == null) { continue; } if (slot.Attachment.GetType() == typeof(RegionAttachment)) { RegionAttachment attach = (RegionAttachment)slot.Attachment; AtlasRegion region = (AtlasRegion)attach.RendererObject; float[] worldVertices = new float[2 * 4]; attach.ComputeWorldVertices(slot.Bone, worldVertices); var color = Color.FromArgb((int)(slot.A * 255), (int)(slot.R * 255), (int)(slot.G * 255), (int)(slot.B * 255)); DrawRegionAttachmnent(pipeline, region, worldVertices, color, slot.Data.BlendMode); } else if (slot.Attachment.GetType() == typeof(MeshAttachment)) { MeshAttachment attach = (MeshAttachment)slot.Attachment; AtlasRegion region = (AtlasRegion)attach.RendererObject; float[] worldVertices = new float[attach.WorldVerticesLength]; attach.ComputeWorldVertices(slot, worldVertices); int[] triangles = attach.Triangles; var color = Color.FromArgb((int)(slot.A * 255), (int)(slot.R * 255), (int)(slot.G * 255), (int)(slot.B * 255)); DrawMeshAttachmnent(pipeline, region, attach.RegionUVs, worldVertices, triangles, color, slot.Data.BlendMode); } else { } } }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); state.Update(gameTime.ElapsedGameTime.Milliseconds / 1000f); state.Apply(skeleton); skeleton.UpdateWorldTransform(); skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); bounds.Update(skeleton, true); MouseState mouse = Mouse.GetState(); if (headSlot != null) { headSlot.G = 1; headSlot.B = 1; if (bounds.AabbContainsPoint(mouse.X, mouse.Y)) { BoundingBoxAttachment hit = bounds.ContainsPoint(mouse.X, mouse.Y); if (hit != null) { headSlot.G = 0; headSlot.B = 0; } } } base.Draw(gameTime); }
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"); }
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"); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); state.Update(gameTime.ElapsedGameTime.Milliseconds / 1000f); state.Apply(skeleton); skeleton.UpdateWorldTransform(); skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); base.Draw(gameTime); }
static int UpdateWorldTransform(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); Spine.Skeleton obj = (Spine.Skeleton)ToLua.CheckObject <Spine.Skeleton>(L, 1); obj.UpdateWorldTransform(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
protected override void LoadContent() { skeletonRenderer = new SkeletonRenderer(GraphicsDevice); Atlas atlas = new Atlas("data/goblins.atlas", new XnaTextureLoader(GraphicsDevice)); SkeletonJson json = new SkeletonJson(atlas); skeleton = new Skeleton(json.ReadSkeletonData("data/goblins.json")); skeleton.SetSkin("goblingirl"); skeleton.SetSlotsToBindPose(); // Without this the skin attachments won't be attached. See SetSkin. animation = skeleton.Data.FindAnimation("walk"); skeleton.RootBone.X = 320; skeleton.RootBone.Y = 440; skeleton.UpdateWorldTransform(); }
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(); }
public override void Render(float deltaTime) { state.Update(deltaTime); state.Apply(skeleton); skeleton.UpdateWorldTransform(); game.GraphicsDevice.Clear(Color.Black); ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0); skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); if (mouseClicked) { game.currentScreen = new RaptorScreen(game); } }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); state.Update(gameTime.ElapsedGameTime.Milliseconds / 1000f); state.Apply(skeleton); skeleton.UpdateWorldTransform(); if (skeletonRenderer.Effect is BasicEffect) { ((BasicEffect)skeletonRenderer.Effect).Projection = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1, 0); } else { skeletonRenderer.Effect.Parameters["Projection"].SetValue(Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1, 0)); } skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); skeletonDebugRenderer.Effect.Projection = Matrix.CreateOrthographicOffCenter(0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1, 0); skeletonDebugRenderer.Begin(); skeletonDebugRenderer.Draw(skeleton); skeletonDebugRenderer.End(); bounds.Update(skeleton, true); MouseState mouse = Mouse.GetState(); if (headSlot != null) { headSlot.G = 1; headSlot.B = 1; if (bounds.AabbContainsPoint(mouse.X, mouse.Y)) { BoundingBoxAttachment hit = bounds.ContainsPoint(mouse.X, mouse.Y); if (hit != null) { headSlot.G = 0; headSlot.B = 0; } } } base.Draw(gameTime); }
public Avatar(string AnimationFile) { SkeletonRenderer = new SkeletonRenderer(Vector3.UnitY, Vector3.UnitZ); String name = AnimationFile; Atlas atlas = new Atlas(name + ".atlas", new OpenTKTextureLoader()); SkeletonJson json = new SkeletonJson(atlas); Skeleton = new Skeleton(json.ReadSkeletonData(name + ".json")); Skeleton.SetSlotsToSetupPose(); // Define mixing between animations. StateData = new AnimationStateData(Skeleton.Data); State = new AnimationState(StateData); Skeleton.X = 0; Skeleton.Y = 0; Skeleton.UpdateWorldTransform(); }
public override void Render(float deltaTime) { state.Update(deltaTime); state.Apply(skeleton); skeleton.UpdateWorldTransform(); // Clear the screen and setup the projection matrix of the custom effect through the // "Projection" parameter. game.GraphicsDevice.Clear(Color.Black); skeletonRenderer.Effect.Parameters["Projection"].SetValue(Matrix.CreateOrthographicOffCenter(0, game.GraphicsDevice.Viewport.Width, game.GraphicsDevice.Viewport.Height, 0, 1, 0)); skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); skeletonRenderer.End(); if (mouseClicked) { game.currentScreen = new SpineboyScreen(game); } }
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"); }
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(); }
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"); }
protected override void LoadContent() { skeletonRenderer = new SkeletonRenderer(GraphicsDevice); Texture2D texture = Util.LoadTexture(GraphicsDevice, "data/goblins.png"); Atlas atlas = new Atlas("data/goblins.atlas", texture, texture.Width, texture.Height); SkeletonJson json = new SkeletonJson(atlas); skeleton = new Skeleton(json.ReadSkeletonData("data/goblins.json")); skeleton.SetSkin("goblingirl"); skeleton.SetSlotsToBindPose(); // Without this the skin attachments won't be attached. See SetSkin. animation = skeleton.Data.FindAnimation("walk"); skeleton.RootBone.X = 320; skeleton.RootBone.Y = 440; skeleton.UpdateWorldTransform(); }
static Mesh ExtractSkinnedMeshAttachment (string name, SkinnedMeshAttachment attachment, int slotIndex, SkeletonData skeletonData, List<Transform> boneList, Mesh mesh = null) { Skeleton skeleton = new Skeleton(skeletonData); skeleton.UpdateWorldTransform(); float[] floatVerts = new float[attachment.UVs.Length]; attachment.ComputeWorldVertices(skeleton.Slots[slotIndex], floatVerts); Vector2[] uvs = ExtractUV(attachment.UVs); Vector3[] verts = ExtractVerts(floatVerts); int[] triangles = attachment.Triangles; Color color = new Color(attachment.R, attachment.G, attachment.B, attachment.A); if (mesh == null) mesh = new Mesh(); mesh.triangles = new int[0]; mesh.vertices = verts; mesh.uv = uvs; mesh.triangles = triangles; Color[] colors = new Color[verts.Length]; for (int i = 0; i < verts.Length; i++) colors[i] = color; mesh.colors = colors; mesh.name = name; mesh.RecalculateNormals(); mesh.RecalculateBounds(); //Handle weights and binding Dictionary<int, BoneWeightContainer> weightTable = new Dictionary<int, BoneWeightContainer>(); System.Text.StringBuilder warningBuilder = new System.Text.StringBuilder(); int[] bones = attachment.Bones; float[] weights = attachment.Weights; for (int w = 0, v = 0, b = 0, n = bones.Length; v < n; w += 2) { int nn = bones[v++] + v; for (; v < nn; v++, b += 3) { Transform boneTransform = boneList[bones[v]]; int vIndex = w / 2; float weight = weights[b + 2]; BoneWeightContainer container; if (weightTable.ContainsKey(vIndex)) container = weightTable[vIndex]; else { container = new BoneWeightContainer(); weightTable.Add(vIndex, container); } container.Add(boneTransform, weight); } } BoneWeight[] boneWeights = new BoneWeight[weightTable.Count]; for (int i = 0; i < weightTable.Count; i++) { BoneWeight bw = new BoneWeight(); var container = weightTable[i]; var pairs = container.pairs.OrderByDescending(pair => pair.weight).ToList(); for (int b = 0; b < pairs.Count; b++) { if (b > 3) { if (warningBuilder.Length == 0) warningBuilder.Insert(0, "[SkinnedMeshAttachment " + name + "]\r\nUnity only supports 4 weight influences per vertex! The 4 strongest influences will be used.\r\n"); warningBuilder.AppendFormat("{0} ignored on vertex {1}!\r\n", pairs[b].bone.name, i); continue; } int boneIndex = boneList.IndexOf(pairs[b].bone); float weight = pairs[b].weight; switch (b) { case 0: bw.boneIndex0 = boneIndex; bw.weight0 = weight; break; case 1: bw.boneIndex1 = boneIndex; bw.weight1 = weight; break; case 2: bw.boneIndex2 = boneIndex; bw.weight2 = weight; break; case 3: bw.boneIndex3 = boneIndex; bw.weight3 = weight; break; } } boneWeights[i] = bw; } Matrix4x4[] bindPoses = new Matrix4x4[boneList.Count]; for (int i = 0; i < boneList.Count; i++) { bindPoses[i] = boneList[i].worldToLocalMatrix; } mesh.boneWeights = boneWeights; mesh.bindposes = bindPoses; string warningString = warningBuilder.ToString(); if (warningString.Length > 0) Debug.LogWarning(warningString); return mesh; }
protected override void LoadContent() { skeletonRenderer = new SkeletonRenderer(GraphicsDevice); Atlas atlas = new Atlas(GraphicsDevice, "data/goblins.atlas"); SkeletonJson json = new SkeletonJson(atlas); skeleton = new Skeleton(json.readSkeletonData("goblins", File.ReadAllText("data/goblins.json"))); skeleton.SetSkin("goblingirl"); skeleton.SetSlotsToBindPose(); animation = skeleton.Data.FindAnimation("walk"); skeleton.RootBone.X = 320; skeleton.RootBone.Y = 440; skeleton.UpdateWorldTransform(); }
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"); }
public void Draw(Skeleton skeleton, Color color) { beginSkeletonRenderer(); Vector4 colorBefore = new Vector4(skeleton.R, skeleton.G, skeleton.B, skeleton.A); updateColor(ref color); tintSkeleton(skeleton, color); if (Camera != null) { float previousX = skeleton.RootBone.X; float previousY = skeleton.RootBone.Y; float previousScaleX = skeleton.RootBone.ScaleX; float previousScaleY = skeleton.RootBone.ScaleY; Vector2 position = Camera.TranslateVector(new Vector2(previousX, previousY)); skeleton.RootBone.X = position.X; skeleton.RootBone.Y = position.Y; skeleton.RootBone.ScaleX *= Camera.Scale.X; skeleton.RootBone.ScaleY *= Camera.Scale.Y; skeleton.UpdateWorldTransform(); skeletonRenderer.Draw(skeleton); skeleton.RootBone.X = previousX; skeleton.RootBone.Y = previousY; skeleton.RootBone.ScaleX = previousScaleX; skeleton.RootBone.ScaleY = previousScaleY; skeleton.UpdateWorldTransform(); } else skeletonRenderer.Draw(skeleton); skeleton.R = colorBefore.X; skeleton.G = colorBefore.Y; skeleton.B = colorBefore.Z; skeleton.A = colorBefore.W; }
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"); }
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"); }
public void LoadContent(ContentManager content, GraphicsDevice graphicsDevice) { blankTex = content.Load<Texture2D>("blank"); skeletonRenderer = new SkeletonRenderer(graphicsDevice); Atlas atlas = new Atlas(graphicsDevice, "robo/robo.atlas", content); SkeletonJson json = new SkeletonJson(atlas); skeleton = new Skeleton(json.readSkeletonData("robo", File.ReadAllText(Path.Combine(content.RootDirectory, "robo/robo.json")))); skeleton.SetSkin("default"); skeleton.SetSlotsToBindPose(); //skeleton.FindSlot("melee-item").Attachment = itemAttach; //skeleton.SetAttachment("melee-item", "crowbar"); fistSound = AudioController.effects["fist"].CreateInstance(); fistSound.IsLooped = true; fistSound.Volume = 0f; fistSound.Pitch = -1f; fistSound.Play(); Animations.Add("walk", skeleton.Data.FindAnimation("walk")); Animations.Add("punch-hold", skeleton.Data.FindAnimation("punch-hold")); Animations.Add("punch-release", skeleton.Data.FindAnimation("punch-release")); Animations.Add("knockback", skeleton.Data.FindAnimation("knockback")); Animations.Add("pickup", skeleton.Data.FindAnimation("pickup")); Animations.Add("knockout", skeleton.Data.FindAnimation("knockout")); skeleton.RootBone.X = Position.X; skeleton.RootBone.Y = Position.Y; skeleton.RootBone.ScaleX = Scale; skeleton.RootBone.ScaleY = Scale; skeleton.UpdateWorldTransform(); Health = 121f; //ItemManager.Instance.Spawn(this); //skeleton.SetAttachment("melee-item", null); skeleton.FindSlot("fist-item").A = 0f; }
protected override void LoadContent() { skeletonRenderer = new SkeletonRenderer(GraphicsDevice); Atlas atlas = new Atlas("data/goblins.atlas", new XnaTextureLoader(GraphicsDevice)); SkeletonJson json = new SkeletonJson(atlas); skeleton = new Skeleton(json.ReadSkeletonData("data/goblins.json")); skeleton.SetSkin("goblingirl"); skeleton.SetSlotsToBindPose(); // Without this the skin attachments won't be attached. See SetSkin. skeleton.SetAttachment("left hand item", "spear"); animation = skeleton.Data.FindAnimation("walk"); skeleton.RootBone.X = 320; skeleton.RootBone.Y = 440; skeleton.UpdateWorldTransform(); }
// build the sprite and slots with the skeleton data private void BuildSkeleton(SkeletonData skeletonData) { skeleton = new Skeleton(skeletonData); skeleton.UpdateWorldTransform(); // check if there are multiple skins loaded if(skeleton.Data.Skins.Count > 0){ // load the first skin as default SetSkin(skeleton.Data.Skins[0].Name); } // build all the child sprites in the container, add them based on the slot draw order and create using the default slot/attachment for(int i = 0; i < skeleton.DrawOrder.Count; i++){ GSpineSlot slot = new GSpineSlot(skeleton.DrawOrder[i]); slots.Add(slot); AddChild(slot); } AnimationStateData animationStateData = new AnimationStateData(skeleton.Data); animation = new Spine.AnimationState(animationStateData); }
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"); }
protected override void LoadContent() { skeletonRenderer = new SkeletonRenderer(GraphicsDevice); Atlas atlas = new Atlas(GraphicsDevice, "data/spineboy.atlas"); SkeletonJson json = new SkeletonJson(atlas); skeleton = new Skeleton(json.readSkeletonData("spineboy", File.ReadAllText("data/spineboy.json"))); animation = skeleton.Data.FindAnimation("walk"); skeleton.RootBone.X = 320; skeleton.RootBone.Y = 440; skeleton.UpdateWorldTransform(); }
public void LoadContent(SkeletonRenderer sr, Texture2D bt, Atlas atlas, string json) { blankTex = bt; skeletonRenderer =sr; SkeletonJson skjson = new SkeletonJson(atlas); skeleton = new Skeleton(skjson.readSkeletonData("robo", json)); tint = new Color(0.5f + ((float)rand.NextDouble() * 0.5f), 0.5f + ((float)rand.NextDouble() * 0.5f), 0.5f + ((float)rand.NextDouble() * 0.5f)); skeleton.R = tint.ToVector3().X; skeleton.G = tint.ToVector3().Y; skeleton.B = tint.ToVector3().Z; foreach (Slot s in skeleton.Slots) { if (s.Data.Name != "melee-item" && s.Data.Name != "projectile-item" && s.Data.Name != "fist-item") { s.Data.R = skeleton.R; s.Data.G = skeleton.G; s.Data.B = skeleton.B; } } skeleton.SetSkin("default"); skeleton.SetSlotsToBindPose(); Animations.Add("walk", skeleton.Data.FindAnimation("walk")); Animations.Add("punch-hold", skeleton.Data.FindAnimation("punch-hold")); Animations.Add("punch-release", skeleton.Data.FindAnimation("punch-release")); Animations.Add("knockback", skeleton.Data.FindAnimation("knockback")); Animations.Add("pickup", skeleton.Data.FindAnimation("pickup")); Animations.Add("knockout", skeleton.Data.FindAnimation("knockout")); skeleton.RootBone.X = Position.X; skeleton.RootBone.Y = Position.Y; skeleton.RootBone.ScaleX = Scale; skeleton.RootBone.ScaleY = Scale; skeleton.UpdateWorldTransform(); skeleton.FindSlot("fist-item").A = 0f; fistSound = AudioController.effects["fist"].CreateInstance(); fistSound.IsLooped = true; fistSound.Volume = 0f; fistSound.Pitch = -1f; fistSound.Play(); }
static void ParseRotateTimeline (Skeleton skeleton, RotateTimeline timeline, AnimationClip clip) { var boneData = skeleton.Data.Bones[timeline.BoneIndex]; var bone = skeleton.Bones[timeline.BoneIndex]; AnimationCurve curve = new AnimationCurve(); float endTime = timeline.Frames[(timeline.FrameCount * 2) - 2]; float currentTime = timeline.Frames[0]; List<Keyframe> keys = new List<Keyframe>(); float rotation = timeline.Frames[1] + boneData.Rotation; keys.Add(new Keyframe(timeline.Frames[0], rotation, 0, 0)); int listIndex = 1; int frameIndex = 1; int f = 2; float[] frames = timeline.Frames; skeleton.SetToSetupPose(); float lastTime = 0; float angle = rotation; while (currentTime < endTime) { int pIndex = listIndex - 1; float curveType = timeline.GetCurveType(frameIndex - 1); if (curveType == 0) { //linear Keyframe pk = keys[pIndex]; float time = frames[f]; rotation = frames[f + 1] + boneData.Rotation; angle += Mathf.DeltaAngle(angle, rotation); float r = angle; float rOut = (r - pk.value) / (time - pk.time); pk.outTangent = rOut; keys.Add(new Keyframe(time, r, rOut, 0)); keys[pIndex] = pk; currentTime = time; timeline.Apply(skeleton, lastTime, currentTime, null, 1); lastTime = time; listIndex++; } else if (curveType == 1) { //stepped Keyframe pk = keys[pIndex]; float time = frames[f]; rotation = frames[f + 1] + boneData.Rotation; angle += Mathf.DeltaAngle(angle, rotation); float r = angle; float rOut = float.PositiveInfinity; pk.outTangent = rOut; keys.Add(new Keyframe(time, r, rOut, 0)); keys[pIndex] = pk; currentTime = time; timeline.Apply(skeleton, lastTime, currentTime, null, 1); lastTime = time; listIndex++; } else if (curveType == 2) { //bezier Keyframe pk = keys[pIndex]; float time = frames[f]; timeline.Apply(skeleton, lastTime, currentTime, null, 1); skeleton.UpdateWorldTransform(); rotation = frames[f + 1] + boneData.Rotation; angle += Mathf.DeltaAngle(angle, rotation); float r = angle; int steps = Mathf.FloorToInt((time - pk.time) / bakeIncrement); for (int i = 1; i <= steps; i++) { currentTime += bakeIncrement; if (i == steps) currentTime = time; timeline.Apply(skeleton, lastTime, currentTime, null, 1); skeleton.UpdateWorldTransform(); pk = keys[listIndex - 1]; rotation = bone.Rotation; angle += Mathf.DeltaAngle(angle, rotation); r = angle; float rOut = (r - pk.value) / (currentTime - pk.time); pk.outTangent = rOut; keys.Add(new Keyframe(currentTime, r, rOut, 0)); keys[listIndex - 1] = pk; listIndex++; lastTime = currentTime; } } frameIndex++; f += 2; } curve = EnsureCurveKeyCount(new AnimationCurve(keys.ToArray())); string path = GetPath(boneData); string propertyName = "localEulerAnglesBaked"; EditorCurveBinding xBind = EditorCurveBinding.FloatCurve(path, typeof(Transform), propertyName + ".x"); AnimationUtility.SetEditorCurve(clip, xBind, new AnimationCurve()); EditorCurveBinding yBind = EditorCurveBinding.FloatCurve(path, typeof(Transform), propertyName + ".y"); AnimationUtility.SetEditorCurve(clip, yBind, new AnimationCurve()); EditorCurveBinding zBind = EditorCurveBinding.FloatCurve(path, typeof(Transform), propertyName + ".z"); AnimationUtility.SetEditorCurve(clip, zBind, curve); }
public void LoadContent(ContentManager content, GraphicsDevice graphicsDevice) { //blankTex = content.Load<Texture2D>("blank"); skeletonRenderer = new SkeletonRenderer(graphicsDevice); Atlas atlas = new Atlas(graphicsDevice, "dude/dude.atlas", content); SkeletonJson json = new SkeletonJson(atlas); skeleton = new Skeleton(json.readSkeletonData("dude", File.ReadAllText(Path.Combine(content.RootDirectory, "dude/dude.json")))); skeleton.SetSkin("default"); skeleton.SetSlotsToBindPose(); Color topColor = Color.Navy; Color bottomColor = Color.Navy; Color shoesColor = Color.DarkGray; Vector3 skinColor = SkinTone().ToVector3(); Vector3 hairColor = HairColor().ToVector3(); foreach (Slot s in skeleton.Slots) { if (s.Data.Name == "torso" || s.Data.Name == "arm-back-upper" || s.Data.Name == "arm-back-lower" || s.Data.Name == "arm-upper" || s.Data.Name == "arm-lower") { s.Data.R = topColor.R; s.Data.G = topColor.G; s.Data.B = topColor.B; } if (s.Data.Name == "leg-left" || s.Data.Name == "leg-right") { s.Data.R = bottomColor.R; s.Data.G = bottomColor.G; s.Data.B = bottomColor.B; } if (s.Data.Name == "foot-left" || s.Data.Name == "foot-right") { s.Data.R = shoesColor.R; s.Data.G = shoesColor.G; s.Data.B = shoesColor.B; } if (s.Data.Name == "head" || s.Data.Name == "hand" || s.Data.Name == "hand-copy") { s.Data.R = skinColor.X; s.Data.G = skinColor.Y; s.Data.B = skinColor.Z; } if (s.Data.Name == "hair") { s.Data.R = hairColor.X; s.Data.G = hairColor.Y; s.Data.B = hairColor.Z; } } skeleton.SetSkin("default"); skeleton.SetSlotsToBindPose(); Animations.Add("walk", skeleton.Data.FindAnimation("walk")); Animations.Add("punch-hold", skeleton.Data.FindAnimation("punch-hold")); Animations.Add("punch-release", skeleton.Data.FindAnimation("punch-release")); Animations.Add("knockback", skeleton.Data.FindAnimation("knockback")); Animations.Add("pickup", skeleton.Data.FindAnimation("pickup")); Animations.Add("knockout", skeleton.Data.FindAnimation("knockout")); Animations.Add("panic", skeleton.Data.FindAnimation("panic")); skeleton.RootBone.X = Position.X; skeleton.RootBone.Y = Position.Y; skeleton.RootBone.ScaleX = Scale; skeleton.RootBone.ScaleY = Scale; skeleton.UpdateWorldTransform(); skeleton.SetAttachment("melee-item", null); skeleton.SetAttachment("hat", (IsCoPilot || IsPlayer) ? "Pilot-Hat" : null); skeleton.SetAttachment("hair", (Helper.Random.Next(2) == 0 ? "Hair-Male" : "Hair-Female")); skeleton.SetAttachment("chute", null); HasParachute = false; //skeleton.FindSlot("fist-item").A = 0f; }
public void LoadContent(ContentManager content, GraphicsDevice graphicsDevice) { blankTex = content.Load<Texture2D>("Textures/Blank"); skeletonRenderer = new SkeletonRenderer(graphicsDevice); Atlas atlas = new Atlas(graphicsDevice, System.IO.Path.Combine(content.RootDirectory, "spineboy.atlas")); SkeletonJson json = new SkeletonJson(atlas); json.Scale = 0.5f; skeleton = new Skeleton(json.readSkeletonData("spineboy", File.ReadAllText(System.IO.Path.Combine(content.RootDirectory, "spineboy.json")))); skeleton.SetSkin("default"); skeleton.SetSlotsToBindPose(); walkAnimation = skeleton.Data.FindAnimation("walk"); jumpAnimation = skeleton.Data.FindAnimation("jump"); crawlAnimation = skeleton.Data.FindAnimation("crawl"); fallAnimation = skeleton.Data.FindAnimation("fall"); grabAnimation = skeleton.Data.FindAnimation("grab"); climbAnimation = skeleton.Data.FindAnimation("climb"); skeleton.RootBone.X = Position.X; skeleton.RootBone.Y = Position.Y; skeleton.UpdateWorldTransform(); }
public void LoadContent(ContentManager content, GraphicsDevice graphicsDevice) { blankTex = content.Load<Texture2D>("blank"); skeletonRenderer = new SkeletonRenderer(graphicsDevice); Atlas atlas = new Atlas(graphicsDevice, Path.Combine(content.RootDirectory, "spinegirl.atlas")); SkeletonJson json = new SkeletonJson(atlas); skeleton = new Skeleton(json.readSkeletonData("spinegirl", File.ReadAllText(Path.Combine(content.RootDirectory, "spinegirl.json")))); skeleton.SetSkin("default"); skeleton.SetSlotsToBindPose(); Animations.Add("walk", skeleton.Data.FindAnimation("walk")); Animations.Add("jump", skeleton.Data.FindAnimation("jump")); Animations.Add("crawl", skeleton.Data.FindAnimation("crawl")); Animations.Add("fall", skeleton.Data.FindAnimation("fall")); Animations.Add("grab", skeleton.Data.FindAnimation("grab")); Animations.Add("climb", skeleton.Data.FindAnimation("climb")); Animations.Add("turnvalve", skeleton.Data.FindAnimation("turnvalve")); skeleton.RootBone.X = Position.X; skeleton.RootBone.Y = Position.Y; skeleton.RootBone.ScaleX = Scale; skeleton.RootBone.ScaleY = Scale; skeleton.UpdateWorldTransform(); }
public void LoadContent(SkeletonRenderer sr, Atlas atlas, string json) { //blankTex = bt; skeletonRenderer =sr; SkeletonJson skjson = new SkeletonJson(atlas); skeleton = new Skeleton(skjson.readSkeletonData("robo", json)); //skeleton.R = Tint.ToVector3().X; //skeleton.G = Tint.ToVector3().Y; //skeleton.B = Tint.ToVector3().Z; Vector3 topColor = ClothesTint().ToVector3(); Vector3 bottomColor = ClothesTint().ToVector3(); Vector3 shoesColor = ClothesTint().ToVector3(); Vector3 skinColor = SkinTone().ToVector3(); Vector3 hairColor = HairColor().ToVector3(); if (IsCoPilot) { topColor = Color.Blue.ToVector3(); bottomColor = Color.Blue.ToVector3(); shoesColor = Color.DarkGray.ToVector3(); } foreach (Slot s in skeleton.Slots) { if (s.Data.Name == "torso" || s.Data.Name=="arm-back-upper" || s.Data.Name == "arm-back-lower" || s.Data.Name== "arm-upper" || s.Data.Name =="arm-lower") { s.Data.R = topColor.X; s.Data.G = topColor.Y; s.Data.B = topColor.Z; } if (s.Data.Name == "leg-left" || s.Data.Name == "leg-right") { s.Data.R = bottomColor.X; s.Data.G = bottomColor.Y; s.Data.B = bottomColor.Z; } if (s.Data.Name == "foot-left" || s.Data.Name == "foot-right") { s.Data.R = shoesColor.X; s.Data.G = shoesColor.Y; s.Data.B = shoesColor.Z; } if (s.Data.Name == "head" || s.Data.Name == "hand" || s.Data.Name == "hand-copy") { s.Data.R = skinColor.X; s.Data.G = skinColor.Y; s.Data.B = skinColor.Z; } if (s.Data.Name == "hair") { s.Data.R = hairColor.X; s.Data.G = hairColor.Y; s.Data.B = hairColor.Z; } } skeleton.SetSkin("default"); skeleton.SetSlotsToBindPose(); Animations.Add("walk", skeleton.Data.FindAnimation("walk")); Animations.Add("punch-hold", skeleton.Data.FindAnimation("punch-hold")); Animations.Add("punch-release", skeleton.Data.FindAnimation("punch-release")); Animations.Add("knockback", skeleton.Data.FindAnimation("knockback")); Animations.Add("pickup", skeleton.Data.FindAnimation("pickup")); Animations.Add("knockout", skeleton.Data.FindAnimation("knockout")); Animations.Add("panic", skeleton.Data.FindAnimation("panic")); skeleton.RootBone.X = Position.X; skeleton.RootBone.Y = Position.Y; skeleton.RootBone.ScaleX = Scale; skeleton.RootBone.ScaleY = Scale; skeleton.UpdateWorldTransform(); skeleton.SetAttachment("melee-item", null); skeleton.SetAttachment("hat", (IsCoPilot||IsPlayer)?"Pilot-Hat":null); skeleton.SetAttachment("hair", (Helper.Random.Next(2)==0?"Hair-Male":"Hair-Female")); skeleton.SetAttachment("chute", null); //skeleton.FindSlot("fist-item").A = 0f; HasParachute = false; State = AIState.Panic; }