Hi guys,
Ive been trying to get animation blending happening and I found out about cumulative blending. So far when I set it (only) the arms do weird animation... I've attached the arm spasm animation (cumulative) and normal animation (average)
I thought it was a IK issue as Ogre3d doesn't do it, so I baked the IK constraints (blender) and removed the IK but it still spasms
Any help will be greatly appreciated
Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
-
- Gnoblar
- Posts: 3
- Joined: Fri Oct 02, 2009 6:11 am
Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
You do not have the required permissions to view the files attached to this post.
-
- OGRE Moderator
- Posts: 2819
- Joined: Mon Mar 05, 2007 11:17 pm
- Location: Canada
- x 218
Re: Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
I haven't looked at your videos. But if you're trying to play two animations at full weight at the same time, ANIMBLEND_CUMULATIVE is going to be wonky. That's because it simply adds the two animations together. For example, if animation1 rotates an arm 40 degrees, and animation2 rotates the arm 90 degrees, in ANIMBLEND_CUMULATIVE the arm will rotate 40+90 = 130 degrees, which generally looks nothing like either of the original animations. Alternatively, ANIMBLEND_AVERAGE would rotate the arm 40+90/2 = 65 degrees, which is probably what you're expecting.
In my experience, the key to good animation blending is:
Hope that helps. Animation is tricky, and many projects do it a little differently from one another.
Ogre3D provides a solid basis for playing animations, but you're going to have to write some code and learn to use the Ogre3D AnimationState functions to get what you want.
In my experience, the key to good animation blending is:
- Usually, you want to avoid playing two different animations at full weight at the same time, unless you make use of "bone blend masks". see AnimationState::BoneBlendMask, or search for it on the forums (I don't think it's very well documented in the source code). Bone blend masks can be used to say blend an upper body animation (like "shoot") with a lower body animation (like "run").
- When transitioning between two animations (e.g. "run" to "jump"), use animation weights to ramp in the weight of the new animation while ramping out the weight of the old animation. see the function AnimationState::setWeight
- In my game, I originally used ANIMBLEND_AVERAGE, which probably works more as you'd expect when transitioning between two different animations. But once I switched to using bone blend masks, I needed to switch to ANIMBLEND_CUMULATIVE, so that two simultaneous animations on different parts of the body both played properly.
Hope that helps. Animation is tricky, and many projects do it a little differently from one another.
Ogre3D provides a solid basis for playing animations, but you're going to have to write some code and learn to use the Ogre3D AnimationState functions to get what you want.
-
- Gnoblar
- Posts: 3
- Joined: Fri Oct 02, 2009 6:11 am
Re: Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
Hi,
Thanks for the reply
Currently I am using the neoaxis engine which does not provide a interface to the blend mask code. I had suspected that weights > 1 would be causing it to behave weirdly, but because the feet/legs animation worked still I thought it could be something else. I tried average but running + shooting still does not seem right. Is it possible to export the skeleton so that the bones which are not animated do not get exported for that animation (e.g cast/shoot animation only has arm data) to avoid using blend masks e.g
Exported Animation Walk (weights):
Leg/Foot = 1
Arms = 1
Exported Animation Shoot (weights):
Leg/Foot = 0 (not exported)
Arms = 1
Average blend:
Leg/Foot = 1(Walk)
Arms = 0.5(Walk) + 0.5(Shoot)
Thanks.
Thanks for the reply
Currently I am using the neoaxis engine which does not provide a interface to the blend mask code. I had suspected that weights > 1 would be causing it to behave weirdly, but because the feet/legs animation worked still I thought it could be something else. I tried average but running + shooting still does not seem right. Is it possible to export the skeleton so that the bones which are not animated do not get exported for that animation (e.g cast/shoot animation only has arm data) to avoid using blend masks e.g
Exported Animation Walk (weights):
Leg/Foot = 1
Arms = 1
Exported Animation Shoot (weights):
Leg/Foot = 0 (not exported)
Arms = 1
Average blend:
Leg/Foot = 1(Walk)
Arms = 0.5(Walk) + 0.5(Shoot)
Thanks.
-
- OGRE Moderator
- Posts: 2819
- Joined: Mon Mar 05, 2007 11:17 pm
- Location: Canada
- x 218
Re: Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
Well, I don't know of any exporters that could do this for you.
Theoretically it would be possible for the animator to create a bunch of specialized animations that blend together properly without using bone blend masks. But it would be a lot of extra work. Even in your simple example, you'd run into problems. If the arm points forward for "shoot", and sways at the side for "walk", when you blend walk+shoot, now your arm is sorta pointing forward, but sort of swaying. It's not going to look right.
What you'd really need to do is something like this: Create a walk animation that only uses the bones of the lower body. Then create a shoot animation that only uses the bones of the upper body. Then you could blend these using ANIMBLEND_CUMULATIVE, and it should work. But now if you play either of these animations separately, they'll look stupid (walking with no upper body movement, or shooting with no lower body movement). So now you need two versions of all your animations, e.g. "walk_full_body", "walk_lower_body_only", "shoot_full_body", and "shoot_upper_body_only"... It's going to get pretty messy, and your animator is going to hate you.
This is the problem bone blend masks was designed to solve.
If there are only one or two situations where you blend together 2 different animations, you might be able to get away with simply creating these extra animations. For example, maybe you need to create a special "walk_and_shoot" animation.
Theoretically it would be possible for the animator to create a bunch of specialized animations that blend together properly without using bone blend masks. But it would be a lot of extra work. Even in your simple example, you'd run into problems. If the arm points forward for "shoot", and sways at the side for "walk", when you blend walk+shoot, now your arm is sorta pointing forward, but sort of swaying. It's not going to look right.
What you'd really need to do is something like this: Create a walk animation that only uses the bones of the lower body. Then create a shoot animation that only uses the bones of the upper body. Then you could blend these using ANIMBLEND_CUMULATIVE, and it should work. But now if you play either of these animations separately, they'll look stupid (walking with no upper body movement, or shooting with no lower body movement). So now you need two versions of all your animations, e.g. "walk_full_body", "walk_lower_body_only", "shoot_full_body", and "shoot_upper_body_only"... It's going to get pretty messy, and your animator is going to hate you.
This is the problem bone blend masks was designed to solve.
If there are only one or two situations where you blend together 2 different animations, you might be able to get away with simply creating these extra animations. For example, maybe you need to create a special "walk_and_shoot" animation.
-
- OGRE Moderator
- Posts: 2819
- Joined: Mon Mar 05, 2007 11:17 pm
- Location: Canada
- x 218
Re: Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
Just a few more thoughts.
If you can't use bone blend masks in Neoaxis, and you don't have an animator (maybe you bought your models from somewhere and you only have a pre-made set to work with), you're options are pretty limited. Either you blend the animations and they look bad. Or you set up your game so that you don't blend animations - e.g. you aren't allowed to walk and shoot at the same time. Shooting roots you in place.
You might want to request that an API for bone blend masks be added to Neoaxis.
If you can't use bone blend masks in Neoaxis, and you don't have an animator (maybe you bought your models from somewhere and you only have a pre-made set to work with), you're options are pretty limited. Either you blend the animations and they look bad. Or you set up your game so that you don't blend animations - e.g. you aren't allowed to walk and shoot at the same time. Shooting roots you in place.
You might want to request that an API for bone blend masks be added to Neoaxis.
-
- Gnoblar
- Posts: 3
- Joined: Fri Oct 02, 2009 6:11 am
Re: Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
Hmm yeah I think I'll either make more animations e.g walk_shoot or root the character in place whilst shooting.
Anyways thanks Jabber
Anyways thanks Jabber
-
- Halfling
- Posts: 95
- Joined: Fri Dec 23, 2005 8:46 pm
- Location: Niskayuna, NY
Re: Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
I'm struggling with this as well. I'm using a public domain model exported from Blender. It has separate animations for the upper body and lower body. The run(legs) animation moves only the legs. The run(arms) animation moves only the arms. One might expect setting the skeleton to ANIMBLEND_CUMULATIVE would give a nice complete run animation with these two, but it doesn't seem to work out that way.
With these two animations running, the arms and legs are contorted to the extreme. I estimate that the bones may be moving their required swing, but the starting pose is all out of wack, and hence he'll never look right. Is there some extra step to get the starting pose right for the two animations? Has it anything to do with the binding pose, and how can I make it so that my guy starts off like he hasn't been tied in knots. If he starts out correctly, I suspect the animations will look proper.
With these two animations running, the arms and legs are contorted to the extreme. I estimate that the bones may be moving their required swing, but the starting pose is all out of wack, and hence he'll never look right. Is there some extra step to get the starting pose right for the two animations? Has it anything to do with the binding pose, and how can I make it so that my guy starts off like he hasn't been tied in knots. If he starts out correctly, I suspect the animations will look proper.
-
- OGRE Moderator
- Posts: 2819
- Joined: Mon Mar 05, 2007 11:17 pm
- Location: Canada
- x 218
Re: Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
I think you're right. Combining an upper and lower body animation won't work at all unless the non-animated part is exactly in the bind pose. So for example, if the non-animated mesh is standing straight up with arms stretched outwards, then the upper-body portion of your run(legs) animation should also have arms stretched outwards - no rotation on any upper body bones.
Bone blend masks would help solve your problem as well.
Bone blend masks would help solve your problem as well.
-
- OGRE Retired Moderator
- Posts: 9481
- Joined: Fri Feb 18, 2005 2:03 am
- Location: Dublin, CA, US
- x 22
Re: Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
I have to say, this presentation was much better with audio to explain what was going on
http://www.naughtydog.com/docs/Naughty- ... ortune.pdf
but you're finding a basic problem with non-additive skeletal animation. In Ogre, currently the closest you are going to get to the sorts of additive animations they talked about there (and you're talking about here) is indeed to use skeletal blend masks.
http://www.naughtydog.com/docs/Naughty- ... ortune.pdf
but you're finding a basic problem with non-additive skeletal animation. In Ogre, currently the closest you are going to get to the sorts of additive animations they talked about there (and you're talking about here) is indeed to use skeletal blend masks.
-
- Halfling
- Posts: 95
- Joined: Fri Dec 23, 2005 8:46 pm
- Location: Niskayuna, NY
Re: Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
I suspect that I may share the same problem with the original poster. Even if the parallel animations don't seem to move the same bones, they may initially pose the same bones. In my case some bones were rotated twice, one per animation.
If there was a way to selectively suppress the initial pose movement of an animation, that could possibly make things easier, in cases where the initial pose of two blended animations is known to be the same or similar.
To avoid blend masking, I think the solution to our problems is to design the animations such that there isn't shared control of many of the bones. In that case some animations may only look right when blended. I think it might be ok for one animation to only translate and the other to only rotate a given bone if needed.
If there was a way to selectively suppress the initial pose movement of an animation, that could possibly make things easier, in cases where the initial pose of two blended animations is known to be the same or similar.
To avoid blend masking, I think the solution to our problems is to design the animations such that there isn't shared control of many of the bones. In that case some animations may only look right when blended. I think it might be ok for one animation to only translate and the other to only rotate a given bone if needed.
-
- Halfling
- Posts: 95
- Joined: Fri Dec 23, 2005 8:46 pm
- Location: Niskayuna, NY
Re: Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
Bah the Blender exporter is part of the problem. When exporting a list of animations, it leaves each animation in whatever pose it is left with to generate the next animation. That doesn't seem right to me. The exported animation should not be affected by the previous animation in the list, but rather the model should be put in its binding pose.
-
- OGRE Retired Moderator
- Posts: 9481
- Joined: Fri Feb 18, 2005 2:03 am
- Location: Dublin, CA, US
- x 22
Re: Weird animation with BlendMode = ANIMBLEND_CUMULATIVE
Ogre treats it that way internally -- all animation keyframes and interpolations are calculated based on the "initial" pose value, not the previous keyframe -- there is no need for an exporter to have to keep repeating the bind pose, in other words.
It would be simpler of course if Ogre just with additive skeletal animations, of course (it already does with pose animations), but in the meantime, blend masks are going the be the most straightforward option for this.
It would be simpler of course if Ogre just with additive skeletal animations, of course (it already does with pose animations), but in the meantime, blend masks are going the be the most straightforward option for this.