complex animations in model

Posted By: enrike

complex animations in model - 12/09/09 07:32

hi

i have this model from Maya with a set of animations with gestures (waving, jumping, dancing...). It also has a basic idle position animation. Each gesture animation has three steps: "start" / "loop" / "end". The model is controlled from gamepad so when the user presses button number 1 the model goes from idle position to animation number 1 doing first the "start" step of the animation, then it enters the "loop" step and it keeps cycling that step until the button is released, at this point it goes to "end" step of the animation and finally goes back to idle position.

So each frame I check which step of the animation I am and do different things depending on the step of the animation I am. I cannot do everything in one while (1){} because it blocks other things happening at the same time.

This is for start and end steps of animation
ent_animate(my, newlabel, animP, ANM_ADD);
animP += speed * time_step; // step

For the loop step of the animation i use
ent_animate(my, newlabel, animP, ANM_CYCLE);
animP += speed * time_step;
animP %= 100;

and this for blending between different steps of animations

ent_animate(my, oldlabel, 100, ANM_SKIP);
ent_blend(newlabel, 0, blendP);
blendP += blend_factor * speed * time_step;
blendP %= 100;


My problems is that because of the way ent_animate works with percentages, all animations must be equal length, otherwise short animations are very fast and long animations very slow. This is very limiting for the animators and for the design of the character so I need to find a way to have different lengths that are played with exactly same speed they are designed in Maya.

My solution was to cycle the animations with
my.frame = nextframe;
where next frame is an index that increases each frame. But I dont like this because I need to store manually in arrays the "keyframes" of each animation step and the code does not look nice.

I hope this explanation is clear enough, i am not sure... Any ideas are welcome. Thanks!

enrike
Posted By: ApenasEu

Re: complex animations in model - 12/09/09 15:03

I am still a newbie to all this so forgive me if this is all munbo jumbo.

So, your issue is having a fixed speed animation for different animations with a varying ammount of keyframes, right?
What you do with nextframe is steping from one keyframe to the next directly without bothering with percentages, is that right?

So you could also just put a number in the percentage calculation that makes a fixed percentage for all animations be diferent for each animation

So for example: animP += speed * animation_length_factor * time_step;

You would have to store in memory each of the animations length, but you would still have speed as controling all animations speed, but then animation length influencing each particular speeds.

Sorry if this is all garbage, just ignore.
Posted By: enrike

Re: complex animations in model - 12/10/09 08:27

i did something like this but i have up to 24-30 animations for character each of them with three different steps (30*3 = 90). I have to control the speed of each of them so it becomes a big headache to do this the way you suggest because they all have small differences. It works for 3 or so animations but i have far to many.
Posted By: ApenasEu

Re: complex animations in model - 12/10/09 10:45

Cant you sort them into 4-5 categories or some such? surely for example most start and end animations are reasonably the same length no?

EDIT: Even if not 4-5, if you got them into 10-20 categories or so it would still be a huge step down from so many individual animations.
Posted By: MrGuest

Re: complex animations in model - 12/11/09 02:24

store all the animation names and animation speeds in arrays, then pass that to an animation_handler to control all anims

Code:
TEXT* txt_anim_names = {
   string("idle_start", "idle_loop", "idle_stop") //etc...
}

var anim_speed[30] = { 3, 2, 3.5 };

then just pass the anim number thro the handler and reference as needed
void anim_handler(int anim_type){
   animP += anim_speed[anim_type] * time_step;
   ent_animate(me, (txt_anim_name.pstring)[anim_type], animP, ANM_CYCLE);
}


btw, you're best off storing the animP as one of the entitys' skills
hope this helps

*tested, though written from memory*
Posted By: enrike

Re: complex animations in model - 12/11/09 08:05

i am thinking that maybe i just need to store the length in frames of each of the steps, then calculate based on that length how long the increase should be for each it in order to get to 100%, this way all would be equal length.

blendP += own_step * speed * time_step;
blendP %= 100;

is there a way to know how many frames there are in a animation? this way i would not need to store anything. i could calculate it on the fly. ent_frames just gives the total num of frames

Posted By: enrike

Re: complex animations in model - 12/11/09 13:46

it does work actually. i do

own_speed = 100.0/own_frame_length;
ent_animate(my, newlabel, animP, ANM_CYCLE);
animP += own_step * speed * time_step;
animP %= 100;

where own_frame_length is the num of frames of each piece of animation, this normalises all animation speeds. So i just need to store the lengths in an array for each animation .

var amin_A_lengths[3] = {12, 24, 8}; // start, loop, end

great!
© 2024 lite-C Forums