Influenced animations
-
bartiss
- Goblin
- Posts: 226
- Joined: Fri Oct 20, 2006 7:41 am
- Location: Cracow, Poland
Influenced animations
Hi,
Imagine a VERY big, six-legged mosnter walking around a hilly terrain. All of his walk animations are prepared to work well on a flat surface, so it's easy to imagine how bad does it look like now. His legs dissappear in higher hills and float in the air above lower terrain.
Let's suppose I know where and how to orient each leg so it stays on hill's surface. I know I can set each bone to be manually controlled, but then the animation stops working. So it's either manual control or animation.
Is there any way to blend it somehow? Just like Euphoria does (http://www.youtube.com/watch?v=Qi5adyccoKI)
Imagine a VERY big, six-legged mosnter walking around a hilly terrain. All of his walk animations are prepared to work well on a flat surface, so it's easy to imagine how bad does it look like now. His legs dissappear in higher hills and float in the air above lower terrain.
Let's suppose I know where and how to orient each leg so it stays on hill's surface. I know I can set each bone to be manually controlled, but then the animation stops working. So it's either manual control or animation.
Is there any way to blend it somehow? Just like Euphoria does (http://www.youtube.com/watch?v=Qi5adyccoKI)
-
buckED
- Greenskin
- Posts: 133
- Joined: Fri Feb 15, 2008 9:51 pm
Re: Influenced animations
What you need is called inverse kinematics.
I'm not sure whether or not it has been realised for ogre yet though.
Just try searching the forums and the Wiki.
If I am not mistaken one of the summer of code projects was an attempt
at IK with ogre.
I'm not sure whether or not it has been realised for ogre yet though.
Just try searching the forums and the Wiki.
If I am not mistaken one of the summer of code projects was an attempt
at IK with ogre.
Many of life's failures are people who did not realize how close they were to success when they gave up.
~ Thomas Edison ~
~ Thomas Edison ~
-
lebensborn
- Gnoblar
- Posts: 5
- Joined: Fri Sep 04, 2009 10:21 pm
Re: Influenced animations
Not what you're looking for but maybe you could use the surface normal to align the mesh with the surface of the terrain at least? World of Warcraft does this.
-
bartiss
- Goblin
- Posts: 226
- Joined: Fri Oct 20, 2006 7:41 am
- Location: Cracow, Poland
Re: Influenced animations
IK is the way to calculate linked bone orientations. If I pull a hand the forearm and arm will "respond" correctly.buckED wrote:What you need is called inverse kinematics.
So I got rotations of all bones calculated, but how can I blend those with the ones coming from animation currently running?
The alignment is done, but it doesn't help. The monster is too big. I'm starting to consider manual animation of legs only and leaving the rest of the body to be animated the usual way.lebensborn wrote:Not what you're looking for but maybe you could use the surface normal to align the mesh with the surface of the terrain at least? World of Warcraft does this.
-
lebensborn
- Gnoblar
- Posts: 5
- Joined: Fri Sep 04, 2009 10:21 pm
Re: Influenced animations
This isn't the best way but might work, although wouldn't be very accurate...
Make an offset vector for each leg, parent it and position it to the end of each foot bone.
Make an update function which checks the distance of the offset vector to the terrain below it, then add the distance value to the bone rotations somehow, you will probably need to play about with the value untill it looks more or less correct.
If you used a multiplier on the distance value, you could use the steepness of the terrain to vary the multiplier, which in turn would vary the bone rotations. So on steep terrain it would add more rotation to the bones, and on none steep areas it would add less rotation. With a little tweaking it might look ok.
Make an offset vector for each leg, parent it and position it to the end of each foot bone.
Make an update function which checks the distance of the offset vector to the terrain below it, then add the distance value to the bone rotations somehow, you will probably need to play about with the value untill it looks more or less correct.
If you used a multiplier on the distance value, you could use the steepness of the terrain to vary the multiplier, which in turn would vary the bone rotations. So on steep terrain it would add more rotation to the bones, and on none steep areas it would add less rotation. With a little tweaking it might look ok.
-
xavier
- OGRE Retired Moderator

- Posts: 9481
- Joined: Fri Feb 18, 2005 2:03 am
- Location: Dublin, CA, US
- x 22
Re: Influenced animations
What you need is IK plus collision -- in other words, what you need is to use Havok for animation. Collision will align the feet to the land, and IK will put the rest of the bones where they need to go. The Havok demos have an example of this.
-
bartiss
- Goblin
- Posts: 226
- Joined: Fri Oct 20, 2006 7:41 am
- Location: Cracow, Poland
Re: Influenced animations
All your answers are correct but that's not what I meant guys!
I just wanted to know how to do it in Ogre. Not how to calculate bone rotations, collisions, etc.
Let's assume I have to sets of data:
A - all bones rotations taken from AnimationSet
B - some bones rotations calculated on the fly (feet collision with terrain for example, but could be anything else)
And now, how do I apply set B?
First thing I thought of was setting appropriate bones to manual control, but that leaves me with B set only. Premade animations don't work with manually controlled bones. I would like to apply set A to get the default movement animation and then correct it with set B, so the feet don't sink into terrain (for example).
So the question is if it's possible at all to change bone rotations set by AnimationState on the fly.
I just wanted to know how to do it in Ogre. Not how to calculate bone rotations, collisions, etc.
Let's assume I have to sets of data:
A - all bones rotations taken from AnimationSet
B - some bones rotations calculated on the fly (feet collision with terrain for example, but could be anything else)
And now, how do I apply set B?
First thing I thought of was setting appropriate bones to manual control, but that leaves me with B set only. Premade animations don't work with manually controlled bones. I would like to apply set A to get the default movement animation and then correct it with set B, so the feet don't sink into terrain (for example).
So the question is if it's possible at all to change bone rotations set by AnimationState on the fly.
-
bartiss
- Goblin
- Posts: 226
- Joined: Fri Oct 20, 2006 7:41 am
- Location: Cracow, Poland
Re: Influenced animations
Sorry for bumping. I really need to know if I should give up on this one.
I'm not exactly sure how Ogre manages animation states, but I think something like this might work:
1. let Ogre do the bone transformations using current animation state
2. take control of the bones and align them the way you like
3. render
4. turn off manual control of bones
Is it possible without manipulating within Ogre source?
I'm not exactly sure how Ogre manages animation states, but I think something like this might work:
1. let Ogre do the bone transformations using current animation state
2. take control of the bones and align them the way you like
3. render
4. turn off manual control of bones
Is it possible without manipulating within Ogre source?
-
lebensborn
- Gnoblar
- Posts: 5
- Joined: Fri Sep 04, 2009 10:21 pm
Re: Influenced animations
Just looked in the wiki for you, this might help. http://www.ogre3d.org/wiki/index.php/Ma ... llingBones
-
Praetor
- OGRE Retired Team Member

- Posts: 3335
- Joined: Tue Jun 21, 2005 8:26 pm
- Location: Rochester, New York, US
- x 3
Re: Influenced animations
Or better: AnimationTrack::Listener
Create a second "ghost" animation track for your object (keep the original). When the listener is called, get the interpolated keyframe from the original track which will be where the animation should be. Now, influence that any way you want (IK info, physics engine, etc.) and then return that tweaked keyframe. Make sure you play your ghost animation and not the original.
Create a second "ghost" animation track for your object (keep the original). When the listener is called, get the interpolated keyframe from the original track which will be where the animation should be. Now, influence that any way you want (IK info, physics engine, etc.) and then return that tweaked keyframe. Make sure you play your ghost animation and not the original.
Game Development, Engine Development, Porting
http://www.darkwindmedia.com
http://www.darkwindmedia.com
-
bartiss
- Goblin
- Posts: 226
- Joined: Fri Oct 20, 2006 7:41 am
- Location: Cracow, Poland
Re: Influenced animations
Thanks Praetor, that's something completely new to me. I've looked into API docs and I think that's exactly what I need.
I don't think I can find any tutorials or demos implementing this (or using AnimationTrack at all), so I'll post some more quiestions here.
I know I can get Animation object from a skeleton. Then I get AnimationTrack from Animation. And even a KeyFrame.
But how do I modify bone rotations now? I can't see any way to access them through Animation, AnimationTrack or KeyFrame.
And how do I know if AnimationTrack::Listener is being called?
And finally, how do I make sure that I play "my" animation and not the original one?
I don't think I can find any tutorials or demos implementing this (or using AnimationTrack at all), so I'll post some more quiestions here.
I know I can get Animation object from a skeleton. Then I get AnimationTrack from Animation. And even a KeyFrame.
But how do I modify bone rotations now? I can't see any way to access them through Animation, AnimationTrack or KeyFrame.
And how do I know if AnimationTrack::Listener is being called?
And finally, how do I make sure that I play "my" animation and not the original one?
-
madmarx
- OGRE Expert User

- Posts: 1671
- Joined: Mon Jan 21, 2008 10:26 pm
- x 51
Re: Influenced animations
From Animation -> the different animation track. What you want is nodeAnimationTrack (since bone is a special node).
Then from (Node)AnimationTrack -> the bone (through getAssociatedNode).
Then setup your listener.
Then I suppose you just need to do something like :
virtual bool getInterpolatedKeyFrame (const AnimationTrack *t, const TimeIndex &timeIndex, KeyFrame *kf)
{
1/ first dynamic cast t to see if its a nodeAnimationTrack (or you can just check the name of the parent animation)
2/ get the associated node.
3/ get the name of the associated node. (so you know which bone it may be).
4/ you just need to modify the values of kf (kf is already constructed, but not with good values).
5/ if you don't want to touch this animation, just return false.
}
cf line 378 of ogreanimationtrack.cpp in the svn.
Then from (Node)AnimationTrack -> the bone (through getAssociatedNode).
Then setup your listener.
Then I suppose you just need to do something like :
virtual bool getInterpolatedKeyFrame (const AnimationTrack *t, const TimeIndex &timeIndex, KeyFrame *kf)
{
1/ first dynamic cast t to see if its a nodeAnimationTrack (or you can just check the name of the parent animation)
2/ get the associated node.
3/ get the name of the associated node. (so you know which bone it may be).
4/ you just need to modify the values of kf (kf is already constructed, but not with good values).
5/ if you don't want to touch this animation, just return false.
}
cf line 378 of ogreanimationtrack.cpp in the svn.
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
-
bartiss
- Goblin
- Posts: 226
- Joined: Fri Oct 20, 2006 7:41 am
- Location: Cracow, Poland
Re: Influenced animations
Thnak you very much madmarx!
I will try it first thing in the morning
I will try it first thing in the morning
-
azzolini
- Gnoblar
- Posts: 16
- Joined: Sun Oct 18, 2009 10:14 pm
Re: Influenced animations
Ok, but it would be better to have an example about how to setup the listener.
Ogre::AnimationState *anim = scene->GetAnimationState("ruota");
unsigned short howmany = mSceneMgr->getAnimation("ruota")->getNumNodeTracks();
Ogre::NodeAnimationTrack *traccia = mSceneMgr->getAnimation("ruota")->getNodeTrack(1);
now i get a pointer to the tracknode but i cannot figure how to set up the listener!
in OgreAnimationtrack.h you have...
and..
so, i suppose it would be something to do with traccia->setListener(??);
Please can anyone help me?
Thank
Lorenzo
Ogre::AnimationState *anim = scene->GetAnimationState("ruota");
unsigned short howmany = mSceneMgr->getAnimation("ruota")->getNumNodeTracks();
Ogre::NodeAnimationTrack *traccia = mSceneMgr->getAnimation("ruota")->getNodeTrack(1);
now i get a pointer to the tracknode but i cannot figure how to set up the listener!
in OgreAnimationtrack.h you have...
Code: Select all
class _OgreExport Listener
{
public:
virtual ~Listener() {}
/** Get an interpolated keyframe for this track at the given time.
@returns true if the KeyFrame was populated, false if not.
*/
virtual bool getInterpolatedKeyFrame(const AnimationTrack* t, const TimeIndex& timeIndex, KeyFrame* kf) = 0;
};Code: Select all
/** Set a listener for this track. */
virtual void setListener(Listener* l) { mListener = l; }Please can anyone help me?
Thank
Lorenzo
