SetSkin() 공개 메소드

Sets the skin used to look up attachments before looking in the {@link SkeletonData#getDefaultSkin() default skin}. Attachmentsfrom the new skin are attached if the corresponding attachment from the old skin was attached. If there was no old skin, each slot's setup mode attachment is attached from the new skin.
public SetSkin ( Spine.Skin newSkin ) : void
newSkin Spine.Skin May be null.
리턴 void
예제 #1
0
    // Use this for initialization
    void Start()
    {
        //randomize character's walking speed
        walkingSpeed = Random.Range(0.01f, 0.03f);

        //assign character skin from skinType
        skeletonAnimation = GetComponent <SkeletonAnimation>();
        skeleton          = skeletonAnimation.Skeleton;
        skeleton.SetSkin(((SkinType)Random.Range(0, 20)).ToString());
        //get reference to map
        mapRef = GameObject.Find("Map").GetComponent <Map>();
        // this stores where in current route-- when you start not yet at first stop, at spawn position
        currentStop = -1;
        // determines sprite animation, when you get to room then do animation assigned
        // but first start in transit
        // could start by idling

        currentlyDoing = Activity.Transit;
        timer          = 0;
        // create 5 destinations in route
        for (int i = 0; i <= 5; i++)
        {
            route.Add(generateRandomDestination());
        }
    }
예제 #2
0
    static int SetSkin(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <Spine.Skin>(L, 2))
            {
                Spine.Skeleton obj  = (Spine.Skeleton)ToLua.CheckObject <Spine.Skeleton>(L, 1);
                Spine.Skin     arg0 = (Spine.Skin)ToLua.ToObject(L, 2);
                obj.SetSkin(arg0);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes <string>(L, 2))
            {
                Spine.Skeleton obj  = (Spine.Skeleton)ToLua.CheckObject <Spine.Skeleton>(L, 1);
                string         arg0 = ToLua.ToString(L, 2);
                obj.SetSkin(arg0);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: Spine.Skeleton.SetSkin"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #3
0
        public SkeletonSpatial(GraphicsDevice device, string contentPath, string skin)
        {
            if (!_registered.TryGetValue(contentPath, out _record))
                _record = Load(device, contentPath);

            _skeleton = new Skeleton(_record.Data);
            _skeleton.SetSkin(skin);
            _skeleton.SetSlotsToBindPose();
        }
예제 #4
0
    public virtual void initCharacterModel()
    {
        Prepare();
        //
        AllSkins      = skeleton.Data.Skins.Select(x => x.Name).ToList();
        AllAnimations = skeleton.Data.Animations.Select(x => x.Name).ToList();

        if (AllSkins.Contains(CMC.skinName))
        {
            skeleton.SetSkin(CMC.skinName);
        }
        else
        {
            skeleton.SetSkin("default");
        }

        if (_Tag == SDConstants.CharacterType.Hero)
        {
            HeroCharacterSet();
        }
    }
    public virtual void Initialize()
    {
        mesh = new Mesh();
        GetComponent<MeshFilter>().mesh = mesh;
        mesh.name = "Skeleton Mesh";
        mesh.hideFlags = HideFlags.HideAndDontSave;

        skeleton = new Skeleton(skeletonDataAsset.GetSkeletonData(false));

        if (initialSkinName != null && initialSkinName.Length > 0) {
            skeleton.SetSkin(initialSkinName);
            skeleton.SetSlotsToSetupPose();
        }
    }
예제 #6
0
		protected override void LoadContent () {
			skeletonRenderer = new SkeletonMeshRenderer(GraphicsDevice);
			skeletonRenderer.PremultipliedAlpha = true;

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

			Atlas atlas = new Atlas(assetsFolder + name + ".atlas", new XnaTextureLoader(GraphicsDevice));
			SkeletonJson json = new SkeletonJson(atlas);
			if (name == "spineboy") json.Scale = 0.6f;
			if (name == "raptor") json.Scale = 0.5f;
			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 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");
		}
예제 #7
0
    public virtual void Initialize()
    {
        mesh = new Mesh();
        GetComponent<MeshFilter>().mesh = mesh;
        mesh.name = "Skeleton Mesh";
        mesh.hideFlags = HideFlags.HideAndDontSave;
        mesh.MarkDynamic();

        renderer.sharedMaterial = skeletonDataAsset.atlasAsset.material;

        vertices = new Vector3[0];

        skeleton = new Skeleton(skeletonDataAsset.GetSkeletonData(false));

        if (initialSkinName != null && initialSkinName.Length > 0) {
            skeleton.SetSkin(initialSkinName);
            skeleton.SetSlotsToSetupPose();
        }
    }
예제 #8
0
파일: Dude.cs 프로젝트: GarethIW/LD28
        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;
        }
예제 #9
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();
        }
    public virtual void Reset()
    {
        if (meshFilter != null) meshFilter.sharedMesh = null;
        if (mesh != null) DestroyImmediate(mesh);
        if (renderer != null) renderer.sharedMaterial = null;
        mesh = null;
        mesh1 = null;
        mesh2 = null;
        lastVertexCount = 0;
        vertices = null;
        colors = null;
        uvs = null;
        sharedMaterials = new Material[0];
        submeshMaterials.Clear();
        submeshes.Clear();
        skeleton = null;

        valid = false;
        if (!skeletonDataAsset) {
            Debug.LogError("Missing SkeletonData asset.", this);
            return;
        }
        SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(false);
        if (skeletonData == null) return;
        valid = true;

        meshFilter = GetComponent<MeshFilter>();
        mesh1 = newMesh();
        mesh2 = newMesh();
        vertices = new Vector3[0];

        skeleton = new Skeleton(skeletonData);
        if (initialSkinName != null && initialSkinName.Length > 0 && initialSkinName != "default")
            skeleton.SetSkin(initialSkinName);
    }
예제 #11
0
        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();
        }
		public void Initialize (bool overwrite) {
			if (this.IsValid && !overwrite) return;

			// Make sure none of the stuff is null
			if (this.skeletonDataAsset == null) return;
			var skeletonData = this.skeletonDataAsset.GetSkeletonData(false);
			if (skeletonData == null) return;

			if (skeletonDataAsset.atlasAssets.Length <= 0 || skeletonDataAsset.atlasAssets[0].materials.Length <= 0) return;

			this.state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
			if (state == null) {
				Clear();
				return;
			}

			this.skeleton = new Skeleton(skeletonData);
			this.spineMeshGenerator = new Spine.Unity.MeshGeneration.ArraysSimpleMeshGenerator(); // You can switch this out with any other implementer of Spine.Unity.MeshGeneration.ISimpleMeshGenerator
			this.spineMeshGenerator.PremultiplyVertexColors = true;

			// Set the initial Skin and Animation
			if (!string.IsNullOrEmpty(initialSkinName))
				skeleton.SetSkin(initialSkinName);

			if (!string.IsNullOrEmpty(startingAnimation))
				state.SetAnimation(0, startingAnimation, startingLoop);
		}
예제 #13
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");
        }
예제 #14
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");
        }
예제 #15
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, "rotate", 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");
        }
예제 #16
0
        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();
        }
예제 #17
0
파일: Dude.cs 프로젝트: GarethIW/LD28
        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;
        }
예제 #18
0
    public virtual void Reset()
    {
        if (meshFilter != null)
            meshFilter.sharedMesh = null;
        if (renderer != null)
            renderer.sharedMaterial = null;
        mesh1 = null;
        mesh2 = null;
        lastVertexCount = 0;
        vertices = null;
        colors = null;
        uvs = null;
        sharedMaterials = new Material[0];
        submeshMaterials.Clear();
        submeshes.Clear();
        skeleton = null;

        valid = false;
        if (!skeletonDataAsset) {
            if (logErrors)
                Debug.LogError("Missing SkeletonData asset.", this);

            return;
        }
        SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(false);
        if (skeletonData == null)
            return;
        valid = true;

        meshFilter = GetComponent<MeshFilter>();
        mesh1 = newMesh();
        mesh2 = newMesh();
        vertices = new Vector3[0];

        skeleton = new Skeleton(skeletonData);
        if (initialSkinName != null && initialSkinName.Length > 0 && initialSkinName != "default")
            skeleton.SetSkin(initialSkinName);

        submeshSeparatorSlots.Clear();
        for (int i = 0; i < submeshSeparators.Length; i++) {
            submeshSeparatorSlots.Add(skeleton.FindSlot(submeshSeparators[i]));
        }

        if (OnReset != null)
            OnReset(this);
    }
예제 #19
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");
        }
예제 #20
0
        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();
        }
예제 #21
0
	public virtual void Reset () {
		if (meshFilter != null)
			meshFilter.sharedMesh = null;

		meshRenderer = GetComponent<MeshRenderer>();
		if (meshRenderer != null) meshRenderer.sharedMaterial = null;

		if (mesh1 != null) {
			if (Application.isPlaying)
				Destroy(mesh1);
			else
				DestroyImmediate(mesh1);
		}

		if (mesh2 != null) {
			if (Application.isPlaying)
				Destroy(mesh2);
			else
				DestroyImmediate(mesh2);
		}

		lastState = new LastState();
		mesh1 = null;
		mesh2 = null;
		vertices = null;
		colors = null;
		uvs = null;
		sharedMaterials = new Material[0];
		submeshMaterials.Clear();
		submeshes.Clear();
		skeleton = null;

		valid = false;
		if (!skeletonDataAsset) {
			if (logErrors)
				Debug.LogError("Missing SkeletonData asset.", this);

			return;
		}
		SkeletonData skeletonData = skeletonDataAsset.GetSkeletonData(false);
		if (skeletonData == null)
			return;
		valid = true;

		meshFilter = GetComponent<MeshFilter>();
		meshRenderer = GetComponent<MeshRenderer>();
		mesh1 = newMesh();
		mesh2 = newMesh();
		vertices = new Vector3[0];

		skeleton = new Skeleton(skeletonData);
		if (initialSkinName != null && initialSkinName.Length > 0 && initialSkinName != "default")
			skeleton.SetSkin(initialSkinName);

		submeshSeparatorSlots.Clear();
		for (int i = 0; i < submeshSeparators.Length; i++) {
			submeshSeparatorSlots.Add(skeleton.FindSlot(submeshSeparators[i]));
		}

		CollectSubmeshRenderers();

		LateUpdate();

		if (OnReset != null)
			OnReset(this);
	}
예제 #22
0
        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;
        }
예제 #23
0
    public virtual void Initialize()
    {
        if (Initialized) return;

        meshFilter = GetComponent<MeshFilter>();
        mesh1 = newMesh();
        mesh2 = newMesh();

        vertices = new Vector3[0];

        skeleton = new Skeleton(skeletonDataAsset.GetSkeletonData(false));

        if (initialSkinName != null && initialSkinName.Length > 0 && initialSkinName != "default") {
            skeleton.SetSkin(initialSkinName);
            skeleton.SetSlotsToSetupPose();
        }
    }
예제 #24
0
        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();
        }
예제 #25
0
파일: Hero.cs 프로젝트: GarethIW/LD26
        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();
        }
예제 #26
0
        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();
        }