fpsってフトした拍子に変わってたりしますが、
気づかずアニメーションとか付けてたりすると悲惨ですΣ( ゚∀)
というわけで、ヒューマンエラーをなくすべく機械にやっていただこう!となるわけです。
スクリプトの出番です。
しかしmayaさんはここでもヒトクセあって、
30fpsとか数字で指定できたら楽なんですがゴニョゴニョ…!?
というのが本日の内容です↓
まず、現在のfpsを問い合わせてみましょう。
currentUnit -q -t;
これで、fpsがユニットで返ってきます。
ユニットがなになのかは後述しますが、「30fps」とかのわかりやすい数字でないことは確かです。
つぎに↓こちら
currentTimeUnitToFPS;
これで、fpsを数字で答えてくれます。
ちなみにwhatIsで訊いてみるとこうなります↓
whatIs currentTimeUnitToFPS; // Result: Mel procedure found in: C:/Program Files/Autodesk/Maya20xx/scripts/startup/currentTimeUnitToFPS.mel //
ここに出てきた.melファイルを見てるとmaya内の真実の一端を見ることができるのですが、
maya内でfpsと言えば、実際のfpsの数字と対をなす文字列が横行跋扈しており、
したがって「30fpsにしたいからどっかに30って入力する」といったお手軽さはないであろうことが察せられます。
currentTimeUnitToFPS.melの中を見ることでユニットの正体も分かります。
unitとは、辞書的には「単位」を示す単語ですが、 mayaでの「時間」の「単位」は
filmやntscといった「規格名」の形で用意されているようです。
filmが24フレ、ntscが30フレというのは納得感がありますが、
gameが15フレ…?ntscfが60フレ…?ってことはfはフィールドのf…?
などなんとなく馴染まないものもあります。
currentTimeUnitToFPS.melの中を見ることでユニットの正体も分かります。
unitとは、辞書的には「単位」を示す単語ですが、 mayaでの「時間」の「単位」は
filmやntscといった「規格名」の形で用意されているようです。
filmが24フレ、ntscが30フレというのは納得感がありますが、
gameが15フレ…?ntscfが60フレ…?ってことはfはフィールドのf…?
などなんとなく馴染まないものもあります。
やはり出来れば、聴いたら数字で返してくれる+指定も数字で、
になると良いような気がします。
=====
続いて、fps指定する方法です。
currentUnit -t (unit);
この(unit)の部分に、fpsに対応する文字列を入れれば、fpsを指定できます。
どういったunitがどのフレームレートになっているのかは、さきほどのcurrentTimeUnitToFPS.melを調べれば分かります。
ユニット(文字列)での指定はできました。
次は数字で指定したいところですが、
どうやらmayaにはその方法が用意されていないようです。
「30と入力すれば30fpsになる」場所がないのです。
というわけで、つくりましょう。
さきほどのcurrentTimeUnitToFPS.melをベースにすれば、簡単に出来ます。
↓こんな感じになりました。
global proc string changeFPS(int $fps)
{
string $unit;
if( $fps == 15 ) {
$unit = "game";
} else if( $fps == 24 ) {
$unit = "film";
} else if( $fps == 25 ) {
$unit = "pal";
} else if( $fps == 30 ) {
$unit = "ntsc";
} else if( $fps == 48 ) {
$unit = "show";
} else if( $fps == 50 ) {
$unit = "palf";
} else if( $fps == 60 ) {
$unit = "ntscf";
} else if( $fps == 2 ) {
$unit = "2fps";
} else if( $fps == 3 ) {
$unit = "3fps";
} else if( $fps == 4 ) {
$unit = "4fps";
} else if( $fps == 5 ) {
$unit = "5fps";
} else if( $fps == 6 ) {
$unit = "6fps";
} else if( $fps == 8 ) {
$unit = "8fps";
} else if( $fps == 10 ) {
$unit = "10fps";
} else if( $fps == 12 ) {
$unit = "12fps";
} else if( $fps == 16 ) {
$unit = "16fps";
} else if( $fps == 20 ) {
$unit = "20fps";
} else if( $fps == 40 ) {
$unit = "40fps";
} else if( $fps == 75 ) {
$unit = "75fps";
} else if( $fps == 80 ) {
$unit = "80fps";
} else if( $fps == 100 ) {
$unit = "100fps";
} else if( $fps == 120 ) {
$unit = "120fps";
} else if( $fps == 125 ) {
$unit = "125fps";
} else if( $fps == 150 ) {
$unit = "150fps";
} else if( $fps == 200 ) {
$unit = "200fps";
} else if( $fps == 240 ) {
$unit = "240fps";
} else if( $fps == 250 ) {
$unit = "250fps";
} else if( $fps == 300 ) {
$unit = "300fps";
} else if( $fps == 375 ) {
$unit = "375fps";
} else if( $fps == 400 ) {
$unit = "400fps";
} else if( $fps == 500 ) {
$unit = "500fps";
} else if( $fps == 600 ) {
$unit = "600fps";
} else if( $fps == 750 ) {
$unit = "750fps";
} else if( $fps == 1200 ) {
$unit = "1200fps";
} else if( $fps == 1500 ) {
$unit = "1500fps";
} else if( $fps == 2000 ) {
$unit = "2000fps";
} else if( $fps == 3000 ) {
$unit = "3000fps";
} else if( $fps == 6000 ) {
$unit = "6000fps";
} else {
$unit = "ntsc";
}
currentUnit -time $unit;
optionVar -sv "workingUnitTimeDefault" $unit;
print ("FrameRate : "+ $fps +"fps\n");
return $unit;
}
fpsは、currentUnitで指定するだけでは今開いている(=カレントの)シーンだけでしか変わりません。
このままうっかり次のシーンを作っていくと事故になるので、optionVar の方も変更して、新規シーンにも影響するようにしておきます。
実行するときは↓こんなかんじです
changeFPS(30);
このようにすると、30fpsになります。
currentTimeUnitToFPS.melを参考にしているので、
数字からユニットへの変換の部分がけっこう肉弾戦になってます。
最後にいたっては、めんどうくさいので 「あてはまらない数字がきたら全部30fpsにしてやる!」という悪しき精神が垣間見えます。が、実用上はそんなに問題ないと思います。 …や、分かりません。もしかしたら堕落の始まりかもしれません。みなさまお気をつけ下さい。
■参考リンク
オンラインドキュメント currentUnitのページ
ちなみに↓こちらではcurrentTimeUnitToFPSのpython版についての記事が。
[Maya] FPSの取得 @たっきゅんのガ☆チンコ開発日記
http://takkun.nyamuuuu.net/blog2/archives/574
0 件のコメント:
コメントを投稿