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()
  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值