Beispiel #1
0
def treeBendingLookAtConnect( inputLookTarget, inputRotTarget ):
    
    lookTarget = pymel.core.ls( inputLookTarget )[0]
    rotTarget  = pymel.core.ls( inputRotTarget )[0]
    
    rotTargetBase = rotTarget.getParent()
    rotTargetList = rotTarget.listRelatives( c=1, ad=1, type='joint' )
    map( lambda x : sgCmds.makeParent( x ) if x.getParent().nodeType() == 'joint' else None, rotTargetList )
    rotTargetPoints = map( lambda x : sgCmds.putObject( x ), rotTargetList )
    map( lambda x : x.dh.set( 0 ), rotTargetPoints )
    rotTargetPointsBase = sgCmds.makeChild( rotTargetBase )
    rotTargetList.append( rotTarget )
    
    sgCmds.lookAtConnect( lookTarget, rotTargetPointsBase )
    sgCmds.makeParent( rotTargetPointsBase )
    pymel.core.parent( rotTargetPoints, rotTargetPointsBase )
    
    rotTargetList.reverse()
    rotTargetPoints.reverse()
    
    numRotTargets = len( rotTargetList )
    sgCmds.addAttr( lookTarget, ln='bendWeight', min=0, max=1, dv=1, k=1 )
    sgCmds.addAttr( lookTarget, ln='powRate', min=0, max=2, dv=1, k=1 )
    
    for i in range( len( rotTargetList )-1 ):
        powRateBaseValue = ( i + 1.0 )/numRotTargets
        rotTargetH = rotTargetList[i]
        rotTargetHBase = rotTargetH.getParent()
        rotTargetChild = rotTargetH.listRelatives( c=1 )[0]
        aimCuPointPiv = sgCmds.makeChild( rotTargetHBase )
        aimCuPointBase = sgCmds.makeChild( aimCuPointPiv )
        aimCuPoint = sgCmds.makeChild( aimCuPointBase )
        pymel.core.xform( aimCuPointPiv, ws=1, matrix=rotTargetH.wm.get() )
        pymel.core.xform( aimCuPointBase, ws=1, matrix=rotTargetChild.wm.get() )
        
        rotTargetPoint = rotTargetPoints[i]
        dcmp = sgCmds.getLocalDecomposeMatrix( rotTargetPoint.wm, aimCuPointBase.wim )
        sgCmds.addAttr( rotTargetH, ln='lookWeight', min=0, max=1, k=1, dv= 1.0/numRotTargets )
        
        multEnv = pymel.core.createNode( 'multDoubleLinear' )
        multPow = pymel.core.createNode( 'multiplyDivide' ); multPow.op.set( 3 )
        multPowAndEnv = pymel.core.createNode( 'multDoubleLinear' )
        multEnv.output >> multPowAndEnv.input1
        multPow.outputX >> multPowAndEnv.input2
        multPow.input1X.set( powRateBaseValue )
        lookTarget.powRate >> multPow.input2X
        
        rotTargetH.lookWeight >> multEnv.input1
        lookTarget.bendWeight >> multEnv.input2
        
        multTrans = pymel.core.createNode( 'multiplyDivide' )
        dcmp.outputTranslate >> multTrans.input1
        multPowAndEnv.output >> multTrans.input2X
        multPowAndEnv.output >> multTrans.input2Y
        multPowAndEnv.output >> multTrans.input2Z
        multTrans.output >> aimCuPoint.t
        sgCmds.lookAtConnect( aimCuPoint, rotTargetH )
    
    sgCmds.addAttr( lookTarget, ln='rotTarget', at='message' )
    rotTargetPointsBase.message >> lookTarget.rotTarget
Beispiel #2
0
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls( sl=1, fl=1 )
newObjects = []
for sel in sels:
    newObject = sgCmds.putObject( sel, 'null' )
    newObjects.append( newObject )
pymel.core.select( newObjects )
from sgMaya import sgCmds

sels = pymel.core.ls( sl=1, fl=1 )
edgeRings = sgCmds.getOrderedEdgeRings( sels[0] )

beforeObject = None
for edgeRing in edgeRings:
    pymel.core.select( edgeRing )
    cmds.SelectEdgeLoopSp()
    loopEdges = pymel.core.ls( sl=1, fl=1 )
    jnt = sgCmds.putObject( loopEdges, typ='joint' )
    if beforeObject:
        jnt.setParent( beforeObject )
    beforeObject = jnt
Beispiel #4
0
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls( sl=1 )
newObjs = []
for sel in sels:
    newObj = sgCmds.putObject( sel, 'joint' )
    sgCmds.constrain_parent( sel, newObj )
    newObjs.append( newObj )
pymel.core.select( newObjs )
Beispiel #5
0
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls( sl=1, fl=1 )
newObjects = []
for sel in sels:
    newObject = sgCmds.putObject( sel, 'locator' )
    newObjects.append( newObject )
pymel.core.select( newObjects )
Beispiel #6
0
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls(sl=1)
newObjs = []
for sel in sels:
    newObj = sgCmds.putObject(sel, 'joint')
    sgCmds.constrain_parent(sel, newObj)
    newObjs.append(newObj)
pymel.core.select(newObjs)
from sgMaya import sgCmds
from maya import cmds

sels = cmds.ls( sl=1 )
sgCmds.putObject( sels, 'null' )
Beispiel #8
0
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls(sl=1, fl=1)
newObjects = []
for sel in sels:
    newObject = sgCmds.putObject(sel, 'locator')
    newObjects.append(newObject)
pymel.core.select(newObjects)
from sgMaya import sgCmds
from maya import cmds

sels = cmds.ls(sl=1)
sgCmds.putObject(sels, 'locator')
Beispiel #10
0
from sgMaya import sgCmds

sels = pymel.core.ls(sl=1, fl=1)
edgeRings = sgCmds.getOrderedEdgeRings(sels[0])

beforeObject = None
for edgeRing in edgeRings:
    pymel.core.select(edgeRing)
    cmds.SelectEdgeLoopSp()
    loopEdges = pymel.core.ls(sl=1, fl=1)
    jnt = sgCmds.putObject(loopEdges, typ='joint')
    if beforeObject:
        jnt.setParent(beforeObject)
    beforeObject = jnt
Beispiel #11
0
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls(sl=1)
targets = []
for sel in sels:
    putTarget = sgCmds.putObject(sel, 'joint')
    putTarget.setParent(sel)

    selName = sel.split('|')[-1]
    childName = ''
    if selName[-1] == '_':
        childName = sel.nodeName() + 'child'
    else:
        childName = sel.nodeName() + '_child'
    putTarget.rename(childName)
    targets.append(putTarget)

pymel.core.select(targets)
Beispiel #12
0
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls( sl=1 )
targets = []
for sel in sels:
    putTarget = sgCmds.putObject( sel, 'null' ) 
    putTarget.setParent( sel )
    
    selName = sel.split('|')[-1]
    childName = ''
    if selName[-1] == '_':
        childName = sel.nodeName() + 'child'
    else:
        childName = sel.nodeName() + '_child'
    putTarget.rename( childName )
    targets.append( putTarget )

pymel.core.select( targets )
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls( sl=1 )
targets = []
for sel in sels:
    putTarget = sgCmds.putObject( sel, 'locator' ) 
    putTarget.setParent( sel )
    
    selName = sel.split('|')[-1]
    childName = ''
    if selName[-1] == '_':
        childName = sel.nodeName() + 'child'
    else:
        childName = sel.nodeName() + '_child'
    putTarget.rename( childName )
    targets.append( putTarget )

pymel.core.select( targets )
Beispiel #14
0
from sgMaya import sgCmds
from maya import cmds

sels = cmds.ls(sl=1)
sgCmds.putObject(sels, 'null')
Beispiel #15
0
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls(sl=1)
targets = []
for sel in sels:
    putTarget = sgCmds.putObject(sel, 'null')
    putTarget.setParent(sel)

    selName = sel.split('|')[-1]
    childName = ''
    if selName[-1] == '_':
        childName = sel.nodeName() + 'child'
    else:
        childName = sel.nodeName() + '_child'
    putTarget.rename(childName)
    targets.append(putTarget)

pymel.core.select(targets)
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls(sl=1)
targets = []
for sel in sels:
    putTarget = sgCmds.putObject(sel, 'locator')
    putTarget.setParent(sel)

    selName = sel.split('|')[-1]
    childName = ''
    if selName[-1] == '_':
        childName = sel.nodeName() + 'child'
    else:
        childName = sel.nodeName() + '_child'
    putTarget.rename(childName)
    targets.append(putTarget)

pymel.core.select(targets)
Beispiel #17
0
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls( sl=1 )
targets = []
for sel in sels:
    putTarget = sgCmds.putObject( sel, 'joint' ) 
    putTarget.setParent( sel )
    
    selName = sel.split('|')[-1]
    childName = ''
    if selName[-1] == '_':
        childName = sel.nodeName() + 'child'
    else:
        childName = sel.nodeName() + '_child'
    putTarget.rename( childName )
    targets.append( putTarget )

pymel.core.select( targets )
Beispiel #18
0
from sgMaya import sgCmds
import pymel.core

sels = pymel.core.ls(sl=1, fl=1)
newObjects = []
for sel in sels:
    newObject = sgCmds.putObject(sel, 'null')
    newObjects.append(newObject)
pymel.core.select(newObjects)
Beispiel #19
0
from sgMaya import sgCmds
from maya import cmds

sels = cmds.ls( sl=1 )
sgCmds.putObject( sels, 'joint' )
from sgMaya import sgCmds
from maya import cmds

sels = cmds.ls( sl=1 )
sgCmds.putObject( sels, 'locator' )