def getJointSizeAndCentre(joints, threshold=0.65, space=SPACE_OBJECT): ''' minor modification to the getJointSize function in rigging.utils - uses the child of the joint[ 0 ] (if any exist) to determine the size of the joint in the axis aiming toward ''' centre = Vector.Zero(3) if not isinstance(joints, (list, tuple)): joints = [joints] joints = [str(j) for j in joints if j is not None] if not joints: return Vector((1, 1, 1)) size, centre = rigUtils.getJointSizeAndCentre(joints, threshold, space) if size.within(Vector.Zero(3), 1e-2): while threshold > 1e-2: threshold *= 0.9 size, centre = rigUtils.getJointSizeAndCentre(joints, threshold) if size.within(Vector.Zero(3), 1e-2): size = Vector((1, 1, 1)) children = listRelatives(joints[0], pa=True, type='transform') if children: childPos = Vector([0.0, 0.0, 0.0]) childPosMag = childPos.get_magnitude() for child in children: curChildPos = Vector(xform( child, q=True, ws=True, rp=True)) - Vector( xform(joints[0], q=True, ws=True, rp=True)) curChildPosMag = curChildPos.get_magnitude() if curChildPosMag > childPosMag: childPos = curChildPos childPosMag = curChildPosMag axis = rigUtils.getObjectAxisInDirection(joints[0], childPos, DEFAULT_AXIS) axisValue = getAttr('%s.t%s' % (children[0], axis.asCleanName())) if space == SPACE_WORLD: axis = Axis.FromVector(childPos) size[axis % 3] = abs(axisValue) centre[axis % 3] = axisValue / 2.0 return size, centre
def getJointSizeAndCentre( joints, threshold=0.65, space=SPACE_OBJECT ): ''' minor modification to the getJointSize function in rigging.utils - uses the child of the joint[ 0 ] (if any exist) to determine the size of the joint in the axis aiming toward ''' centre = Vector.Zero( 3 ) if not isinstance( joints, (list, tuple) ): joints = [ joints ] joints = [ str( j ) for j in joints if j is not None ] if not joints: return Vector( (1, 1, 1) ) size, centre = rigUtils.getJointSizeAndCentre( joints, threshold, space ) if size.within( Vector.Zero( 3 ), 1e-2 ): while threshold > 1e-2: threshold *= 0.9 size, centre = rigUtils.getJointSizeAndCentre( joints, threshold ) if size.within( Vector.Zero( 3 ), 1e-2 ): size = Vector( (1, 1, 1) ) children = listRelatives( joints[ 0 ], pa=True, type='transform' ) if children: childPos = Vector( [ 0.0, 0.0, 0.0 ] ) childPosMag = childPos.get_magnitude() for child in children: curChildPos = Vector( xform( child, q=True, ws=True, rp=True ) ) - Vector( xform( joints[ 0 ], q=True, ws=True, rp=True ) ) curChildPosMag = curChildPos.get_magnitude() if curChildPosMag > childPosMag: childPos = curChildPos childPosMag = curChildPosMag axis = rigUtils.getObjectAxisInDirection( joints[ 0 ], childPos, DEFAULT_AXIS ) axisValue = getAttr( '%s.t%s' % (children[ 0 ], axis.asCleanName()) ) if space == SPACE_WORLD: axis = Axis.FromVector( childPos ) size[ axis % 3 ] = abs( axisValue ) centre[ axis % 3 ] = axisValue / 2.0 return size, centre