Game Development Community

Blending animation in Blender possible?

by Alaric Karczag · in Artist Corner · 05/20/2005 (3:42 pm) · 9 replies

I have created my character with his arms out to the sides- this is making alot of issues with the blending of animation sequences in game, as most of the blend animations, like arms up and down, revert to the base pose (of arms out) and then play the animation.

He's resting with the gun out in root pose, but when he moves forward.... wheee his arms go out and he decides to run like a kid pretending he's a plane- arm out.

how do i set him to a default pose in Blender. Evidently the root sequence does not play all the time.
I was under the impression that root was the only full character animation, and all the other animaitons were blends to the root.
so running would be a blend of the legs running on top of the root sequence-

my arms up and down sequence sends his arms all over the place- for no known reason


should i be recording all bones during a sequence? I have just been recording the bones im animating.

in torque show tool pro the only way i can get him to look correct is to load in the root sequence first, then add a thread to run, move head, etc. ( but the arm up/down animation still messed up?)

I've spent 15 hours trying to make a proper skeleton thats not wrong in any way, now the animations will not blend.

anyone got a .blend of a fully animated character for torque that i can look at?
I'll send my .blend out to anyone that wants to try and fix it.

Thanks all for your help!

#1
05/23/2005 (6:33 am)
Afaik it's not possible to make blend animations with the current version of the exporter. I'm no expert, i just tried it in a variety of different ways with no success. It looks like blends are relative to the armature's rest position, not relative to the Root animation (as they should be and actually are e.g. with the 3ds max exporter).
#2
05/23/2005 (7:33 am)
I just finished a tutorial covering this for 3dsmax. It was not easy figuring it out the first time, but you might learn something that will help you out down the road in it.

Read it here.


Since most exporters are based on the 3dsmax one, here is a quick rundown of what I learned about blends:

1. The 1st frame of animation should be the "root" pose (If your working on the look blend for his arms, then his arms would be in the middle)

2. The next frame should be the highest his arms will go up (assuming your working on the look blend)

3. The last frame (about 10 to 15 frames later) should be the lowest his arms will go down.

4. When you export, don't include the "frame 0" "root" pose, but start at the "frame 1" where he is looking all the way up, and end it at the last frame.

I don't know if that will help you for Blender, but, that is how the Max exporter likes to do blends.

B--
#3
07/03/2005 (10:45 am)
Here's a messy hack to make the Blender DTS exporter create Blends in a similar manner to the 3DSMax exporter mentioned above. With this modification, the final frame of the Blend Action is used to define the "root" pose for the exported Blend Sequence. So for the "look" blend animation, the first frame would be the character aiming upwards, the second-to-last frame the character aiming downwards, and the final frame the character's root/idle pose (copied from the full separate root/idle animation). Then in the show tool, you would then run your root/idle animation in thread 0, and the look blend animation in thread 1.

Apply the following changes to the code in Dts_Blender.py:

At around line 1200, find this statement
if sequence.flags & sequence.Cyclic:
and replace it with
if (sequence.flags & sequence.Cyclic) or (sequence.flags & sequence.Blend):



Then at around line 1400, find this block
# Set the current frame in blender to the frame the ipo keyframe is at
context.currentFrame(int(frame))
and insert the following before it
if sequence.flags & sequence.Blend:
	context.currentFrame(int(sequence.numKeyFrames))
	scene.update(1)
	if has_rot:
		lastQuatX = ipo.getCurveCurval(curveMap['QuatX'])
		lastQuatY = ipo.getCurveCurval(curveMap['QuatY'])
		lastQuatZ = ipo.getCurveCurval(curveMap['QuatZ'])
		lastQuatW = ipo.getCurveCurval(curveMap['QuatW'])
		lastQuat = Quaternion(lastQuatX, lastQuatY, lastQuatZ, lastQuatW)



Finally, at around line 1460 find this block of code (be careful not to confuse it with a similar-looking block below it)
# If we have rot values...
if has_rot:
	ipo_rot = Quaternion(
	ipo.getCurveCurval(curveMap['QuatX']),
	ipo.getCurveCurval(curveMap['QuatY']),
	ipo.getCurveCurval(curveMap['QuatZ']),
	ipo.getCurveCurval(curveMap['QuatW']))
	#print "BLEND rot: %f %f %f %f" % (ipo_rot[0],ipo_rot[1],ipo_rot[2],ipo_rot[3])
	rot = ipo_rot.inverse()
and replace it with
# If we have rot values...
if has_rot:
	currentQuat = Quaternion(
	ipo.getCurveCurval(curveMap['QuatX']),
	ipo.getCurveCurval(curveMap['QuatY']),
	ipo.getCurveCurval(curveMap['QuatZ']),
	ipo.getCurveCurval(curveMap['QuatW']))
	ipo_rot = lastQuat.inverse() * currentQuat
	#print "BLEND rot: %f %f %f %f" % (ipo_rot[0],ipo_rot[1],ipo_rot[2],ipo_rot[3])
	rot = ipo_rot.inverse()

This hack isn't a comprehensive solution; these modifications only alter rotations, not location and size.
#4
07/05/2005 (6:07 pm)
Walter, that looks extremely interesting. Thanks a lot for sharing your 'hack', if it works it's gonna solve most of my problems
#5
08/14/2005 (2:57 am)
I tracked down a bug with my hack that was causing the last Blend frame to be exported under certain circumstances. Turns out that my own peculiar animating habits didn't trigger the bug, so I didn't quite catch it the first time around. This time it should work.

Instead of detailing the fixes, I'll just post a link to the corrected Dts_Blender.py hack: Dts_Blender_hack.zip.
#6
08/15/2005 (5:01 am)
Thanks for the "hack" - shouldn't we call it 0.8.7.1 ??? :)

BTW Is this the only way we have to blend animations together?

Anyone using anything else?
#7
08/15/2005 (6:01 am)
Quote:Thanks for the "hack" - shouldn't we call it 0.8.7.1 ??? :)

I'm not the original author of the exporter, and the modifications change the way that one has to create blend animations from previous versions, so frankly I don't consider it as any sort of offical update. Plus the zipfile I posted only replaces a single file of the whole exporter; you'll still need the rest of the original exporter files for it to work.

Quote:BTW Is this the only way we have to blend animations together?

The original exporter already supported blend animations. My modification just changes the way it works to make it easier for more people to use (ie: more similar to the other Torque DTS exporters).
#8
08/20/2005 (10:04 am)
Walter,

Thanks for the contribution. I will definatly be putting this functionality into the next release.
Although, perhaps i will have an option on the gui to control the reference pose...
#9
08/29/2005 (3:43 pm)
!!! Thank the lords above!
A call is heard!

Thank you all for looking into this situation.