Investigating the animation system
Page 1 of 2 Goto page 1, 2  Next
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Sun, 5th Feb 2012 22:21    Post subject: Investigating the animation system
What features should our animation system have? Post your ideas and findings here.

Regarding the basic bone structure:

* Each animated char should have at least a root node.

* Each node can have one or multiple child nodes.

* Each node features the following attributes:

** A 3DPoint defining the position relative to the parent nodes hinge (values between 0 and 1, null for the root element, 3D because we can store this way the z-drawing order of the nodes) [node.posRelParHinge]

** A 2DPoint defining the point around which the node rotates (basically it's hinge, again values between 0 and 1) [node.hinge]

** A 2DPoint defining the action point(basically where other entities, like for example bullets, smoke etc. would emit from, again values only between 0 and 1) [node.action]

** 3 float defining the current rotation value, the minimum rotation value and the maximum rotation value (to limit movement of hinges... This could also be a 3D Point) [node.rotation, node.minRotation, node.maxRotation or just node.rotation as 3DPoint]

The size of the nodes should come from the sprites they are based on. For this we still need to write a sprite/tile based animation system.

I'll write more on my thoughts regarding the animation system later on Smile
Back to top
garus
VIP Member



Posts: 34200

PostPosted: Sun, 5th Feb 2012 22:27    Post subject:
snip


Last edited by garus on Tue, 27th Aug 2024 21:23; edited 2 times in total
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Sun, 5th Feb 2012 22:28    Post subject:
Well basically this'll end in some sort of class outline, but once this is done, the actual developing of this shit should be "piss easy" Very Happy


Last edited by PumpAction on Sun, 5th Feb 2012 22:53; edited 2 times in total
Back to top
garus
VIP Member



Posts: 34200

PostPosted: Sun, 5th Feb 2012 22:31    Post subject:
snip


Last edited by garus on Tue, 27th Aug 2024 21:23; edited 1 time in total
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 22:34    Post subject:
garus wrote:
About the export formats of C4D or others. Do they output in some simple text files or more complex stuff?


Don't know about c4d, but I think XMLs could do it for other programs.

Anyway, I think we're getting a bit ahead of ourselves, but no problem with that. Once I'm done testing, I will post more.
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 22:37    Post subject:
garus wrote:
I agree with all the above. One other thing I was thinking about is: transitions between states. For example when a character is running and we want it to stop. We can't just reset the movement animation. Needs some kind of smooth transition from one state to another (legs returning to "stance" position etc.)

Also animation divided into at least two sections: upper body and lower body. So we can run (legs move) and gun at the same time (aiming with guns or something). Much like in Max Payne (only easier Very Happy).


The transition should in essence not be a problem, it's doable. Since keyframe animation works with interpolation, once the walk button is no longer pressed, the next keyframe should be a complete halt (instead of the next keyframe from the run animation) in X amount of time, until that time the engine interpolates the animation steps.
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Sun, 5th Feb 2012 22:54    Post subject:
garus wrote:
I agree with all the above. One other thing I was thinking about is: transitions between states. For example when a character is running and we want it to stop. We can't just reset the movement animation. Needs some kind of smooth transition from one state to another (legs returning to "stance" position etc.)


Ofc, that should be something that should be solved by the animation system. What I posted up until now, is just the very basic bone structure. How should we approach animation?

Let's say we have a class
[BoneChar]

I'd say we should load one set of [BoneStructure] into it. BoneStructure should contain all the stuff I posted in my first post. (btw we could also add stuff like node.damage, node.maxDamage and so on depending on the need)

The BoneStructure will be the ground structure of the char with a predefined stance.

Also we'll add [BoneAnimation] to BoneChar which will be a reference to a list of BoneAnimations that we have. The BoneAnimation will be the current played animation.

A BoneAnimation will store a list of BoneFrames and for example the duration of the animation (world.time % boneAnimation.duration should return the current time in our animation for example).

A BoneFrame should not need more than just two floats and one integer for each node, that store it's rotational value [boneFrame[node].rotation] at a given time [boneFrame[node].time] and the sprite Offset [boneFrame[node].spriteOffset] (more on the offset later on). If we have the time in our animation we could then look for the last BoneFrame in this particular BoneAnimation and the next BoneFrame in the BoneAnimation and interpolate the rotational value... this'd result in a linear interpolation Smile ofc this type of calculation will happen somewhere else, so we can also think about different approaches, except linear transition Smile

... if our animation software on the other hand would produce 60fps animations then we don't need the time value in our BoneFrame and we wouldn't need animation interpolation...

Regarding the sprite offSet:

Each boneChar should also have a [Spritesheet] that stores all graphics for this bonechar. (google spritesheet and you'll know what this looks like).
The spritesheet should have a (indexed!) list of sprites with values for size of the sprite, source of the sprite and so on.

Now so that the correct sprite is at the correct position in our animation, we have the spriteOffset.

We can say that at time 1 the first node should use the first sprite of our spriteSheet. And at time 2 the first node should have the second sprite of our spriteSheet and so on. This can be used for example to load different sprites when needed (for example player getting wounded, or just for the blinking of the eyes, or animation of the hand).

Having it all indexed should make it very easy to use the same boneAnimation for two totally different looking chars.

BoneChar A and BoneChar B could both load the same BoneStructure and BoneAnimation, but just need a different SpriteSheet. This way we could create for example ONE walking animation and use it on multiple different enemy and player models, that could also be different in matters like size, as all positional values are stored in a relative 0-1 range Smile


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Sun, 5th Feb 2012 22:55    Post subject:
Radicalus wrote:
garus wrote:
I agree with all the above. One other thing I was thinking about is: transitions between states. For example when a character is running and we want it to stop. We can't just reset the movement animation. Needs some kind of smooth transition from one state to another (legs returning to "stance" position etc.)

Also animation divided into at least two sections: upper body and lower body. So we can run (legs move) and gun at the same time (aiming with guns or something). Much like in Max Payne (only easier Very Happy).


The transition should in essence not be a problem, it's doable. Since keyframe animation works with interpolation, once the walk button is no longer pressed, the next keyframe should be a complete halt (instead of the next keyframe from the run animation) in X amount of time, until that time the engine interpolates the animation steps.

Ah, good idea. So we will just store instances of our figures and in our world we'll have representations, where the current animation is just another blob of rotation information that is blended over time, and not between specific frames of a specific animation Smile


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Sun, 5th Feb 2012 22:57    Post subject:
Eh, please consider all of my posts in here as pure brain farts. People like bearish should have more knowledge about this stuff Smile

*btw, pedro the bear had a working animation system based on this thoughts, minus the bonestructure though, but the animation class was similar, as i had to deal with timing, spritesheets and so on. The video I posted showed so little of what I actually did in there *


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 22:58    Post subject:
In XNA, the default update function, that updates game logic (including animations) runs at 60. note, that drawing the game world isn't locked to the update.
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 23:01    Post subject:
PumpAction wrote:
Eh, please consider all of my posts in here as pure brain farts. People like bearish should have more knowledge about this stuff Smile

*btw, pedro the bear had a working animation system based on this thoughts, minus the bonestructure though, but the animation class was similar, as i had to deal with timing, spritesheets and so on. The video I posted showed so little of what I actually did in there *


Brainfarts from my behalf as well. Cool Face We're learning. I never did games, or animation, and they never taught it at uni, so Smile
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 23:14    Post subject:
PumpAction wrote:
Radicalus wrote:
garus wrote:
I agree with all the above. One other thing I was thinking about is: transitions between states. For example when a character is running and we want it to stop. We can't just reset the movement animation. Needs some kind of smooth transition from one state to another (legs returning to "stance" position etc.)

Also animation divided into at least two sections: upper body and lower body. So we can run (legs move) and gun at the same time (aiming with guns or something). Much like in Max Payne (only easier Very Happy).


The transition should in essence not be a problem, it's doable. Since keyframe animation works with interpolation, once the walk button is no longer pressed, the next keyframe should be a complete halt (instead of the next keyframe from the run animation) in X amount of time, until that time the engine interpolates the animation steps.

Ah, good idea. So we will just store instances of our figures and in our world we'll have representations, where the current animation is just another blob of rotation information that is blended over time, and not between specific frames of a specific animation Smile


So, let me take two cases, to explain, what I mean.

We have timeframe X in seconds and animation keyframes A and B. The keyframes contain all data, but for this example, I'll just assume the difference in A and B is just an angle of a bone.

Now, A is the present keyframe, B is the always next keyframe, our engine interpolates the steps in the animation between A and B. In our example, this is just an angle of a bone, and we know, that in XNA the logic updates every 60 seconds. So we just take the difference of the angles between B and A, divide it by (60*X), and add the amount to the object angle each logic update. What we have is a lean animation.

Now, if we don't want it to be lean, but we want it to ease in at the beginning and end before reaching a keyframe - that's more complex, but you get the basic idea.

So here comes the interesting part: B depends on the input state of the game. For example, if we are pressing right, then B is the next keyframe of the run animation, if we stopped pressing right, then B is the idle animation's first keyframe.

This way, what garus says is avoided.
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Sun, 5th Feb 2012 23:25    Post subject:
OK, here is a VERY basic animation that I created in Cinema4D, together with the possible useful exports:


Cinema4D Setup:



Download: http://www.mediafire.com/?opkfdlv8hj76sz5

Archive contains:
+ The original animation in C4D (R13) and the basic texturesheet.
+ Exported into DirectX .X format
+ Exported into XML
+ Exported into .fbx
+ Exported into .fbx with prebaked frames
+ Exported into .fbx as text

Feel free to join me in analyzing, which one might be the most useful.

If you have autodesk maya or 3DStudio max, please feel free to import this and export the stuff with them, so that we can spot differences and get sure on which software to use Smile


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
garus
VIP Member



Posts: 34200

PostPosted: Sun, 5th Feb 2012 23:25    Post subject:
snip


Last edited by garus on Tue, 27th Aug 2024 21:23; edited 2 times in total
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 23:30    Post subject:
garus wrote:
What you described is a (not bad) solution to transitions between states. We are not avoiding anything, just solving Smile


PS. DIE XML DIEEEEE!


Who did you post this to?
Back to top
garus
VIP Member



Posts: 34200

PostPosted: Sun, 5th Feb 2012 23:31    Post subject:
snip


Last edited by garus on Tue, 27th Aug 2024 21:23; edited 1 time in total
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 23:33    Post subject:
garus wrote:
@Radicalus, what you described is a (not bad) solution to transitions between states. We are not avoiding anything, just solving Smile


PS. DIE XML DIEEEEE!


Nice one Pumpy. About to check the files Smile


I know we're not avoiding anything Smile Don't worry about me, I don't mind if somebody finds better ways than me - I'm all for it. Just brainstorming here without actually knowing this in depth or anything.
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Sun, 5th Feb 2012 23:33    Post subject:
Radicalus wrote:
Now, A is the present keyframe, B is the always next keyframe, our engine interpolates the steps in the animation between A and B. In our example, this is just an angle of a bone, and we know, that in XNA the logic updates every 60 seconds. So we just take the difference of the angles between B and A, divide it by (60*X), and add the amount to the object angle each logic update. What we have is a lean animation.


Yeah, inside my pile of brainfart, I was talking about the exact same thing Very Happy

Quote:
If we have the time in our animation we could then look for the last BoneFrame in this particular BoneAnimation and the next BoneFrame in the BoneAnimation and interpolate the rotational value... this'd result in a linear interpolation ofc this type of calculation will happen somewhere else, so we can also think about different approaches, except linear transition




--

Radicalus wrote:
Now, if we don't want it to be lean, but we want it to ease in at the beginning and end before reaching a keyframe - that's more complex, but you get the basic idea.

So here comes the interesting part: B depends on the input state of the game. For example, if we are pressing right, then B is the next keyframe of the run animation, if we stopped pressing right, then B is the idle animation's first keyframe.

This way, what garus says is avoided


So what you are talking now in this process is, that we load animations seperately from our chars, and we just assing the animation temporary to our char and just store the current frame and the next one.

Thus we'll say the following:
Player is walking to the left. Grab animation for walking to the left, take the first frame, and use it as the next frame in our current player animation.
Player suddenly decides to walk right. Grab right walk animation, take first frame, set it in the next frame of our current player animation.

In the mean time, the game will always lineary interpolate between the current and next frame.

...

If we extend this by two more frames, we could do some easing and so on Smile Ofc not ALL animations would want easing, but there are work arounds. (If you are interested in more detail regarding this, look up on how to get sharp corners in an object that has a hypernurb modifier. The hypernurb in c4d smothes polygons. If you still want sharp edges in there, you just place more polygons next to each other. This will result in sharp edges when desired and done properly. The same could be used for animations Smile ).
Back to top
BearishSun




Posts: 4484

PostPosted: Sun, 5th Feb 2012 23:35    Post subject:
Sounds like you guys got it worked out Wink

What is also useful is to have animation events. They are pretty much callbacks you can set by calling Animations.SetEvent("SomeAnim", 1.2, myCallback). So now at 1.2 seconds of animation "SomeAnim" method myCallback gets called. This way you can easily set up sound and other cues.

Also I'd make action points a special class of bones. Something you can attach to the skeleton like a bone, but isn't actually one. Gives you more freedom I think.
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Sun, 5th Feb 2012 23:37    Post subject:
Sounds good, maybe even a list of actionpoints....

Animation events could be generated while loading the file, right? Sounds interesting too. I already thought about how we should solve that. Smile Hey, please give us more detailed info Very Happy

btw. .X is very simple and easy to understand. BUT it doesn't store the animation Crying or Very sad

The pure fbx is a binary file where we have to pray and hope that XNA's content pipeline will understand it just the correct way...

The fbx as text is readable, but damn, those structures SUCK ASS! Why not define it in JSON instead? Smile

The xml by C4D has some nice stuff but looks like a pain in the ass to read through... will do this at a latter point in time Smile



... I also should've exported the prebakedframes as text fbx. If this is what we think it is, we could forget about the whole frame interpolation thingy and just let C4D do all the animation transition and just spit out pre-calculated animations Smile


Last edited by PumpAction on Sun, 5th Feb 2012 23:42; edited 1 time in total
Back to top
garus
VIP Member



Posts: 34200

PostPosted: Sun, 5th Feb 2012 23:38    Post subject:
snip


Last edited by garus on Tue, 27th Aug 2024 21:23; edited 2 times in total
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 23:38    Post subject:
BearishSun wrote:
Sounds like you guys got it worked out Wink

What is also useful is to have animation events. They are pretty much callbacks you can set by calling Animations.SetEvent("SomeAnim", 1.2, myCallback). So now at 1.2 seconds of animation "SomeAnim" method myCallback gets called. This way you can easily set up sound and other cues.

Also I'd make action points a special class of bones. Something you can attach to the skeleton like a bone, but isn't actually one. Gives you more freedom I think.


Yes, thought of this as well.

Bearish, now that you're here (thank for droping by Smile). Mind sharing some resources, useful links, code snippets, something? Smile
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Sun, 5th Feb 2012 23:42    Post subject:
Yeah, give us the sourcecode of on whatever you are working right now Devil Troll


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 23:43    Post subject:
PumpAction wrote:
Radicalus wrote:
Now, A is the present keyframe, B is the always next keyframe, our engine interpolates the steps in the animation between A and B. In our example, this is just an angle of a bone, and we know, that in XNA the logic updates every 60 seconds. So we just take the difference of the angles between B and A, divide it by (60*X), and add the amount to the object angle each logic update. What we have is a lean animation.


Yeah, inside my pile of brainfart, I was talking about the exact same thing Very Happy

Quote:
If we have the time in our animation we could then look for the last BoneFrame in this particular BoneAnimation and the next BoneFrame in the BoneAnimation and interpolate the rotational value... this'd result in a linear interpolation ofc this type of calculation will happen somewhere else, so we can also think about different approaches, except linear transition




--

Radicalus wrote:
Now, if we don't want it to be lean, but we want it to ease in at the beginning and end before reaching a keyframe - that's more complex, but you get the basic idea.

So here comes the interesting part: B depends on the input state of the game. For example, if we are pressing right, then B is the next keyframe of the run animation, if we stopped pressing right, then B is the idle animation's first keyframe.

This way, what garus says is avoided


So what you are talking now in this process is, that we load animations seperately from our chars, and we just assing the animation temporary to our char and just store the current frame and the next one.

Thus we'll say the following:
Player is walking to the left. Grab animation for walking to the left, take the first frame, and use it as the next frame in our current player animation.
Player suddenly decides to walk right. Grab right walk animation, take first frame, set it in the next frame of our current player animation.

In the mean time, the game will always lineary interpolate between the current and next frame.

...

If we extend this by two more frames, we could do some easing and so on Smile Ofc not ALL animations would want easing, but there are work arounds. (If you are interested in more detail regarding this, look up on how to get sharp corners in an object that has a hypernurb modifier. The hypernurb in c4d smothes polygons. If you still want sharp edges in there, you just place more polygons next to each other. This will result in sharp edges when desired and done properly. The same could be used for animations Smile ).


Sorry for not catching the part, where you said the same thing. Anyway, yes, I think we should load bone structures and animations separately, and let the engine dynamically set keyframes (from the animations we loaded) based on game state.
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 23:43    Post subject:
PumpAction wrote:
Yeah, give us the sourcecode of on whatever you are working right now Devil Troll


Also, your bank account details Cool Face
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Sun, 5th Feb 2012 23:48    Post subject:
Well sounds as we are all on the same line of thought Smile

Pff, you can't beat logic. Look at what happened to the game mechanic thread, just because taste is involved Laughing


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 23:48    Post subject:
Also: good resource for XNA animation: http://demina.codeplex.com/

Download and check out the sample code.
Back to top
Radicalus




Posts: 6421

PostPosted: Sun, 5th Feb 2012 23:49    Post subject:
PumpAction wrote:
Well sounds as we are all on the same line of thought Smile

Pff, you can't beat logic. Look at what happened to the game mechanic thread, just because taste is involved Laughing


Yeah, it got heated - but overall, most people agreed to a plan, so it's all good.
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Sun, 5th Feb 2012 23:50    Post subject:
Well to be honest, our animation system is SO simple, that we could built our own animation creating tool. This should be fairly easy and share the essential classes with our game...


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
garus
VIP Member



Posts: 34200

PostPosted: Sun, 5th Feb 2012 23:51    Post subject:
snip


Last edited by garus on Tue, 27th Aug 2024 21:23; edited 1 time in total
Back to top
Page 1 of 2 All times are GMT + 1 Hour
NFOHump.com Forum Index - Project Codenamed Cuppah Joe's Goto page 1, 2  Next
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group