• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
MohammadAhmed

.X file with animation clips

6 posts in this topic

I have many animations files for one model !! 


attak.x
walk.x
run.x
.................
and many others .

Now  how to mix them into one file so that I can use them in my XNA 3D animation game engine which accepts .X file only  ?? ( Pls I can't find an importer for 3d max so skip this solution smile.png )

 

Edited by mrmohadnan
0

Share this post


Link to post
Share on other sites

belfegor :) , thaaaaaanks brother you are always doing great help :) I will not forget that thank you I will try it right now.

1

Share this post


Link to post
Share on other sites

Ok , now My Animations are ready to being used ?? 

1 : If I want to it be for the enemy I don't need update methode called every user key input ?? 
if ( mouseButton.Right)
{

        enemy.walk; // example

}

but instead :
if(player.ray.intersects(enemy.boundingbox))
{
    enemy.walk;

}

i.e , I should used the animations for the enemy based on Machine state AI not based on user Input !! as the last one used for the player not the enemy ??!! right !!! sorry I am not strong in the animations :/ 

0

Share this post


Link to post
Share on other sites

Ok , May be my question was not clear , again :

Q : Now I have model.x with multiple animations clips ( walk , run , attak , jump ....etc ) , Now I must make a machine state so that the enemy will run according to sum conditions and also attack if I am close enough ?? do you have pseudo code on how to do that , or do you have any information about this :) ?

0

Share this post


Link to post
Share on other sites
I have used  XNA Animation Component Library to load ".x" files with multiple animations clips , now there is a sample called dwarfmodel and here is the code used to animate it :

private void UpdateEnemyState(GameTime gameTime, KeyboardState keyState, KeyboardState prebiousKeyState,
            MouseState mouseState)
        {
            BonePoseCollection poses = dwarfAnimator.BonePoses;
            if (stateModel == "idle")
            {
                currentSpeed = 0;
                // Add this to the beginning of the if (state=="idle") block in the UpdateState method
                // Remove the old if (keyState.IsKeyDown(Keys.W)) block
                if (keyState.IsKeyDown(Keys.W))
                {
                    blendFactor = 0;
                    stateModel = "idleToWalk";
                }
                // Add this in the if (state=="idle") block of the UpdateState method
                if (keyState.IsKeyDown(Keys.Space))
                {
                    crouch.ElapsedTime = 0;
                    crouch.IsLooping = false;
                    stateModel = "crouchDown";
                }

                if (mouseState.LeftButton == ButtonState.Pressed)
                {
                    stateModel = "attack0";
                }

                RunController(dwarfAnimator, idle);

            }
            else if (stateModel == "walk")
            {
                currentSpeed = WALK_SPEED;
                // Add this to the beginning of the if (state=="walk") block in the UpdateState method
                // Remove the old if (keyState.IsKeyUp(Keys.W)) block
                if (keyState.IsKeyUp(Keys.W))
                {
                    blendFactor = 0;
                    stateModel = "walkToIdle";
                }
                if (keyState.IsKeyDown(Keys.LeftShift) && keyState.IsKeyDown(Keys.W))
                {
                    blendFactor = 0;
                    stateModel = "walkToRun";
                    run.SpeedFactor = 0;
                }
                RunController(dwarfAnimator, crouch );
            }
            // Add this to the UpdateState method
            else if (stateModel == "idleToWalk")
            {
                blendFactor += .1f;
                currentSpeed = blendFactor * WALK_SPEED;
                if (blendFactor >= 1)
                {
                    blendFactor = 1;
                    stateModel = "walk";
                }
                foreach (BonePose p in poses)
                {
                    p.CurrentController = idle;
                    p.CurrentBlendController = walk;
                    p.BlendFactor = blendFactor;
                }
            }
            // Add this to the UpdateState method
            else if (stateModel == "walkToIdle")
            {
                blendFactor += .1f;
                currentSpeed = (1f - blendFactor) * WALK_SPEED;
                if (blendFactor >= 1)
                {
                    blendFactor = 1;
                    stateModel = "idle";
                }
                foreach (BonePose p in poses)
                {
                    p.CurrentController = walk;
                    p.CurrentBlendController = idle;
                    p.BlendFactor = blendFactor;
                }
            }
            // Add this in the UpdateState method
            else if (stateModel == "crouchDown")
            {
                crouch.AnimationEnded += crouch_AnimationEnded;
                RunController(dwarfAnimator, crouch);
            }
            else if (stateModel == "stayCrouched")
            {
                // Add this to the if (state == "stayCrouched") block in the UpdateState method
                if (keyState.IsKeyDown(Keys.Space) && prebiousKeyState.IsKeyUp(Keys.Space))
                {
                    crouch.ElapsedTime = crouch.AnimationSource.Duration;
                    crouch.SpeedFactor = 0;
                    stateModel = "standUp";
                }
                RunController(dwarfAnimator, stayCrouched);
            }
            // Add this to the UpdateState method
            else if (stateModel == "standUp")
            {
                if (crouch.ElapsedTime - gameTime.ElapsedGameTime.Ticks <= 0)
                {
                    crouch.SpeedFactor = 1;
                    crouch.ElapsedTime = 0;
                    idle.ElapsedTime = 0;
                    stateModel = "idle";
                }
                else
                    crouch.ElapsedTime -= gameTime.ElapsedGameTime.Ticks;
                RunController(dwarfAnimator, crouch);
            }
            // Add this to the UpdateState method
            else if (stateModel == "walkToRun")
            {
                blendFactor += .05f;
                if (blendFactor >= 1)
                {
                    blendFactor = 1;
                    run.SpeedFactor = 1;
                    stateModel = "run";
                }
                double factor = (double)walk.ElapsedTime / walk.AnimationSource.Duration;
                run.ElapsedTime = (long)(factor * run.AnimationSource.Duration);
                currentSpeed = WALK_SPEED + blendFactor * (RUN_SPEED - WALK_SPEED);
                foreach (BonePose p in poses)
                {
                    p.CurrentController = walk;
                    p.CurrentBlendController = run;
                    p.BlendFactor = blendFactor;
                }
            }
            else if (stateModel == "run")
            {
                currentSpeed = RUN_SPEED;
                if (keyState.IsKeyUp(Keys.LeftShift))
                {
                    blendFactor = 0;
                    stateModel = "runToWalk";
                    walk.SpeedFactor = 0;
                }
                foreach (BonePose p in poses)
                {
                    p.CurrentController = run;
                    p.CurrentBlendController = null;
                }
            }
            else if (stateModel == "runToWalk")
            {
                blendFactor += .05f;
                if (blendFactor >= 1)
                {
                    blendFactor = 1;
                    walk.SpeedFactor = 1;
                    stateModel = "walk";
                }
                double factor = (double)run.ElapsedTime / run.AnimationSource.Duration;
                walk.ElapsedTime = (long)(factor * walk.AnimationSource.Duration);
                currentSpeed = WALK_SPEED + (1f - blendFactor) * (RUN_SPEED - WALK_SPEED);
                foreach (BonePose p in poses)
                {
                    p.CurrentController = run;
                    p.CurrentBlendController = walk;
                    p.BlendFactor = blendFactor;
                }

            }

            else if (stateModel == "attack0")
            {
                attak.SpeedFactor = 2;
                blendFactor += .5f;
                if (mouseState.LeftButton == ButtonState.Released)
                    stateModel = "idle";

                RunController(dwarfAnimator, attak);
            }

        }

 

 

Q1 : So , I want to change that , to become animated based on Machine state AI , for example if I am close enough then attack and so on !!
Q2 : I have problem with modifying the xml file used for the model  , as the animation for "beast.x" model not animated like the one used for "dwarfmodel.x" , I know it's hard to understand my questions smile.png but say what you want smile.png

 

How to change making my enemy animate based on key Input to become animate based on some AI behaviours ( for example if Hero close enough then attack not it key.w then attack !! )

Edited by mrmohadnan
0

Share this post


Link to post
Share on other sites

in addition to is being said :

the animations ( walk , run , couch , idle , attack ) are not runs well , but instead two of them are loaded correctly (walk , idle ) ?? what do you think about this problem ?

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0