Animationblending with Manually Controlled Bone

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
Masterjaffa
Gnoblar
Posts: 10
Joined: Wed Jun 20, 2007 12:50 pm
Location: Hamburg, Germany

Animationblending with Manually Controlled Bone

Post by Masterjaffa » Fri Aug 17, 2007 1:45 pm

Hi!

I have a character with fullbody animations.
While playing some of the Animations (idle), the Head of the character should be facing towards the camera. And while playing other anims the head should be animated as well. The camera is allways moving.

I've done this so far:

I delete the animation track of the headbone and set the bone to manually controlled where the head should be facing the camera:

Code: Select all

Animation *aTemp = NULL;
m_pHeadBone = m_pEntity->getSkeleton()->getBone("Bip01 Head");
aTemp = m_pEntity->getSkeleton()->getAnimation("idle");
aTemp->destroyNodeTrack(m_pHeadBone->getHandle());
m_pHeadBone->setManuallyControlled(true);
when the anim should be played where the head should be animated too, I do the following:

Code: Select all

m_pHeadBone->setManuallyControlled(false);
and then play the anim...
it works so far, but the anim is not blended between the boneCameraLookAt state and the first anim-keyframe, so it doens't look smooth.
Has anybody an Idea how can I make a smooth Overblending between the BoneCameraLookAt and the animation

Greetings,
MJ
0 x

User avatar
Masterjaffa
Gnoblar
Posts: 10
Joined: Wed Jun 20, 2007 12:50 pm
Location: Hamburg, Germany

Post by Masterjaffa » Mon Aug 20, 2007 11:11 am

Update:

I have done this so far:
I change the first 8 keyframes of the anim to interpolate from the lookat camera position to 9th keyframe of the anim like this:

Code: Select all

Animation* anim = m_pEntity->getSkeleton()->getAnimation(sAnim);

NodeAnimationTrack* track = anim->getNodeTrack(m_pHeadBone->getHandle());
		
TransformKeyFrame * pFirstKF = track->getNodeKeyFrame(0);
pFirstKF->setRotation(m_pHeadBone->getOrientation());
TransformKeyFrame * pLastKF = track->getNodeKeyFrame(8);
Quaternion quatFirst = pFirstKF->getRotation();
Quaternion quatLast = pLastKF->getRotation();
Quaternion quatInterpolated;
for (int i = 1;i<8;i++)
{
   TransformKeyFrame * pNewKF = track->getNodeKeyFrame(i);
   Real rTime= 1-((8-(Real)i)/8);
   quatInterpolated = Quaternion::Slerp(rTime,quatFirst,quatLast);
   pNewKF->setRotation(quatInterpolated);
}
it almost works, but there is a small problem:
allthougt the starting keyFrame(0) is set to the rotation of the bone, the first frame of the anim seems still to be the original frame of the anim, so when I start to play anim the head looks forward (instead into the camera) for one frame and then suddenly looks into the camera again and then the anim is beeing played correct way.

what did I miss? is there a frame before the keyFrame(0)?

Greetings,
MJ
0 x

Post Reply