Set interpolation function per-bone

What it says on the tin: a place to discuss proposed new features.
Post Reply
oiking
Kobold
Posts: 39
Joined: Fri Jun 06, 2008 1:59 pm
Location: Germany
Contact:

Set interpolation function per-bone

Post by oiking » Thu Jan 29, 2009 11:39 am

Preface
I recently stumbled across some animation system incapabilities that can be traced back to the used interpolation between two (or more) animation tracks.
Currently, OGRE is using a simple linear interpolation to blend rotations from two (or more) animation tracks together.
In one of my last projects we were using acrobatic motions( like sommersaults, twists etc... ) that rotate the character within 360° of an axis.
As we wanted to support smooth blending between two motions, it became apparent that the linear blending between tracks
rendered the blending useless: Blending two sommersault animations together (ending of one with beginning of second) made the root bone
rotate 360° within a fraction of a second, really not the result we wanted. We solved this by turning off blending and trying to align the
assets as closely as possible so no blending was needed. This leads me to the feature request.

Feature Request
It would be very useful when OGRE supports Shortest Path Interpolation. I know it's more expensive in performance meanings than simple linear
interpolation. But as you see, this special interpolation mode just has to be used for special bones (in my case, the root bone only), so the
overhead would be small in comparation to the rest of your 200 bones skeleton using linear interpolation.

I really would like to do this my self, but I lack the experience of OGRE design priciples, thus not having an idea
where I need to plug-in the shortest path animation.
0 x
Working at Z-Software

nbeato
Gnome
Posts: 372
Joined: Thu Dec 20, 2007 1:00 am
Location: Florida
x 1
Contact:

Re: Set interpolation function per-bone

Post by nbeato » Tue Feb 17, 2009 10:24 pm

I don't mean to bring up a relatively old post, but we also have this problem with animations built with MotionBuilder. Individual animations are fine, but when I try blending animations (ramp out/in to transition), the models decide to spin 358 degree instead of -2, which looks really bad. I've been trying to find an easy solution. This seems to only happen when the animations involve rotating the parent bone 180 degrees and starting the next animation rotated 180 degrees. However, I haven't tested it enough to say "that's only when it happens".
0 x

nbeato
Gnome
Posts: 372
Joined: Thu Dec 20, 2007 1:00 am
Location: Florida
x 1
Contact:

Re: Set interpolation function per-bone

Post by nbeato » Tue Feb 17, 2009 10:58 pm

After some investigation, the problematic code for my problem can be found in OgreAnimationTrack.cpp, line 497-504. In NodeAnimationTrack::applyToNode(), we see the following:

Code: Select all

        if (rim == Animation::RIM_LINEAR)
        {
            rotate = Quaternion::nlerp(weight, Quaternion::IDENTITY, kf.getRotation(), mUseShortestRotationPath);
        }
        else //if (rim == Animation::RIM_SPHERICAL)
        {
            rotate = Quaternion::Slerp(weight, Quaternion::IDENTITY, kf.getRotation(), mUseShortestRotationPath);
        }
Notice that if 2 animations are blending with weights t and 1-t, the mUseShortestRotationPath will force the shortest rotation towards IDENTITY, which isn't correct from a "global" view. For example, if we have two animations rotated -178 and 178 degrees and set t=0.5. Then we would expect to get a 180 degree rotation. However, the code produces a 0 degree rotation as follows:

We start with IDENTITY.
The first animation calls slerp(0.5, IDENTITY, -178, true), causing an -89 degree rotation.
The current rotation is -89 degrees.
The second animation calls slerp(0.5, IDENTITY, 178, true), causing an 89 degree rotation.
The current rotation is -89 rotated to +89, giving the net 0 rotation.
0 is bad!

Calling slerp(0.5, -178, 178, true) would result in a 180 degree rotation.

I don't know the best solution to this problem. I am getting more familiar with the implementation, but I don't see a way to blend animations without a priori knowledge. I tried disabling the useShortestRotationPath flag, and that didn't help. Actually, it made some of the working transitions stop working. Doh!
0 x

nbeato
Gnome
Posts: 372
Joined: Thu Dec 20, 2007 1:00 am
Location: Florida
x 1
Contact:

Re: Set interpolation function per-bone

Post by nbeato » Tue Feb 17, 2009 11:29 pm

Ack, I just realized the result of this problem isn't related to the initial post. Sorry! Can a moderator move this to a different forum and new topic?

EDIT: the message was irrelevant, this is the same problem as the initial post.
0 x

Post Reply