Optchar + blended animations + control joint = bug?

Hi people!

I’m having some problems in using egg-optchar for model optimization.

In few words…
I have a model and several animations. The animations have to be blended. At the same time I want to control a joint for procedural animation (eg. the eyes).

If I run egg-optchar on the whole bundle, I got a zero global scale on the controlled joint which leads to an assertion error when I am calling NodePath.lookAt on that joint.

Here is the code…

from direct.showbase.ShowBase import ShowBase
from direct.actor.Actor import Actor


class OptcharTest(ShowBase):

	MODEL = 'Humanoid.egg'
	IDLE  = 'Humanoid_idle.egg'
	
	TRY_OPTCHAR = True
	
	def __init__(self):
		ShowBase.__init__(self)
		
		if OptcharTest.TRY_OPTCHAR:
			self.MODEL = 'opt/' + OptcharTest.MODEL
			self.IDLE  = 'opt/' + OptcharTest.IDLE
		
		act = Actor( self.MODEL )
		act.reparentTo( render )
		act.makeSubpart( 'mainSub', ['modelRoot' ], ['spine4'] )
		act.loadAnims( {'idle':self.IDLE}, partName='mainSub' )
		ctrl_idle = act.getAnimControl( 'idle', partName='mainSub' )
		ctrl_idle.loop( True )
        
		act.setBlend( animBlend=True )		
		act.setControlEffect( 'idle', 1.0, partName='mainSub' )
		
		face = act.exposeJoint( None, 'modelRoot', 'face_top_parent' )
		eyel = act.controlJoint( None, 'modelRoot', 'eyeball_left' )
		eyel.reparentTo( face )		
		
		print "###################################################"
		node = eyel
		while not node.isEmpty( ):
			print "%s scale = %s" % (node, node.getScale( ))
			node = node.getParent( )
		
		print "\n"
		print "eyeball_left global scale: ", eyel.getScale( render )
		print "###################################################"
		
		eyel.lookAt( render )

		
if __name__ == '__main__':
	
	OptcharTest( )
	run( )

Here is how I used egg-optchar:

egg-optchar -d opt -flag Humanoid_joints=joints -keep spine4,face_top_parent,eyeball_left,eyeball_right Humanoid.egg Humanoid_idle.egg

I got a zero scale error only when the control effect of the idle animation is greater than 0. Do you have any clue about this?
The problem seems to come either from egg-optchar or from the model itself.

Model, anim and test script are here: http://dl.dropbox.com/u/80827/test.zip

Regards,
cla

The problem is that your animation file and your model file have different character names: the animation file is called “idle” and the model file is called “Armature”. This is incorrect; they should both have the same character name, for instance, “Humanoid”. The character name is the name used by egg-optchar and other tools to identify animations and models that are intended to have the same skeleton and be interoperable.

Also, though this isn’t related, your model is duplicated in the animation file, which is wasteful and potentially a source of trouble.

Both of these are no doubt due to the conversion process. I know nothing about Chicken, so cannot advise you specifically how to correct them; but surely there is an option there to set the character name, and to omit the model when you export the animation.

David

Thanks David!

The problem was indeed the character name. Renaming ‘Armature’ into ‘Humanoid’ fixed the zero scale problem. Now I’ll try to optimize the whole model+animations bundle and try everything with the rest of system.

Regards,
Claudio