public SetAttachment ( String slotName, String attachmentName ) : void | ||
slotName | String | |
attachmentName | String | May be null. |
return | void |
static int SetAttachment(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); Spine.Skeleton obj = (Spine.Skeleton)ToLua.CheckObject <Spine.Skeleton>(L, 1); string arg0 = ToLua.CheckString(L, 2); string arg1 = ToLua.CheckString(L, 3); obj.SetAttachment(arg0, arg1); 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. skeleton.SetAttachment("left hand item", "spear"); 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"); }
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"); }
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(); }
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; }
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; }