New animation module

Hey all,

Well, I've recently (as of tomorrow :D) resumed working on the skeletal animation and I will actually change how the whole module is working by adding channels to animations.
Nothing groundbreaking there but it was definitely a concept missing to orx's animation system.

As I'm doing this, I might as well try to make the definition of animations and animation graphs easier in config. That will break backward compatibility but I think it's really worth it as defining those is really extremely annoying (and verbose) right now.

I'm posting here to get suggestions from all of you. Any idea?

As a reminder, here's what we currently have:
[AnimationSetTemplate]
AnimationList = AnimationTemplate1#AnimationTemplate2#...
LinkList      = LinkTemplate1#LinkTemplate2#...
Frequency     = <float>

[AnimationTemplate]
DefaultKeyDuration = <float>
KeyData<N>         = GraphicTemplate
KeyDuration<N>     = <float>
KeyEventName<N>    = <string>
KeyEventValue<N>   = <float>

[LinkTemplate]
Source      = SourceAnimationTemplate
Destination = DestinationAnimationTemplate
Priority    = <int>
Property    = immediate | cleartarget

Now what do you think of something more compact, like:
[AnimationSetTemplate]
AnimationList = AnimationTemplate1#AnimationTemplate2#...
Frequency     = <float>

Defining the links directly:

Anim1-Anim2 = immediate|cleartaget|low|medium|high(priority)
...

[AnimationTemplate]
ChannelList = EventChannel # SkeletonChannel # GraphicChannel

[EventChannel]
Type = Event
0.5 = StepLeft (# Value)
1.0 = StepRight (# Value)

[GraphicChannel]
Type = graphic
0.1 = AnimFrame1
0.3 = AnimFrame2
...

[SkeletonChannel]
Type = skeleton
0.2 = Child1Frame1 # ... # ChildNFrame1

[ChildFrame]; This is the transformation node for 1 bone at a given key
Position = <Vector>
Scale = <Vector>
Rotation = <Float>

That's basically it. No more separate link sections, everything will be within the AnimSet section.
And using timestamps as keys for all the channel data.

In the same time I'd add similar syntax for the TimeLine feature which are basically scripts/sequences attached to an object that can triggers events over time. Some of those events will be understood by orx like CreateObject, Transform, AddTimeLine, AddSound, AddFX, etc...

But more details in another post. :)

Any suggestion is welcome. Sooner than later as my plans are to begin implementing the new anim system this week end. :D

Comments

  • edited April 2012
    So if I understand with the Timeline feature you'll be able to have bone animations in the .ini file and set the position and rotation at different times and orx will interpolate with the Transform function.

    Here's a suggestion : would it be possible to have a better interpolation than a linear interpolation, like a spline interpolation with a handle on each point ? I have no idea how heavy it is to compute btw.

    I'm saying this because an animation with spline interpolation looks way better than a linearly interpolated one, and in any decent animation program you can animate with splines. But if you don't plan to include it it's ok because you can still split your splines into many linear curves in the animation program and then export to a config file for orx.
  • edited April 2012
    Well the TimeLine is a separate entity and isn't related with the animation system at all, I should probably not have mentioned it here. :)

    But yes, I can support more than one type of interpolation for skeletal animation. My thought was to implement at first linear and smoothstep/smootherstep, but splines are possible.

    Orx already supports Catmull-Rom splines, I just don't know how expensive those interpolations will be in the context of animations.

    I have to admit I haven't seen any 2D skeletal animation using anything but linear interpolation, but again I didn't search too much into it for now. Do you have any examples/links I could look at?

    Grey already mentioned Spriter to me and I know there are a few other out there.
  • edited April 2012
    My plan is to use Softimage for my project, it's a powerful 3d animation program and it's easy to script and export with it. I'm leaving to Corsica tomorrow, but I'll try to make a small animation to show the differences between interpolations and export the values. It'd be nice to see the smoothstep interpolation too, it'd probably be enough in most cases.

    In your config file I'm not sure to understand how the skeleton bones are tied together. It seems that all the bones of a chain need to be keyed at the same time. It's a major drawback for an animator not to be able to key elements independently. A principle is to have the animation of the elements overlap, like if I swing my arm my hand will rotate with a delay for example. I suggest that the lists of keys are done per bone rather than per whole skeleton chain.

    Also you shouldn't force the position and the rotation to be keyed together because then you can't have overlapping animations. It's a basic principle.

    However it's ok to force the 3 coordinates of the position to be keyed together because that's how you animate. And it's probably ok to have one type of interpolation for a whole set of keys even though animation programs let you switch from key to key. The only cases where you want to switch from spline to linear is when you have a physical shock or when the object was moving and then bounces on something. So if you have to animate this case anyways you can just have your whole animation curve in linear it's not a big problem.

    A small suggestion too, but I haven't really thought about it, maybe you could have a time modifier for skeleton chains. For example if you have a walk animation on both legs made for when the character is at cruising speed, when he's decelerating you could just reduce the time modifier so his feet will still follow the ground. But I haven't used this clock function so I don't know if it's already easy to do.

    Good luck and happy Easter !
  • edited April 2012
    grumly wrote:
    My plan is to use Softimage for my project, it's a powerful 3d animation program and it's easy to script and export with it. I'm leaving to Corsica tomorrow, but I'll try to make a small animation to show the differences between interpolations and export the values. It'd be nice to see the smoothstep interpolation too, it'd probably be enough in most cases.

    I've never used Softimage myself as all the studios I've worked for over those last 12 years were either using 3DS Max or Maya. I also played a bit with Blender at home, but that's about it.

    As for interpolations, I'm pretty sure most of, if not all, the games I've worked on were using lerp/slerp for interpolating keys.
    I'm not 100% sure for Resistance: Burning Skies, but I'll check tomorrow. If I remember correctly, Splinter Cell: Resistance was only using rotations transforms and didn't even support translations/scales.

    That being said I'm all for supporting different interpolation types, probably something in the end like linear, cubic (smoothstep) and catmull-rom.
    In your config file I'm not sure to understand how the skeleton bones are tied together. It seems that all the bones of a chain need to be keyed at the same time. It's a major drawback for an animator not to be able to key elements independently. A principle is to have the animation of the elements overlap, like if I swing my arm my hand will rotate with a delay for example. I suggest that the lists of keys are done per bone rather than per whole skeleton chain.

    I haven't settled on that one yet. A lot of engines/formats (such as MD5) have this restriction in order to have a more efficient mixer (and allow easier reverse playback), so I need to weight the pro and cons.

    From the animator standpoint it shouldn't have any impact at all: adding a key generally use the current interpolated values of the skeletons before modifications, even if you want to only modify a couple of bones. It's only a matter of exported data at this point.
    Also you shouldn't force the position and the rotation to be keyed together because then you can't have overlapping animations. It's a basic principle.

    I'm not sure what you mean by overlapping animations. The way I understand it you are referring to additive animations, which I won't support in the first version (nor will I support blending/crossfades as it requires a multi-track mixer and orx currently has a single track one). Or did you mean something different? as there's no such requirement for additive animations.

    Anyway, there's will be no such requirement here, position, rotation and scale values are independent/optional.
    However it's ok to force the 3 coordinates of the position to be keyed together because that's how you animate. And it's probably ok to have one type of interpolation for a whole set of keys even though animation programs let you switch from key to key. The only cases where you want to switch from spline to linear is when you have a physical shock or when the object was moving and then bounces on something. So if you have to animate this case anyways you can just have your whole animation curve in linear it's not a big problem.

    A small suggestion too, but I haven't really thought about it, maybe you could have a time modifier for skeleton chains. For example if you have a walk animation on both legs made for when the character is at cruising speed, when he's decelerating you could just reduce the time modifier so his feet will still follow the ground. But I haven't used this clock function so I don't know if it's already easy to do.

    The frequency can be changed on the fly, that's already the case and will still be supported if that's what you're referring to.
    Also it's good to know that animations don't have to be exported with a fixed rate as it's still often the case in some engines.

    But again, keep in mind that the first iteration will not support any blending/fading and the goal is to support simple 2D skeletal animation which is still not very common for sprite-based (ie. non-vector) engines. :)
    Good luck and happy Easter !

    Thanks, same to you!
  • edited April 2012
    Hey guys, do you want to take a look at this?
    http://www.kickstarter.com/projects/539087245/spriter
    This looks interesting... not sure if it could help you implement your skeletal animation module or not.
  • edited April 2012
    I've tried the beta linked there a week or two ago and it felt very limited. Much more than what they show on their video at least. Hopefully the end product will be much better as a lot of people seem to be waiting for it. :)
  • edited April 2012
    I read about slerp and I finally understood what you wanted to do. I thought you were keeping the bones hierarchy while you break the chains and key each key individually on position and rotation at the same time, with absolute values. Now I understand why you want every key in a skeleton to be made at the same time.

    What I meant with "overlapping animations" is not animating on layers or mixing animations together, just that there's a delay between animations of each body part. For example a walking character will have the first bone of the leg keyed on rotation at time 0 and 10 and the second bone of the leg keyed at 2 and 12. If you keep the hierarchy it's just 2 keys on each bone. Now if you remove the bone hierarchy and key the absolute rotation and position you need keys at 0, 2, 10 and 12. For each bone that's 4 rotation keys and 4*3 keys for the coordinates of the position.

    And since the pelvis moves up and down and chains are all connected to it I think the whole upper body will need to have keys at the same time. Everytime you go down in the hierarchy and you want to add a delay on a bone that's a lot more keys you'll have to store.

    So now I learnt about slerp I think the game engines you mentioned revolve around using the slerp interpolation because it gives a nice round interpolation and you can animate without touching the animation curves so it's more productive regarding the quality wanted. But since bones aren't related anymore in the exported file you need to key a lot of things. I guess that's done by the exporter but that's still a lot of data. If you don't plan to use slerp interpolation I don't think it's a good idea to remove the hierarchy and have absolute keys for all the bones every time something is keyed.

    I just read forums and the wikipedia page of catmull rom and they say catmull rom is fast but the reason it isn't used too much is because it's hard to generate keys with handles. I fail to see why it's hard because in 3d animation programs you animate with splines from the start and there are curve fitting functions anyways. And if you use a 2d animation program that doesn't support splines you don't expect smooth curves anyways.

    I remember making animations for a Half-Life 1 mod. I checked the specifications and Half-Life was importing the bone hierarchy (in a text file for each bone you told who was the parent bone if any). Then each key stored both the relative position and rotation of the bone. Then in the game I believe it interpolated keys with smoothstep (the same format was used for Quake 1 but the interpolation in-game was linear).

    Setting keys was easy and the smoothness was nice but the big drawback was you couldn't tweak the ramp from one key to the next one because for every key the interpolation created a plateau. It's good only if you set keys like sawteeth but if you want to ramp differently you have to make many keys in between and it won't be as smooth. If you need to set many close keys anyways linear interpolation is smoother, it's closer to the curve you want.

    But now we have better animation tools than then. Catmull Rom splines would fix the ramp problem and also now we animate directly with splines so we can fit as many points on the curve as needed to make it look smooth with a linear interpolation.

    So I think a system like Half-Life/Quake 1 is a good option along with spline interpolation. It's easy to export keys or even copy paste them from your program. If the hierarchy was broken in your format you'd have to make a tool to create the missing keys and convert them into absolute values.

    I made a small run cycle animation if you want something to test your system. I didn't export any value I just made a looping video. I can export and provide the source if you want. In the animation there are rotation keys on every bone. The pelvis has position keys up and down, and the shoulders have position keys on both dimensions, to fake 3d.

    Download the video (click "télécharger ce fichier")

    28yA0.jpg
  • edited April 2012
    grumly wrote:
    What I meant with "overlapping animations" is not animating on layers or mixing animations together, just that there's a delay between animations of each body part. For example a walking character will have the first bone of the leg keyed on rotation at time 0 and 10 and the second bone of the leg keyed at 2 and 12. If you keep the hierarchy it's just 2 keys on each bone. Now if you remove the bone hierarchy and key the absolute rotation and position you need keys at 0, 2, 10 and 12. For each bone that's 4 rotation keys and 4*3 keys for the coordinates of the position.

    And since the pelvis moves up and down and chains are all connected to it I think the whole upper body will need to have keys at the same time. Everytime you go down in the hierarchy and you want to add a delay on a bone that's a lot more keys you'll have to store.

    Ah ok, I see what you mean. This shouldn't be required for the user (depending on which animation editor they use as those have their own requirements, of course), but if we end up needing a key to contain the info for the whole skeleton, the exporter should be able to make this conversion behind the scene. But I'll try to not have this requirement in code, depending on the complexity of supporting scrubbing/reverse play without those extra data.
    So now I learnt about slerp I think the game engines you mentioned revolve around using the slerp interpolation because it gives a nice round interpolation and you can animate without touching the animation curves so it's more productive regarding the quality wanted. But since bones aren't related anymore in the exported file you need to key a lot of things. I guess that's done by the exporter but that's still a lot of data. If you don't plan to use slerp interpolation I don't think it's a good idea to remove the hierarchy and have absolute keys for all the bones every time something is keyed.

    The idea was to reuse the hierarchy we naturally had with the objects (parent/children/siblings). However controlling them entirely from a single animation is probably going to be tricky. Still trying to define the best scenario for that without having to create support for a separate skeleton.
    I just read forums and the wikipedia page of catmull rom and they say catmull rom is fast but the reason it isn't used too much is because it's hard to generate keys with handles. I fail to see why it's hard because in 3d animation programs you animate with splines from the start and there are curve fitting functions anyways. And if you use a 2d animation program that doesn't support splines you don't expect smooth curves anyways.

    Well there are a bunch of other splines that makes it much more easy for precisely controlling the curve than the catmull-rom. Catmull-rom is interpolating (the curve is going through all the control points, making it hard to control the tangents/acceleration) whereas other splines might be approximating (the curve is not going through all the control points).
    I remember making animations for a Half-Life 1 mod. I checked the specifications and Half-Life was importing the bone hierarchy (in a text file for each bone you told who was the parent bone if any). Then each key stored both the relative position and rotation of the bone. Then in the game I believe it interpolated keys with smoothstep (the same format was used for Quake 1 but the interpolation in-game was linear).

    Setting keys was easy and the smoothness was nice but the big drawback was you couldn't tweak the ramp from one key to the next one because for every key the interpolation created a plateau. It's good only if you set keys like sawteeth but if you want to ramp differently you have to make many keys in between and it won't be as smooth. If you need to set many close keys anyways linear interpolation is smoother, it's closer to the curve you want.

    That's indeed a side effect of the smooth step curve. However the smoother step one suggested by Ken Perlin doesn't have this issue and is also supported by orx.
    But now we have better animation tools than then. Catmull Rom splines would fix the ramp problem and also now we animate directly with splines so we can fit as many points on the curve as needed to make it look smooth with a linear interpolation.

    That's true but it really depends on which animation editor are going to be used the most for 2D animation, so I guess I'm bound to support all the different interpolation kind, just in case.
    So I think a system like Half-Life/Quake 1 is a good option along with spline interpolation. It's easy to export keys or even copy paste them from your program. If the hierarchy was broken in your format you'd have to make a tool to create the missing keys and convert them into absolute values.

    The idea is not to use absolute values, only relative. It's just that the skeleton is not in 1 piece right now, but all the pieces are still relative to their parent.
    I made a small run cycle animation if you want something to test your system. I didn't export any value I just made a looping video. I can export and provide the source if you want. In the animation there are rotation keys on every bone. The pelvis has position keys up and down, and the shoulders have position keys on both dimensions, to fake 3d.

    Download the video (click "télécharger ce fichier")

    28yA0.jpg

    Thanks! That's going to be very useful for testing purposes. :)

    However I couldn't download the file, the captcha on free was empty no matter what I tried (asking for a new one or the audio version didn't work either). :(
    Any change of a dropbox link or anywhere else?
    Or maybe it's only a temp issue on free, I'll retry tonight.
  • edited April 2012
    Looks like I was wrong on many points. I feel awkward having written such a big essay for nothing :laugh:

    Anyways I looked at my animation and most keys are kind of aligned already, so it's not hard to optimize by hand anyways.

    I tweaked a bit the animation and included the file just in case. I think I found a great hosting site for it :dry:.

    About the captcha on Free, when it's your provider you don't see anything it downloads automatically. They announced they created their own captcha service where the captcha is inside the ad and you have to look at the ad to see it. Maybe it didn't get popular if you can't see it.

    https://forum.orx-project.org/uploads/legacy/fbfiles/files/orxanimtest.zip
  • edited April 2012
    grumly wrote:
    Looks like I was wrong on many points. I feel awkward having written such a big essay for nothing :laugh:

    Ahah well, my explanations tend to be more confusing that I'd like them to be, unfortunately! ^^
    Anyways I looked at my animation and most keys are kind of aligned already, so it's not hard to optimize by hand anyways.

    I tweaked a bit the animation and included the file just in case. I think I found a great hosting site for it :dry:.

    Hehe, yes, didn't think of that myself. I must be much more tired than I thought! :) Thanks again!
    About the captcha on Free, when it's your provider you don't see anything it downloads automatically. They announced they created their own captcha service where the captcha is inside the ad and you have to look at the ad to see it. Maybe it didn't get popular if you can't see it.

    https://forum.orx-project.org/uploads/legacy/fbfiles/files/orxanimtest.zip

    Ooooh, that would make sense then, I guess AdBlock is a bit too aggressive in that case and doesn't know about free's treachery! ;)
  • SASSAS
    edited May 2012
    how do I erase this comment?
    by the way just concerning the adition below i use mac (because i got a freebee and am cheap so I won't pay to replace it) thanks for the mac tutorials :)
  • edited May 2012
    Hi SAS and welcome here!

    Well I'm not sure what you are expecting to find here actually, so apologies if I didn't understand your message correctly.

    This thread is about supporting 2D skeletal animation in orx which is a 2D-oriented game engine (mostly sprite base hence this thread). There's no editor for orx (yet).

    If you're looking for a sprite editor, have you tried softwares such as GraphicsGale?

    That being said, orx (as a game engine), supports any blending/rotation combinations as it's using 3D OpenGL behind the scene.

    Hope this helps! :)
  • edited July 2012
    This sounds interesting,

    I saw a project on kickstarter that, without reading this whole thread, creates sprites for this type of animation.

    http://www.kickstarter.com/projects/539087245/spriter

    If there's support for this tool, maybe creating an export plugin for it could be worth it.
  • edited July 2012
    Yep Spriter got famous lately but there are other similar programs out there.

    As for the export plugin, it's a good idea. That reminds me if someone wants to write an export plugin for Physic Editor and/or Texture Packer, just let me know.
  • edited September 2012
    Any new developments on this front?
Sign In or Register to comment.