[sldev] Avatar Data Files - Formula for bone weights

Domino Marama mark at identityserver.net
Fri Aug 15 15:25:36 PDT 2008

On Thu, 2008-08-14 at 14:28 -0700, Richard Nelson wrote:
> That is correct.  Keep in mind that the index is into an "expanded" list  
> of joints, not just a linear array of the joints as defined in the  
> skeleton file.  In particular, any joint that has more than one child will  
> have to be repeated in the list for each of its children.

Thanks for pointing that out. I took the easy route in coding the list
expansion :)

Python Code...

if llm['hasWeights']:
	mode = Blender.Mesh.AssignModes.REPLACE
	jn = {
		'hair':['mNeck', 'mHead'],
		'head':['mNeck', 'mHead'],
		'upperBody':['mPelvis', 'mTorso','mChest', 'mNeck',
		'lowerBody':[ 'mPelvis', 'mHipRight', 'mKneeRight', 'mAnkleRight',
			 'mPelvis', 'mHipLeft', 'mKneeLeft', 'mAnkleLeft' ],
		'skirt':['mTorso', 'mPelvis', 'mPelvis', 'mHipRight', 'mKneeRight',
			'mPelvis', 'mHipLeft',  'mKneeLeft' ]
	}[ name ]
	cn = {
		'hair':['mHead', None],
		'head':['mHead', None],
		'upperBody':['mTorso', 'mChest', 'mNeck', None,
				'mCollarLeft', 'mShoulderLeft',
				'mElbowLeft', 'mWristLeft', None,
				'mElbowRight', 'mWristRight', None],
		'lowerBody':['mHipRight', 'mKneeRight', 'mAnkleRight', None,
			'mHipLeft', 'mKneeLeft', 'mAnkleLeft', None ],
		'skirt':[ 'mPelvis', None, 'mHipRight', 'mKneeRight', None,
			'mHipLeft', 'mKneeLeft', None ]
	for j in llm['skinJoints']:
		mesh.addVertGroup( j )
	for i in xrange( len(llm['weights'] )):
		b, w = llm['weights'][ i ]
		mesh.assignVertsToGroup( jn[ b - 1 ], [ i ], 1.0 - w, mode )
		if cn[b-1] != None:
			if w != 0.0:
				mesh.assignVertsToGroup( cn[ b - 1 ], [ i ], w, mode )

More information about the SLDev mailing list