maybe this will help
http://content.gpwiki.org/index.php/...c_Bones_System
maybe this will help
http://content.gpwiki.org/index.php/...c_Bones_System
This is my solution.
A few words of introduction: We operate only on angles (one bone = one angle) and one start point (X0, Y0) from figure B (picture 1) - this is the only data that we need to read and write to the file (for one frame of animation).
Additionally, you can have a bone length L, but this is unnecessary when you have a human bones (ideal human proportion) or you can get L from sprite length.
Algorithm:
- starting from the point (X0, Y0), Figure B (picture 1).
- we have angle (a), length of bone (L1), start point (X0,Y0), so we can calculate the point (X1, Y1). (X1, Y1) is a central position of our next sprite (be sure your sprite can be rotated from a center (picture 2, figure A))
- if we have (X1, Y1), (b) and (L2), we can calculate (X2, Y2) and next (X3, Y3)
- we do this same for left and right leg (figure C), and left and right hand (figure D)
Optimization:
This method requires a large number of calculations, but it does not need a lot of resources to read and write. To better work with animation, we can use KeyFrames - write data only for KeyFrames, and the rest is calculated automatically (picture 2, Figure B). It's not difficult to calculate AutoFrames if we operate on angles.
Result (AutoFrames = 5):
http://www.youtube.com/watch?v=igSRP0J5q_I
Last edited by mobilus; 09-03-2012 at 11:46 PM.
Thanks Mobilus!
Your info will be very useful! =)
I think I have understood! I will try to make something here!
Thanks
Cezar Wagenheimer from Green Sauce Games
Programmer of Druids - Battle of Magic, Abra Academy, Abra Academy - Returning Cast, Rabbit Jump, Dreams of a Geisha and Heroes from the Past: Joan of Arc
Wagenheimer's Game Development Blog
How do you calculate the new X1,Y1 position?
I have the original X0, Y0 values and X1, Y1 Values. And the length of Bone, L.
This almost works for me. It only works if the Initial Angle between (X0,Y0) and (X1,Y1) is 0 otherwise I got a small difference after the rotation. And my Math does not help!Code:X1 := X0 + L * Cos(DegToRad(Angle-90)); Y1 := Y0 + L * Sin(DegToRad(Angle-90));
Do you have any advice?
Cezar Wagenheimer from Green Sauce Games
Programmer of Druids - Battle of Magic, Abra Academy, Abra Academy - Returning Cast, Rabbit Jump, Dreams of a Geisha and Heroes from the Past: Joan of Arc
Wagenheimer's Game Development Blog
My first advice is to not work with Degrees (Animation.zip):
Your angle must be in the range from 0 to 2*Pi (Figure A, Picture 1):Code:var S, C: Single; SinCos(Angle, S, C); X1:= X0 + L * S; Y1:= Y0 - L * C;
If Angle > 2*Pi then Angle:= Angle - 2*Pi;
If Angle < 0 then Angle:= Angle + 2*Pi;
(but this should not happen if your animation is prepare properly)
Figure B and C presents the problem that you can have by using Auto Frames.
In my case, one minute of animation takes 40 KB with Auto Frames and 200 KB without Auto Frames - this is still not much, so it is not necessary to implement Auto Frames.
Bookmarks