Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » 2D Skeletal Animation. Going in the right way?

This thread is locked; no one can reply to it. rss feed Print
2D Skeletal Animation. Going in the right way?
Dario ff
Member #10,065
August 2008
avatar

I decided Skeletal animation is the best choice for my actual project. I wrote up something today and I wanted to know if you think my approach is on the right track.

Controls:

Left Click to move the selected joint around.
Right click on the joints(they will appear if you hover the mouse above'em), to select them(will change from purple to blue).

Press the 'P' Key for 'playing' the animation on the 'skeleton'.
Press the 'S' Key for stopping the animation on the 'skeleton' and going back to the first frame.

Source and Binary

A screenie(though there's little to show off, but some people need one to keep reading)

599941

Ok, I'm not looking for something really simple or overly complex realistic engine.
What I'm trying to achieve(and mostly I already have in the actual test):

  • Limbs(sprites) that are joined by skeletal joints, and animate smoothly along keyframes.

  • Variable length bones and constraints that limit the distance between each other.

  • Constant and smooth Keyframing allowing looped and ping pong animations.

If you don't wish to read the source code to find out my approach, then here it is an overview: Basically, there is an 'skeleton' class that contains a list of 'bone' objects. These 'bones', are merely points, which are later rendered to give the impression as if they were actually body parts.
Each bone has a list of childs(bones that root from him) and a root pointer(its parent 'bone'). Every time a bone is moved, it's checked if it's in range of its root. If it doesn't, then it will be forced to stay in range. Moving a bone moves its children, but can't modify its root.

Do you think this system is good enough? Or will it have some serious problems when I get deeper with it?

EDIT: Is it skeletal or skeletical?

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

GullRaDriel
Member #3,861
September 2003
avatar

For the lexical part, skeletal sounds good to me, but I'm not a native English speaker.

I had good time reading these threads about GRIM and a demo using it.
Have a look here and here.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Dario ff
Member #10,065
August 2008
avatar

^ Yeah, I knew about GRIM, and tried it out a while ago, but I didn't like it very much. Also, I enjoy programming anything that I think I'm capable enough of doing before lurking on the internet for something similar and copy it.

No comments on the system? Is the 'point' and 'joints' approach good enough?

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

OnlineCop
Member #7,919
October 2006
avatar

Can't get it to compile on Mac, so can't check it out. Sorry :-/

I'd suggest that a bone can affect its root, though. Tug on someone's arm, and it should pull the upper portion of the torso slightly. If I can get it to go for me, I'll let you know my results.

Dario ff
Member #10,065
August 2008
avatar

^^ You're right. It should modify it's root, but only in the following situation. This bones can change their length in real time(for simulating a 3D situation in 2D), but maybe I should make two types of keyframes(like in many other programs). A Move keyframe, which would affect root and children, and a Scale keyframe, which would only modify the children.

Still, I don't know if I need something that complex to get the animations right, but neverthless, I enjoy a good challenge ;)

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

Go to: