• Create Account

.X file with animation clips

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

Like
0Likes
Like

Posted 17 May 2013 - 03:09 AM

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 )

Edited by mrmohadnan, 17 May 2013 - 03:10 AM.

#2belfegor  Crossbones+   -  Reputation: 2493

Like
3Likes
Like

Posted 17 May 2013 - 03:19 AM

The easy way is the old DX utility mview (in attachment).

Note that it doesn't support meshes with tanget/binormals, and some other cases.

First you open your mesh, then choose "Add Animation" (load X file with same mesh but different animation)  and repeat process for all.

Under "Animations" you should see the list of all animations that you have added.

Attached Files

Edited by belfegor, 17 May 2013 - 03:22 AM.

Like
1Likes
Like

Posted 17 May 2013 - 03:27 AM

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

Like
0Likes
Like

Posted 17 May 2013 - 04:46 PM

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

}

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 :/

Like
0Likes
Like

Posted 18 May 2013 - 11:54 AM

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 ?

Like
0Likes
Like

Posted 18 May 2013 - 12:24 PM

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 );
}
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;
}
}
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;
}
}
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);
}
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);
}
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 but say what you want

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, 18 May 2013 - 02:00 PM.

Like
0Likes
Like

Posted 18 May 2013 - 02:50 PM

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 ?

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS