1 registered members (AndrewAMD),
742
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
complex animations in model
#301250
12/09/09 07:32
12/09/09 07:32
|
Joined: Jul 2009
Posts: 40
enrike
OP
Newbie
|
OP
Newbie
Joined: Jul 2009
Posts: 40
|
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
|
|
|
Re: complex animations in model
[Re: enrike]
#301410
12/10/09 10:45
12/10/09 10:45
|
Joined: Oct 2008
Posts: 23
ApenasEu
Newbie
|
Newbie
Joined: Oct 2008
Posts: 23
|
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.
Last edited by ApenasEu; 12/10/09 10:53.
|
|
|
Re: complex animations in model
[Re: ApenasEu]
#301486
12/11/09 02:24
12/11/09 02:24
|
Joined: Jul 2008
Posts: 1,178 England
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
store all the animation names and animation speeds in arrays, then pass that to an animation_handler to control all anims
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*
|
|
|
Re: complex animations in model
[Re: MrGuest]
#301503
12/11/09 08:05
12/11/09 08:05
|
Joined: Jul 2009
Posts: 40
enrike
OP
Newbie
|
OP
Newbie
Joined: Jul 2009
Posts: 40
|
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
Last edited by enrike; 12/11/09 09:23.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|