Exemplo n.º 1
0
def form(self):
    _crv = CURVES.create_controlCurve(self.mNode,
                                      shape='circleArrow',
                                      direction='y+',
                                      sizeMode='fixed',
                                      size=self.baseSize)
    RIG.shapeParent_in_place(self.mNode, _crv, False)
    return True
Exemplo n.º 2
0
def template(self):
    _crv = CURVES.create_controlCurve(
        self.mNode,
        shape=self.getEnumValueString('basicShape'),
        direction='z+',
        sizeMode='fixed',
        size=self.baseSize)
    RIG.shapeParent_in_place(self.mNode, _crv, False)
    return True
def create(obj,parentTo = False):
    """   
    Create a spacePivot from a given object

    :parameters:
        *a(varied): - Uses validate_arg 

    :returns
        mSpacePivot(metaList)
    """ 
    _str_func = 'create'
    
    #....inital...
    i_obj = cgmMeta.validateObjArg(obj,cgmMeta.cgmObject,noneValid=False)    
    i_parent = cgmMeta.validateObjArg(parentTo,cgmMeta.cgmObject,noneValid=True)    
    bbSize = DIST.get_bb_size(i_obj.mNode)
    size = max(bbSize)

    #>>>Create #====================================================
    #CURVES.create_controlCurve(i_obj.mNode,'jack')
    i_control = cgmMeta.asMeta(CURVES.create_controlCurve(i_obj.mNode,'jack',sizeMode='guess')[0],'cgmObject',setClass=True)
    log.debug(i_control)
    try:l_color = curves.returnColorsFromCurve(i_obj.mNode)
    except Exception,error:raise Exception,"color | %s"%(error)          
    log.debug("l_color: %s"%l_color)
    curves.setColorByIndex(i_control.mNode,l_color[0])
    
    #>>>Snap and Lock
    #====================================================	
    #Snap.go(i_control,i_obj.mNode,move=True, orient = True)

    #>>>Copy Transform
    #====================================================   
    i_newTransform = i_obj.doCreateAt()

    #Need to move this to default cgmNode stuff
    mBuffer = i_control
    i_newTransform.doCopyNameTagsFromObject(i_control.mNode)
    curves.parentShapeInPlace(i_newTransform.mNode,i_control.mNode)#Parent shape
    i_newTransform.parent = mBuffer.parent#Copy parent
    i_control = i_newTransform
    mc.delete(mBuffer.mNode)
    
    #>>>Register
    #====================================================    
    #Attr
    i = ATTR.get_nextAvailableSequentialAttrIndex(i_obj.mNode,"pivot")
    str_pivotAttr = str("pivot_%s"%i)
    str_objName = str(i_obj.getShortName())
    str_pivotName = str(i_control.getShortName())
    
    #Build the network
    i_obj.addAttr(str_pivotAttr,enumName = 'off:lock:on', defaultValue = 2, value = 0, attrType = 'enum',keyable = False, hidden = False)
    i_control.overrideEnabled = 1
    d_ret = NodeF.argsToNodes("%s.overrideVisibility = if %s.%s > 0"%(str_pivotName,str_objName,str_pivotAttr)).doBuild()
    log.debug(d_ret)
    d_ret = NodeF.argsToNodes("%s.overrideDisplayType = if %s.%s == 2:0 else 2"%(str_pivotName,str_objName,str_pivotAttr)).doBuild()
    
    for shape in mc.listRelatives(i_control.mNode,shapes=True,fullPath=True):
        log.debug(shape)
        mc.connectAttr("%s.overrideVisibility"%i_control.mNode,"%s.overrideVisibility"%shape,force=True)
        mc.connectAttr("%s.overrideDisplayType"%i_control.mNode,"%s.overrideDisplayType"%shape,force=True)
    
    #Vis 
    #>>>Name stuff
    #====================================================
    cgmMeta.cgmAttr(i_control,'visibility',lock=True,hidden=True)   
    i_control = cgmMeta.validateObjArg(i_control,'cgmControl',setClass = True)
    i_control.doStore('cgmName',i_obj)
    i_control.addAttr('cgmType','controlAnim',lock=True)    
    i_control.addAttr('cgmIterator',"%s"%i,lock=True)        
    i_control.addAttr('cgmTypeModifier','spacePivot',lock=True)

    i_control.doName(nameShapes=True)

    i_control.addAttr('cgmAlias',(i_obj.getNameAlias()+'_pivot_%s'%i),lock=False)
    
    #Store on object
    #====================================================    
    i_obj.addAttr("spacePivots", attrType = 'message',lock=True)
    _l_spacePivots = i_obj.getMessage('spacePivots',True) or []
    if i_control.getLongName() not in _l_spacePivots:
        #_l_spacePivots = i_obj.getMessage('spacePivots',True)
        #_l_spacePivots.append(i_control.mNode)
        i_obj.msgList_append('spacePivots',i_control,'controlTarget')
    log.debug("spacePivots: %s"%i_obj.msgList_get('spacePivots',asMeta = True))

    #parent
    if i_parent:
        i_control.parent = i_parent.mNode
        i_constraintGroup = (cgmMeta.asMeta(i_control.doGroup(True),'cgmObject',setClass=True))
        i_constraintGroup.addAttr('cgmTypeModifier','constraint',lock=True)
        i_constraintGroup.doName()
        i_control.connectChildNode(i_constraintGroup,'constraintGroup','groupChild')	

        log.debug("constraintGroup: '%s'"%i_constraintGroup.getShortName())		

    #change to cgmControl
    i_control = cgmMeta.asMeta(i_control.mNode,'cgmControl', setClass=1)

    return i_control
Exemplo n.º 4
0
def resize_masterShape(self, sizeBy=None, resize=False):
    try:

        _short = self.p_nameShort
        _str_func = '[{0}] resize_masterShape'.format(_short)
        log.debug("|{0}| >> ".format(_str_func) + '-' * 80)
        _sel = mc.ls(sl=True)
        _bb = False
        _bb = self.baseSize

        if resize:
            if _sel:
                _bb = TRANS.bbSize_get(_sel, False)
            #elif self.getBlockChildren():
            #    sizeBy = mc.ls(self.getBlockChildren(asMeta=False))
            #    _bb = TRANS.bbSize_get(sizeBy,False)
            self.baseSize = _bb

        log.debug("|{0}| >> _bb: {1}".format(_str_func, _bb))

        mHandleFactory = self.asHandleFactory(_short)
        mc.delete(self.getShapes())

        _average = MATH.average([_bb[0], _bb[2]])
        _size = _average * 1.5
        _offsetSize = _average * .01
        _blockScale = self.blockScale
        mFormNull = self.atUtils('stateNull_verify', 'form')
        mNoTransformNull = self.atUtils('noTransformNull_verify', 'form')

        if resize or self.controlOffset == .9999:
            self.controlOffset = _offsetSize

        #Main curve ===========================================================================
        _crv = CURVES.create_fromName(name='circle', direction='y+', size=1)
        mCrv = cgmMeta.asMeta(_crv)
        SNAP.go(mCrv.mNode, self.mNode, rotation=False)
        TRANS.scale_to_boundingBox(mCrv.mNode, [_bb[0], None, _bb[2]])

        #mDup = mCrv.doDuplicate(po=False)
        #mDup.p_position = MATH.list_add(mDup.p_position, [0,_offsetSize,0])

        RIG.shapeParent_in_place(self.mNode, _crv, False)
        #RIG.shapeParent_in_place(self.mNode,mDup.mNode,False)

        mHandleFactory.color(self.mNode, 'center', 'main', transparent=False)

        #Bounding box ==================================================================
        if self.getMessage('bbHelper'):
            self.bbHelper.delete()

        _bb_shape = CURVES.create_controlCurve(self.mNode,
                                               'cubeOpen',
                                               size=1,
                                               sizeMode='fixed')
        _bb_newSize = MATH.list_mult(self.baseSize,
                                     [_blockScale, _blockScale, _blockScale])
        TRANS.scale_to_boundingBox(_bb_shape, _bb_newSize)
        mBBShape = cgmMeta.validateObjArg(_bb_shape,
                                          'cgmObject',
                                          setClass=True)
        mBBShape.p_parent = mFormNull

        mBBShape.inheritsTransform = False
        mc.parentConstraint(self.mNode, mBBShape.mNode, maintainOffset=False)

        SNAPCALLS.snap(mBBShape.mNode,
                       self.mNode,
                       objPivot='axisBox',
                       objMode='y-')

        CORERIG.copy_pivot(mBBShape.mNode, self.mNode)
        self.doConnectOut('baseSize', "{0}.scale".format(mBBShape.mNode))
        #mHandleFactory.color(mBBShape.mNode,controlType='sub')
        mBBShape.setAttrFlags()

        mBBShape.doStore('cgmName', self)
        mBBShape.doStore('cgmType', 'bbVisualize')
        mBBShape.doName()
        mBBShape.template = True
        self.connectChildNode(mBBShape.mNode, 'bbHelper')

        #Offset visualize ==================================================================
        if self.getMessage('offsetHelper'):
            self.offsetHelper.delete()

        #Need to guess our offset size based on bounding box volume

        mShape = self.getShapes(asMeta=True)[0]
        l_return = mc.offsetCurve(mShape.mNode, distance=1, ch=True)
        #pprint.pprint(l_return)
        mHandleFactory.color(l_return[0], 'center', 'sub', transparent=False)

        mOffsetShape = cgmMeta.validateObjArg(l_return[0],
                                              'cgmObject',
                                              setClass=True)
        mOffsetShape.p_parent = mNoTransformNull
        #mOffsetShape.doSnapTo(self)
        #mc.pointConstraint(self.mNode,mOffsetShape.mNode,maintainOffset=True)
        #mc.orientConstraint(self.mNode,mOffsetShape.mNode,maintainOffset=True)
        mOffsetShape.inheritsTransform = False

        mOffsetShape.dagLock()

        _arg = '{0}.distance = -{1}.controlOffset'.format(
            l_return[1], self.mNode)
        NODEFACTORY.argsToNodes(_arg).doBuild()
        #self.doConnectOut('controlOffset',"{0}.distance".format(l_return[1]))

        mOffsetShape.doStore('cgmName', self)
        mOffsetShape.doStore('cgmType', 'offsetVisualize')
        mOffsetShape.doName()

        self.connectChildNode(mOffsetShape.mNode, 'offsetHelper')

        return
        #Offset visualize ==================================================================
        if self.getMessage('offsetHelper'):
            self.offsetHelper.delete()

        mShape = self.getShapes(asMeta=True)[0]
        l_return = mc.offsetCurve(mShape.mNode, distance=1, ch=True)
        #pprint.pprint(l_return)
        mHandleFactory.color(l_return[0], 'center', 'sub', transparent=False)

        mOffsetShape = cgmMeta.validateObjArg(l_return[0],
                                              'cgmObject',
                                              setClass=True)
        mOffsetShape.p_parent = mFormNull

        mOffsetShape.inheritsTransform = False
        mc.parentConstraint(self.mNode,
                            mOffsetShape.mNode,
                            maintainOffset=False)

        #mOffsetShape.setAttrFlags()

        _arg = '{0}.distance = -{1}.controlOffset * {1}.blockScale'.format(
            l_return[1], self.mNode)
        NODEFACTORY.argsToNodes(_arg).doBuild()
        #self.doConnectOut('controlOffset',"{0}.distance".format(l_return[1]))

        mOffsetShape.doStore('cgmName', self)
        mOffsetShape.doStore('cgmType', 'offsetVisualize')
        mOffsetShape.doName()

        self.connectChildNode(mOffsetShape.mNode, 'offsetHelper')

        return

        _crv = CURVES.create_fromName(name='squareOpen',
                                      direction='y+',
                                      size=1)
        TRANS.scale_to_boundingBox(_crv, [_bb[0], None, _bb[2]])

        mHandleFactory.color(_crv, 'center', 'sub', transparent=False)

        mCrv = cgmMeta.validateObjArg(_crv, 'cgmObject')
        l_offsetCrvs = []
        for shape in mCrv.getShapes():
            offsetShape = mc.offsetCurve(shape, distance=-_offsetSize,
                                         ch=True)[0]
            mHandleFactory.color(offsetShape,
                                 'center',
                                 'main',
                                 transparent=False)
            l_offsetCrvs.append(offsetShape)

        RIG.combineShapes(l_offsetCrvs + [_crv], True)
        SNAP.go(_crv, self.mNode)

        RIG.shapeParent_in_place(self.mNode, _crv, True)

        self.baseSize = _bb

        #Bounding box ==================================================================
        if self.getMessage('offsetVisualize'):
            self.bbVisualize.delete()

        _bb_shape = CURVES.create_controlCurve(self.mNode,
                                               'cubeOpen',
                                               size=1.0,
                                               sizeMode='fixed')
        mBBShape = cgmMeta.validateObjArg(_bb_shape,
                                          'cgmObject',
                                          setClass=True)
        mBBShape.p_parent = mFormNull

        SNAPCALLS.snap(mBBShape.mNode,
                       self.mNode,
                       objPivot='axisBox',
                       objMode='y-')

        CORERIG.copy_pivot(mBBShape.mNode, self.mNode)
        self.doConnectOut('baseSize', "{0}.scale".format(mBBShape.mNode))
        mHandleFactory.color(mBBShape.mNode, controlType='sub')
        mBBShape.setAttrFlags()

        mBBShape.doStore('cgmName', self)
        mBBShape.doStore('cgmType', 'bbVisualize')
        mBBShape.doName()

        self.connectChildNode(mBBShape.mNode, 'bbHelper')

        return True

    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err, localDat=vars())
Exemplo n.º 5
0
        #_average = MATH.average([self.baseSize[0],self.baseSize[2]])
        #_size = _average * 1.5
        #_offsetSize = _average * .1
        #log.info(_size)

        #mHandleFactory = self.asHandleFactory(_short)
        mc.select(cl=True)
        resize_masterShape(self)

        return True
    except Exception, err:
        cgmGEN.cgmExceptCB(Exception, err, localDat=vars())

    _crv = CURVES.create_controlCurve(self.mNode,
                                      shape='squareOpen',
                                      direction='y+',
                                      sizeMode='fixed',
                                      size=1)
    TRANS.scale_to_boundingBox(_crv,
                               [self.baseSize[0], None, self.baseSize[2]])

    mHandleFactory.color(_crv, 'center', 'sub', transparent=False)

    mCrv = cgmMeta.validateObjArg(_crv, 'cgmObject')
    l_offsetCrvs = []
    for shape in mCrv.getShapes():
        offsetShape = mc.offsetCurve(shape, distance=-_offsetSize, ch=False)[0]
        mHandleFactory.color(offsetShape, 'center', 'main', transparent=False)

        l_offsetCrvs.append(offsetShape)
Exemplo n.º 6
0
cgm.core._reload()

RBLOCKS.get_modules_dat()  #...also reloads

b1 = RBLOCKS.cgmRigBlock(blockType='handle')
b1 = cgmMeta.asMeta('handle_block')
b1.p_blockState = 'define'
b1.p_blockState = 'template'
b1.p_blockState = 'prerig'

reload(cgm.core.lib.rigging_utils)

import cgm.core.lib.curve_Utils as CURVES
reload(CURVES)
CURVES.create_fromName('squareOpen', size=1)
CURVES.create_controlCurve(b1.mNode, 'circle')

#>>>Skeleton ---------------------------------------------------------------------------------------
b1.atBlockModule('build_skeleton')
b1.atBlockUtils('skeleton_getCreateDict')

#>>>Rig process
b1.verify()
mRigFac = RBLOCKS.rigFactory(b1)
mRigFac.log_self()  #>>uses pprint
mRigFac.mRigNull.fkHeadJoint
pprint.pprint(b1.__dict__)
mRigFac.mRigNull.headFK.dynParentGroup
mRigFac.atBlockModule('rig_skeleton')

mRigFac.atBlockModule('build_proxyMesh', False)  #must have rig joints
Exemplo n.º 7
0
    def chain_create(self, objs = None,
                     fwd = None, up=None,
                     name = None,
                     upSetup = "guess",
                     extendStart = None,
                     extendEnd = True,
                     mNucleus=None,
                     upControl = None,
                     aimUpMode = None,
                     **kws):
        
        _str_func = 'chain_create'
        
        if not objs:
            _sel = mc.ls(sl=1)
            if _sel:objs = _sel
        
        ml = cgmMeta.asMeta( objs, noneValid = True )
        ml_baseTargets = copy.copy(ml)
        
        if not ml:
            return log.warning("No objects passed. Unable to chain_create")
            
        if not name:
            name = ml[-1].p_nameBase
                    
        _idx = self.get_nextIdx()
        

        #Make our sub group...
        mGrp = self.doCreateAt(setClass=1)
        mGrp.p_parent = self
        mGrp.rename("chain_{0}_grp".format(name))
        mGrp.dagLock()
        self.connectChildNode(mGrp.mNode,'chain_{0}'.format(_idx),'owner')
        
        
        #holders and dat...
        ml_targets = []
        ml_posLocs = []
        ml_aim_locs = []
        
        fwd = fwd or self.fwd
        up = up or self.up
        upSetup = upSetup or self.upSetup
        extendStart = extendStart or self.extendStart
        extendEnd = extendEnd or self.extendEnd
        upControl = upControl or self.upControl
        aimUpMode = aimUpMode or self.aimUpMode
        
        #fwdAxis = simpleAxis(fwd)
        #upAxis = simpleAxis(up)

        fwdAxis = TRANS.closestAxisTowardObj_get(ml[0], ml[1])
        upAxis = TRANS.crossAxis_get(fwdAxis)

        mGrp.doStore('fwd', fwdAxis.p_string)
        mGrp.doStore('up', upAxis.p_string)

        #Curve positions...
        l_pos = []
        
        if upSetup == 'manual':
            if len(ml) < 2:
                log.debug(cgmGEN.logString_msg(_str_func, 'Single count. Adding extra handle.'))
                mLoc = ml[0].doLoc()
                mLoc.rename("chain_{0}_end_loc".format(name))
                _size = DIST.get_bb_size(ml[0],True,'max')
                mLoc.p_position = ml[0].getPositionByAxisDistance(fwdAxis.p_string,_size)
                ml.append(mLoc)
                mLoc.p_parent = mGrp
            
            for obj in ml:
                l_pos.append(obj.p_position)
                
                
            _v_baseDist = DIST.get_distance_between_points(l_pos[-1],l_pos[-2])
            _v_baseDist = MATHUTILS.Clamp(_v_baseDist, .5,None)

            _p_baseExtend = DIST.get_pos_by_axis_dist(ml[-1],
                                                      fwdAxis.p_string,
                                                      _v_baseDist)
            
            
            if extendEnd:
                log.debug(cgmGEN.logString_msg(_str_func, 'extendEnd...'))
                
                extendEnd = VALID.valueArg(extendEnd)
                
                if issubclass(type(extendEnd),bool):#VALID.boolArg(extendEnd):
                    log.debug(cgmGEN.logString_msg(_str_func, 'extendEnd | guess'))
                    l_pos.append(_p_baseExtend)
                elif extendEnd:
                    log.debug(cgmGEN.logString_msg(_str_func, 'extendEnd | {0}'.format(extendEnd)))
                    
                    l_pos.append( DIST.get_pos_by_axis_dist(ml[-1],
                                                            fwdAxis.p_string,
                                                            extendEnd ))                            
            else:
                l_pos.append( _p_baseExtend)
        
            if extendStart:
                f_extendStart = VALID.valueArg(extendStart)
                if f_extendStart:
                    l_pos.insert(0, DIST.get_pos_by_axis_dist(ml[0],
                                                              fwdAxis.inverse.p_string,
                                                              f_extendStart ))
                    
        else:
            log.debug(cgmGEN.logString_msg(_str_func, 'Resolving aim'))
            if len(ml) < 2:
                return log.error(cgmGEN.logString_msg(_str_func, 'Single count. Must use manual upSetup and aim/up args'))
            
            for obj in ml:
                l_pos.append(obj.p_position)
            
            _vecEnd = MATHUTILS.get_vector_of_two_points(l_pos[-2],l_pos[-1])
            if extendEnd:
                log.debug(cgmGEN.logString_msg(_str_func, 'extendEnd...'))
                
                extendEnd = VALID.valueArg(extendEnd)
                
                if issubclass(type(extendEnd),bool):#VALID.boolArg(extendEnd):
                    log.debug(cgmGEN.logString_msg(_str_func, 'extendEnd | guess'))
                    
                    l_pos.append( DIST.get_pos_by_vec_dist(l_pos[-1], _vecEnd,
                                                           (DIST.get_distance_between_points(l_pos[-2],l_pos[-1])/2)))
                elif extendEnd:
                    log.debug(cgmGEN.logString_msg(_str_func, 'extendStart | {0}'.format(extendEnd)))
                    
                    l_pos.append( DIST.get_pos_by_vec_dist(l_pos[-1], _vecEnd,
                                                           extendEnd))
            
            if extendStart:
                f_extendStart = VALID.valueArg(extendStart)
                if f_extendStart:
                    log.debug(cgmGEN.logString_msg(_str_func, 'extendStart...'))
                    
                    _vecStart = MATHUTILS.get_vector_of_two_points(l_pos[1],l_pos[0])
                    
                    l_pos.insert(0, DIST.get_pos_by_vec_dist(l_pos[0],
                                                             _vecStart,
                                                             f_extendStart))

        #pprint.pprint(l_pos)
        
        #for i,p in enumerate(l_pos):
        #    LOC.create(position=p,name='p_{0}'.format(i))
            
        crv = CORERIG.create_at(create='curve',l_pos= l_pos, baseName = name)
        mInCrv = cgmMeta.asMeta(crv)
        mInCrv.rename("{0}_inCrv".format(name))
        mGrp.connectChildNode(mInCrv.mNode,'mInCrv')
        mc.select(cl=1)

        # make the dynamic setup
        log.debug(cgmGEN.logString_sub(_str_func,'dyn setup'))
        b_existing = False
        b_existing_nucleus = False
        
        mHairSys = self.getMessageAsMeta('mHairSysShape')
        if mHairSys:
            mHairSysDag = mHairSys.getTransform(asMeta=1)
            log.info(cgmGEN.logString_msg(_str_func,'Using existing system: {0}'.format(mHairSys.mNode)))
            mc.select(mHairSysDag.mNode, add=True)
            b_existing = True
            
        if self.useExistingNucleus or mNucleus:
            mNucleus = self.get_nucleus(mNucleus)
            if mNucleus:
                #mc.select(mNucleus.mNode,add=1)
                b_existing_nucleus = True
                log.info(cgmGEN.logString_msg(_str_func,'Using existing nucleus: {0}'.format(mNucleus.mNode)))
                self.connectChildNode(mNucleus.mNode,'mNucleus')
        
        mc.select(mInCrv.mNode,add=True)
        mel.eval('makeCurvesDynamic 2 { "0", "0", "1", "1", "0" }')

        # get relevant nodes
        follicle = mc.listRelatives(mInCrv.mNode,parent=True)[0]
        mFollicle = cgmMeta.asMeta(follicle)
        mFollicle.rename("{0}_foll".format(name))
        parent = mFollicle.getParent(asMeta=1)
        mFollicle.p_parent = mGrp
        mFollicleShape = mFollicle.getShapes(1)[0]
        mc.delete(parent.mNode)
        
        _follicle = mFollicle.mNode
        mGrp.connectChildNode(mFollicle.mNode,'mFollicle','group')
        
        follicleShape = mFollicleShape.mNode#mc.listRelatives(mFollicle.mNode, shapes=True)[0]
        _hairSystem = mc.listRelatives( mc.listConnections('%s.currentPosition' % follicleShape)[0],
                                        shapes=True)[0]
        if not b_existing:
            mHairSys = cgmMeta.asMeta(_hairSystem)
            mHairSysDag = mHairSys.getTransform(asMeta=1)
            
            mHairSysDag.rename("{0}_hairSys".format(self.baseName))
            self.connectChildNode(mHairSysDag.mNode,'mHairSysDag','owner')
            self.connectChildNode(mHairSys.mNode,'mHairSysShape','owner')
            
            mHairSysDag.p_parent = self
            _hairSystem = mHairSys.mNode
            
        outCurve = mc.listConnections('%s.outCurve' % _follicle)[0]
        mCrv = cgmMeta.asMeta(outCurve)
        parent = mCrv.getParent(asMeta=1)

        outCurveShape = mc.listRelatives(mCrv.mNode, shapes=True)[0]
        mCrv.p_parent = mGrp.mNode
        
        mc.delete(parent.mNode)
        _nucleus = mc.listConnections( '%s.currentState' % mHairSys.mNode )[0]
        
        if not b_existing_nucleus:
            mNucleus = cgmMeta.asMeta(_nucleus)
            mNucleus.rename("cgmDynFK_nucleus")            
            #self.connectChildNode(mNucleus.mNode,'mNucleus','owner')
            self.connectChildNode(mNucleus.mNode,'mNucleus')
            
            if self.startFrame is not None:
                mNucleus.startFrame = self.startFrame
        else:
            #Because maya is crappy we gotta manually wire the existing nucleus
            ##startFrame out to startFrame in
            ##outputObjects[x] - nextState
            ##shape.currentState>inputActive[x]
            ##shape.startState>inputActiveStart[x]
            if cgmMeta.asMeta(_nucleus).mNode != mNucleus.mNode:
                mc.delete(_nucleus)

            _useNucleus = mNucleus.mNode

            """
            _useIdx = ATTR.get_nextCompoundIndex(mNucleus.mNode,'outputObjects')
            log.info("useIdx: {0}".format(_useIdx))
            ATTR.connect('{0}.outputObjects[{1}]'.format(_useNucleus,_useIdx),'{0}.nextState'.format(_hairSystem))
            ATTR.connect('{0}.currentState'.format(_hairSystem),'{0}.inputActive[{1}]'.format(_useNucleus,_useIdx))
            ATTR.connect('{0}.startState'.format(_hairSystem),'{0}.inputActiveStart[{1}]'.format(_useNucleus,_useIdx))"""            
            
            
        mParent = ml[0].getParent(asMeta=1)
        if not mParent:
            mParent = ml[0].doGroup(1,1,
                                    asMeta=True,
                                    typeModifier = 'dynFKParent',
                                    setClass='cgmObject')
        #else:
            #mParent.getParent(asMeta=1)
        
        mGrp.connectChildNode(mCrv.mNode,'mOutCrv','group')

        #self.follicles.append(follicle)
        #self.outCurves.append(outCurve)
        
        # set default properties
        mFollicleShape.pointLock = 1
        #mc.setAttr( '%s.pointLock' % follicleShape, 1 )
        mc.parentConstraint(ml[0].getParent(), _follicle, mo=True)
        
        # create locators on objects
        locators = []
        prs = []
        
        ml_locs = []
        ml_aims = []
        ml_prts = []
        
        _upVector = None
        if upSetup == 'guess':
            log.debug(cgmGEN.logString_msg(_str_func, 'Resolving up/aim'))
            poci_base = CURVES.create_pointOnInfoNode(mInCrv.mNode,1)
            mPoci_base = cgmMeta.asMeta(poci_base)
            
            _upVector = mPoci_base.normalizedNormal
            log.debug(cgmGEN.logString_msg(_str_func, "upVector: {0}".format(_upVector)))        
        
        
        #Let's make an up object as the parent of the root isn't good enough
        mUp = ml[0].doCreateAt(setClass=1)
        mUp.rename("chain_{0}_up".format(name))
        mUp.p_parent = mGrp
        
        if _upVector:
            SNAP.aim_atPoint(mUp.mNode,
                             DIST.get_pos_by_vec_dist(mUp.p_position,
                                                      _upVector,
                                                      10),aimAxis='y+',upAxis='z+')
        
        if upControl:
            log.debug(cgmGEN.logString_msg(_str_func,'upControl'))
            if len(ml_baseTargets)>1:
                sizeControl = DIST.get_distance_between_targets([mObj.mNode for mObj in ml_baseTargets],True)
            else:
                sizeControl = DIST.get_bb_size(ml[0],True,'max')
                
            crv = CURVES.create_controlCurve(mUp.mNode,'arrowSingle', size= sizeControl, direction = 'y+')
            CORERIG.shapeParent_in_place(mUp.mNode, crv, False)
            mUpGroup = mUp.doGroup(True,True,
                                   asMeta=True,
                                   typeModifier = 'master',
                                   setClass='cgmObject')
            
            mc.parentConstraint(ml[0].getParent(), mUpGroup.mNode, mo=True)
            
            
        else:
            mc.parentConstraint(ml[0].getParent(), mUp.mNode, mo=True)
            
        
        # create control joint chain
        mc.select(cl=True)
        chain = []
        for obj in ml:
            if len(chain) > 0:
                mc.select(chain[-1])
            jnt = mc.joint(name='%s_%s_jnt' % (name, obj.p_nameBase))
            SNAP.matchTarget_set(jnt, obj.mNode)
            mObj = cgmMeta.asMeta(jnt)
            mObj.doSnapTo(mObj.getMessageAsMeta('cgmMatchTarget'))

            chain.append(jnt)

        mc.parent(chain[0], _follicle)
        mInCrv.p_parent = mGrp

        mc.bindSkin(mInCrv.mNode, chain[0], ts=True)


        log.debug(cgmGEN.logString_msg(_str_func,'aimUpMode: {0}'.format(aimUpMode)))
        
        
        for i, mObj in enumerate(ml):
            if not i:
                mUpUse = mUp
            else:
                mUpUse = ml_locs[-1]
                
            mLoc = cgmMeta.asMeta( LOC.create(mObj.getNameLong()) )
            loc = mLoc.mNode
            ml_locs.append(mLoc)
            #loc = LOC.create(mObj.getNameLong())
            
            mAim = mLoc.doGroup(False,False,
                                 asMeta=True,
                                 typeModifier = 'aim',
                                 setClass='cgmObject')
            ml_aims.append(mAim)
            #aimNull = mc.group(em=True)
            #aimNull = mc.rename('%s_aim' % mObj.getShortName())
            
            poc = CURVES.create_pointOnInfoNode(outCurveShape)
#mc.createNode('pointOnCurveInfo', name='%s_pos' % loc)
            mPoci_obj = cgmMeta.asMeta(poc)
            mPoci_obj.rename('%s_pos' % loc)
            pocAim = CURVES.create_pointOnInfoNode(outCurveShape)
            #mc.createNode('pointOnCurveInfo', name='%s_aim' % loc)
            
            pr = CURVES.getUParamOnCurve(loc, outCurve)
            mPoci_obj.parameter = pr
            
            #mc.connectAttr( '%s.worldSpace[0]' % outCurveShape, '%s.inputCurve' % poc, f=True )
            #mc.connectAttr( '%s.worldSpace[0]' % outCurveShape, '%s.inputCurve' % pocAim, f=True )

            #mc.setAttr( '%s.parameter' % poc, pr )
            
            if i < len(ml)-1:
                nextpr = CURVES.getUParamOnCurve(ml[i+1], outCurve)
                mc.setAttr('%s.parameter' % pocAim, (nextpr))# + pr))# * .5)
            else:
                if extendStart:
                    mc.setAttr( '%s.parameter' % pocAim, len(ml)+1 )                    
                else:
                    mc.setAttr( '%s.parameter' % pocAim, len(ml) )
                    
                    
            
            mLocParent = mLoc.doGroup(False,False,
                                      asMeta=True,
                                      typeModifier = 'pos',
                                      setClass='cgmObject')
            ml_prts.append(mLocParent)
            #locParent = mc.group(em=True)
            #locParent = mc.rename( '%s_pos' % mObj.getShortName() )

            mc.connectAttr( '%s.position' % mPoci_obj.mNode, '%s.translate' % mLocParent.mNode)
            mc.connectAttr( '%s.position' % pocAim, '%s.translate' % mAim.mNode)
            
            
            
            if aimUpMode == 'master':
                aimConstraint = mc.aimConstraint( mAim.mNode,
                                                  mLocParent.mNode,
                                                  aimVector=fwdAxis.p_vector,
                                                  upVector = upAxis.p_vector,
                                                  worldUpType = "objectrotation",
                                                  worldUpVector = upAxis.p_vector,
                                                  worldUpObject = mUp.mNode )
            elif aimUpMode == 'orientToMaster':
                mc.orientConstraint( mUp.mNode,
                                     mLocParent.mNode,
                                     maintainOffset = 1)
                
            elif aimUpMode == 'sequential':
                aimConstraint = mc.aimConstraint( mAim.mNode,
                                                  mLocParent.mNode,
                                                  aimVector=fwdAxis.p_vector,
                                                  upVector = upAxis.p_vector,
                                                  worldUpType = "objectrotation",
                                                  worldUpVector = upAxis.p_vector,
                                                  worldUpObject = mUpUse.mNode )                
            elif aimUpMode == 'joint':
                aimConstraint = mc.aimConstraint( mAim.mNode,
                                                  mLocParent.mNode,
                                                  aimVector=fwdAxis.p_vector,
                                                  upVector = upAxis.p_vector,
                                                  worldUpType = "objectrotation",
                                                  worldUpVector = upAxis.p_vector,
                                                  worldUpObject = chain[i] )  
            elif aimUpMode == 'curveNormal':
                mUpLoc = mLoc.doGroup(False,False,
                                      asMeta=True,
                                      typeModifier = 'up',
                                      setClass='cgmObject')
                mUpLoc.p_parent = mLocParent
                
                aimConstraint = mc.aimConstraint( mAim.mNode,
                                                  mLocParent.mNode,
                                                  aimVector=fwdAxis.p_vector,
                                                  upVector = upAxis.p_vector,
                                                  worldUpType = "object")
                
                mPlusMinusAverage = cgmMeta.cgmNode(name="{0}_pma".format(mObj.p_nameBase),
                                                    nodeType = 'plusMinusAverage')
                mPlusMinusAverage.operation = 3
                
                mPoci_obj.doConnectOut('position','{0}.input3D[0]'.format(mPlusMinusAverage.mNode))
                mPoci_obj.doConnectOut('normalizedNormal','{0}.input3D[1]'.format(mPlusMinusAverage.mNode))
                mUpLoc.doConnectIn('translate','{0}.output3D'.format(mPlusMinusAverage.mNode))

            
            
            mLoc.p_parent = mLocParent
            mAim.p_parent = mGrp
            mLocParent.p_parent = mGrp
            
            #mc.parent(loc, locParent)
        
        mCrv.rename("{0}_outCrv".format(name))
        mCrvParent = mCrv.getParent(asMeta=1)
        mCrvParent.p_parent = mGrp
        
        mGrp.msgList_connect('mLocs',ml_locs)
        mGrp.msgList_connect('mAims',ml_aims)
        mGrp.msgList_connect('mParents',ml_prts)
        mGrp.msgList_connect('mTargets',ml)
        mGrp.msgList_connect('mBaseTargets',ml_baseTargets)
        mGrp.msgList_connect('mObjJointChain',chain)
        mGrp.doStore('cgmName', name)

        mNucleus.doConnectOut('startFrame',"{0}.startFrame".format(mHairSys.mNode))