MaxScript输出所选对象在每一帧中的速率以及平均速率到一个文件

来源:互联网 发布:网络呼叫系统有哪些 编辑:程序博客网 时间:2024/06/11 01:34


How To ... Output Object Data To File

macroScript SpeedSheet category:"HowTo"

(

if selection.count > 0 then

(

output_name = getSaveFileName caption:"SpeedSheet File" types:"SpeedSheet (*.ssh)|*.ssh|All Files (*.*)|*.*|"

if output_name != undefined then

(

output_file = createfile output_name

at time animationrange.start format "Object(s): %/n" (selection as array) to:output_file

average_speed = 0  --平均速度

for t = animationrange.start to animationrange.end do

(

at time t current_pos = selection.center

at time (t-1f) last_pos = selection.center

frame_speed = (distance current_pos last_pos)*FrameRate --帧速

average_speed += frame_speed

format "Frame %: %/n" t frame_speed to:output_file

)

average_speed /= (animationrange.end-animationrange.start)

format "Average Speed: %/n" average_speed to:output_file

close output_file

edit output_name

)--end if

)--end if

)--end macroScript

 

运行结果:

==================================

animationrange  默认为100帧

FrameRate 帧速率 这里是30

有一行代码让我思索好久,最后恍然大悟

frame_speed = (distance current_pos last_pos)*FrameRate

一直想为什么乘呢?

原来1秒有30帧

原创粉丝点击