ml_stopwatch.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:ml_tools 作者: morganloomis 项目源码 文件源码
def addMarksToScene(marks):
    '''
    This is temp and will possibly be rolled into future releases.
    '''

    start,end = utl.frameRange()
    camera = utl.getCurrentCamera()
    camShape = mc.listRelatives(camera, shapes=True)[0]
    aov = mc.getAttr(camShape+'.horizontalFilmAperture')

    name = 'ml_stopwatch_'

    numStopwatches = len(mc.ls(name+'*', type='locator'))
    top = mc.spaceLocator(name=name+'#')

    ename = ':'.join([str(x) for x in marks])
    mc.addAttr(top, longName='keyTimes', at='enum', enumName=ename, keyable=True)

    markRange = float(marks[-1]-marks[0])
    viewWidth = aov*2
    viewHeight = -0.4*aov+(numStopwatches*aov*0.08)
    depth = 5

    for mark in marks[1:-1]:

        ann = mc.annotate(top, text=str(mark))
        mc.setAttr(ann+'.displayArrow', 0)

        #parent
        annT = mc.parent(mc.listRelatives(ann, parent=True, path=True), top)[0]
        annT = mc.rename(annT, 'mark_'+str(round(mark)))
        ann = mc.listRelatives(annT, shapes=True, path=True)[0]

        #set the position
        normalX = float(mark-marks[0])/markRange-0.5
        mc.setAttr(annT+'.translateX', viewWidth*normalX*2)
        mc.setAttr(annT+'.translateY', viewHeight)
        mc.setAttr(annT+'.translateZ', -depth)

        #keyframe for color
        mc.setAttr(ann+'.overrideEnabled', 1)

        mc.setKeyframe(ann, attribute='overrideColor', value=17, time=(int(marks[0]-1),int(mark+1)))
        mc.setKeyframe(ann, attribute='overrideColor', value=13, time=(int(mark),))
        mc.keyTangent(ann+'.overrideColor', ott='step')


    mc.select(clear=True)    
    mc.parentConstraint(camera, top)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号