コンテキスト式は MAXScript 構文の一部で、特に 3ds Max で使用するために設計したものです。コンテキスト式は、アニメーション ボタン、タイム ライン スライダ、作業座標システムなどの 3ds Max ユーザ インタフェース内のもっとも重要な概念のいくつかの反映です。コンテキスト式を使用すると、ユーザ インタフェースからこれらのツールを使って行うのと同じくらい MAXScript でのアニメーションの作成やジオメトリ操作が簡単になります。
式の評価の状況を設定するため提供されるプレフィックス、というのが基本的な考え方です。
例: |
b1 = box() b2 = box() animate on ( move $box001 [20, 0, 0] rotate $box002 45 x_axis ) |
こうすると、ブロック式の継続中にアニメーション ボタンを「オンにする」ことになります。3ds Max ユーザ インタフェースでアニメーション ボタンをオンにしてからオブジェクトを移動したときと同じように、move や rotate がキーフレームを自動的に生成します。
他のコンテキスト式には、ちょうどタイム スライダを動かしたときのように、そのときのアニメーション時間を設定するためのプレフィックスが付いたものもあります。この 2 種類の形式を混ぜて使うと、MAXScript でのキーフレーム アニメーションの実行方法がわかります。
例: |
animate on ( at time 0 $box001.position = [-100, 0, 0] at time 100 $box001.position = [100, 0, 0] ) |
<context_expr> の完全な構文を次に示します。
<context> { , <context> } <expr>
ここで、 <context> は次のいずれかになります。
[ with ] animate <boolean> at level <node> in <node> at time <time> [ in ] coordsys <coordsys> about <center_spec> [ with ] undo <boolean> [ with ] redraw <boolean> [ with ] quiet <bool> [ with ] redraw <bool> [ with ] printAllElements <bool> [ with ] defaultAction <action> [ with ] MXSCallstackCaptureEnabled <bool> [ with ] dontRepeatMessages <bool> [ with ] macroRecorderEmitterEnabled <bool>
例: |
-- randomly jiggle each object in the selection around + or - 20 units in coordsys local selection.pos = random [-20,20,20] [20,20,20] -- rotate all the boxes 30 degrees about the y_axis of $foo about $box001 rotate $box002* 30 y_axis -- generate a keyframed animation of $foo randomly chasing $baz animate on for t in 0 to 100 by 5 do at time t $box001.pos = $box002.pos + random [-10,-10,-10] [10,10,10] |
各コンテキスト式については、以下のトピックを参照してください。