当前位置:   article > 正文

MAYA中 快速Bake物体关键帧_maya bake

maya bake

转载请备注信息:转自WOOVR博客
在项目制作过程中,我们时常需要烘培一些物体的动画信息,使用MAYA自带的BS(BakeSimulation),总需要跑一遍时间轴
MAYA中BAKE关键帧老方法
UI界面
如果遇到的场景、动画简单还好,但若是场景过大,绑定较卡,这样BAKE会非常耗时,于是利用MAYA自带的BAKE命令写了个小工具,后台执行,无需逐帧跑时间轴。

#!/usr/bin/python
# -*- coding: utf-8 -*-
#developed by WOOVR 20190528, Free to use and modify
from maya.cmds import *
import os
import sys
# GUI
def quickBakeUI():
	win = 'quickBake_win'
	if window( win, exists = True ): 
		deleteUI( win )

	window(win, title =u"快速BAKE物体", sizeable = False)

	columnLayout( adj = True, columnAttach = ['both', 1] )


	separator( style = 'in' )

	checkBox( win + '__fromCurFrame_ChB', align = 'left', label = 'Start from Current Frame', value = 0 )

	radioButtonGrp( win + '__range_RBG',
					labelArray2 = ['Playback Range', 'Custom Range'], 
					numberOfRadioButtons = 2, 
					select = 1,
					onCommand1 = 'intFieldGrp( "' + win + '__range_IFG", edit = True, enable1 = False, enable2 = False )', 
					onCommand2 = 'intFieldGrp( "' + win + '__range_IFG", edit = True, enable1 = True, enable2 = True )' )

	intFieldGrp( win + '__range_IFG', label = '', numberOfFields = 2, columnWidth = (1, 24), value1 = playbackOptions( q = True, min = True ), value2 = playbackOptions( q = True, max = True ), enable1 = False, enable2 = False )
	
	sep2 = separator( style = 'in' )

	rowLayout( numberOfColumns = 2, columnWidth2 = [ 172, 40 ], columnAlign2 = [ 'center', 'center' ] )

	button( label = 'Bake',
			width = 220,
			command = 'quickBake_cmd()' )

	setParent( '..' )

	# PROGRESS BAR
	#progressBar( 'ark_instToGeo_progBar1', width = 220, height = 15, isInterruptable = True )
	#progressBar( 'ark_instToGeo_progBar2', width = 220, height = 15, isInterruptable = True )

	showWindow( win )
	window( win, edit = True, width = 228, height = 143 )

def quickBake_cmd():
    win = 'quickBake_win'
    Bake_Grp=ls( selection=True )
    start=intFieldGrp( win + '__range_IFG', q = True, value1 = True )
    end=intFieldGrp( win + '__range_IFG', q = True, value2 = True )
    fromCurFrame = checkBox( win + '__fromCurFrame_ChB', q = True, value = True )
    currentFrame = currentTime( q = True )
    rangeSpecified = radioButtonGrp( win + '__range_RBG', q = True, select = True )-1
    print rangeSpecified
    print start
    print end
    Timeline_startFrame= playbackOptions( q = True, min = True )
    Timeline_endFrame=playbackOptions( q = True, max = True )
    print Timeline_endFrame
    if not Bake_Grp:
        error( u'请选择要BAKE的物体' )
    elif fromCurFrame > 0 and rangeSpecified==0:
        print u'从当前帧开始BAKE'
        bakeResults(Bake_Grp,t=(currentFrame,Timeline_endFrame),sb=1)
    elif rangeSpecified==0:
        bakeResults(Bake_Grp,t=(Timeline_startFrame,Timeline_endFrame),sb=1)
    elif rangeSpecified>0:
        start=intFieldGrp( win + '__range_IFG', q = True, value1 = True )
        end=intFieldGrp( win + '__range_IFG', q = True, value2 = True )
        bakeResults(Bake_Grp,t=(start,end),sb=1)
    else:
        print u'从设置的帧开始BAKE'
        start=intFieldGrp( win + '__range_IFG', q = True, value1 = True )
        end=intFieldGrp( win + '__range_IFG', q = True, value2 = True )
        bakeResults(Bake_Grp,t=(start,end),sb=1)
        
	
def main():
    quickBakeUI()
    

if __name__ == '__main__':
    main()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/451387
推荐阅读
相关标签
  

闽ICP备14008679号