Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by dr_panther. 05/18/24 11:01
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, dr_panther), 724 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
complex animations in model #301250
12/09/09 07:32
12/09/09 07:32
Joined: Jul 2009
Posts: 40
E
enrike Offline OP
Newbie
enrike  Offline OP
Newbie
E

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] #301295
12/09/09 15:03
12/09/09 15:03
Joined: Oct 2008
Posts: 23
A
ApenasEu Offline
Newbie
ApenasEu  Offline
Newbie
A

Joined: Oct 2008
Posts: 23
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.

Re: complex animations in model [Re: ApenasEu] #301396
12/10/09 08:27
12/10/09 08:27
Joined: Jul 2009
Posts: 40
E
enrike Offline OP
Newbie
enrike  Offline OP
Newbie
E

Joined: Jul 2009
Posts: 40
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.

Re: complex animations in model [Re: enrike] #301410
12/10/09 10:45
12/10/09 10:45
Joined: Oct 2008
Posts: 23
A
ApenasEu Offline
Newbie
ApenasEu  Offline
Newbie
A

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
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

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

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*

Re: complex animations in model [Re: MrGuest] #301503
12/11/09 08:05
12/11/09 08:05
Joined: Jul 2009
Posts: 40
E
enrike Offline OP
Newbie
enrike  Offline OP
Newbie
E

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.
Re: complex animations in model [Re: enrike] #301532
12/11/09 13:46
12/11/09 13:46
Joined: Jul 2009
Posts: 40
E
enrike Offline OP
Newbie
enrike  Offline OP
Newbie
E

Joined: Jul 2009
Posts: 40
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!


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1