Help - Search - Members - Calendar
Full Version: 2d Skeletal Animation System
Game Maker Community > Working with Game Maker > Advanced Users Only
Aedous
Hey guys, ive been away for a while and ive been working on a new 2D skeletal animation system, im also willing to release this system to the public so that anyone else who wishes to have a complete 2D Skeletal Animation system in thier game, plus have the editor to go along with it can use it.

So far i have the positioning of "Nodes" which are the joints to create the skeleton, and the parenting of these "Nodes" work well together. Im using a list data structure to store the children of "Nodes" on each parent.

Heres a breif pseudo image of what it looks like
CODE

[Node]---->[Node2]--->[Node3, Node4, Node5].


At the moment im updating the positions of each node according to the parent, by getting the offset of the child, and then adding that to the actual position of the parent, and it seems to work well without any bugs so far.

My problem is i cant get the Rotation to work well, i tried using the lengthdir functions and it sort of achieves the effect, but it gets really buggy, if anyone could post up an algorithm on Rotating a parent and then having its children update their rotation along the direction of the parent.
Basically the effect im trying to achieve is that of an ik solver, the ones similar to those found on 3d programs, but on a 2d object.

Thanks.
ragarnak
QUOTE (Aedous @ Aug 20 2009, 10:14 PM) *
Hey guys, ive been away for a while and ive been working on a new skeletal animation system,
If its only a animation you are after than simply using the "d3d_transform_add_...(...)" methods will work fine.

If you are after getting the actual coordinates of each joint than I suggest you do a search for 3D matrix-multiplications (which is what GM uses internally, but which results are not exposed to the user).

Hope that helps.
Aedous
QUOTE (ragarnak @ Aug 20 2009, 09:33 PM) *
If its only a animation you are after than simply using the "d3d_transform_add_...(...)" methods will work fine.

If you are after getting the actual coordinates of each joint than I suggest you do a search for 3D matrix-multiplications (which is what GM uses internally, but which results are not exposed to the user).

Hope that helps.


Thanks for the reply, but forgot to add that this skeletal system is for 2d animation, not 3d. oops.
ragarnak
QUOTE (Aedous @ Aug 20 2009, 10:50 PM) *
Thanks for the reply, but forgot to add that this skeletal system is for 2d animation, not 3d. oops.
In that case I suggest you post the problematic code (something that is allso mandated by this subforums rules whistle.gif ) and explain what, according to you, the problem is : what does it do now, and what should it be doing.

rwilson
I was working on this awhile back and came up with this:

CODE
var i,link,dist,dir;
for (i=0;i<ds_list_size(links);i+=1)
{
link=ds_list_find_value(links,i)
dist=point_distance(xprevious,yprevious,link.x,link.y)
dir=point_direction(xprevious,yprevious,link.x,link.y)
link.image_angle+=image_angle-dir_p
link.direction+=image_angle-dir_p
link.x=x+lengthdir_x(dist,dir+image_angle-dir_p)
link.y=y+lengthdir_y(dist,dir+image_angle-dir_p)
}

It takes the change in the caller's position and direction and applies it to all the instances in ds_list(links)
Tahnok
QUOTE (Aedous @ Aug 20 2009, 01:14 PM) *
[...]
My problem is i cant get the Rotation to work well, i tried using the lengthdir functions and it sort of achieves the effect, but it gets really buggy, if anyone could post up an algorithm on Rotating a parent and then having its children update their rotation along the direction of the parent.
Basically the effect im trying to achieve is that of an ik solver, the ones similar to those found on 3d programs, but on a 2d object.
[...]
I find this statement confusing. It seems like if you were wanting true IK you would want to have be able to pull and rotate a child and have it's parent bones follow, not the other way around. So I'll assume you meant the first part, and just misunderstood IK.

Anyway, I've found that it's important to work from the center out with this kind of stuff. You have to start at the origin of the character (where all bones start from) and start updating angles from there, otherwise the lower down bones wont have the correct angles to set themselves. Also, it's important to keep two variables (and I think this may be the issue you're having). You have to keep a variable that contains the offset the bone is supposed to have from the parent bone and a variable containing the actual current angle. The offset angle is set when you manually rotate the bone, not when you rotate the parent bones though. The actual angle is the one that is calculated based on the parent bones. Basically it should be the offset angle plus the parent's actual/calculated angle. And now you see why it's important to calculate these angles from the inside out.

I hope that makes sense. Feel free to catch me on IM (messangers listed in profile) if you need further explanation.

Finally, I have to plug my own skeleton program, Skeleton. Maybe it already has the functionality you're looking for.
Aedous
QUOTE (rwilson @ Aug 20 2009, 10:43 PM) *
I was working on this awhile back and came up with this:

CODE
var i,link,dist,dir;
for (i=0;i<ds_list_size(links);i+=1)
{
link=ds_list_find_value(links,i)
dist=point_distance(xprevious,yprevious,link.x,link.y)
dir=point_direction(xprevious,yprevious,link.x,link.y)
link.image_angle+=image_angle-dir_p
link.direction+=image_angle-dir_p
link.x=x+lengthdir_x(dist,dir+image_angle-dir_p)
link.y=y+lengthdir_y(dist,dir+image_angle-dir_p)
}

It takes the change in the caller's position and direction and applies it to all the instances in ds_list(links)

Hey thanks ill give that a go and see what happens.

QUOTE (Tahnok @ Aug 20 2009, 10:49 PM) *
Finally, I have to plug my own skeleton program, Skeleton. Maybe it already has the functionality you're looking for.

I had a look at your animation system Tahnok and it is what im looking for, however i can only animate static gifs, and bmps, i cant take the actual coordinates and have them put into the game. This is a problem because for this system i want to be able to animate in a seperate editor, and then load those files into gamemaker to get the real time coordinates, so i can then add items to a bone for example positioning armour directly onto an arm and have that update in real time which in effect will help customization of characters and also some sort of visual character progression.
Your system works great and very well.. and i would like to know how you achieved it.
Tahnok
QUOTE (Aedous @ Aug 20 2009, 03:14 PM) *
[...]
QUOTE (Tahnok @ Aug 20 2009, 10:49 PM) *
Finally, I have to plug my own skeleton program, Skeleton. Maybe it already has the functionality you're looking for.

I had a look at your animation system Tahnok and it is what im looking for, however i can only animate static gifs, and bmps, i cant take the actual coordinates and have them put into the game. This is a problem because for this system i want to be able to animate in a seperate editor, and then load those files into gamemaker to get the real time coordinates, so i can then add items to a bone for example positioning armour directly onto an arm and have that update in real time which in effect will help customization of characters and also some sort of visual character progression.
Your system works great and very well.. and i would like to know how you achieved it.
Actually, you can. You can either use Skeleton Lite (a standalone render engine, source included) or look at the save file documentation to pull the data you need out. Both of those links are within the main Skeleton topic's main post.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.