9
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

TouchDesignerでの状態管理の方法について

Posted at

TouchDesignerでの状態管理について、フォーラムに投稿されている以下の質問と全く同じ理由ではまりました。
Setting CHOP Channels with Python - General TouchDesigner Discussion - TouchDesigner forum

で、それに対する回答としてTouchDesignerで状態を管理する方法について箇条書きで回答されていました。

  • store the state in a Table DAT (access state via row name: op(‘table1’)[‘state1’,1] = 1)
  • store the state in storage (ie parent().store(‘state1’,1))
  • utilize the Timer CHOP as a state machine (my favorite, use segments as states and switch through the segments)
  • in the case of the video playback, why not use the info CHOP on Moviefilein TOP, it already gives you the states
  • use radio or exclusive buttons to store the states (op(‘state1’).click())
  • write your own state machine using extensions

訳すとこんな感じです。

  • Table DATで状態を管理する (行名で状態にアクセスする: op('table1')['state1', 1]=1)
  • Storageで状態をを管理する (つまり parent().store('state1', 1))
  • Timer CHOPを状態機械として使う (私のお気に入り、segmentsを状態として使い、segmentsを通じて切り替える)
  • 映像再生の場合はMoviefilein TOPに対してInfo CHOPを使うべき、これにより状態を取得できる
  • ラジオボタンまたは排他ボタンを状態を管理するために使う (op('state1').click())
  • Extensionsを使って専用の状態機械を書く

この記事ではそれぞれの手法を試してみます。
(Extensionsを使う方法は試しません、Extensionsよくわかってないので...。)

Table DATを使う方法

Table DATでkey-valueのペアとして値を管理する方法です。Table DAT内の値はスクリプトで更新することができます。
以下の例ではsliderを操作するとchopexec内のonValueChangeメソッドが実行され、state_tablevalueキーに対応した値が更新されます。
use_table_dat.PNG

Storageを使う方法

オペレーターが持つStorageの機能を使用する方法です。以下の例はさきほどと同じようにCHOP Execute DATでスライダーを監視して、値が変わるとonValueChangeメソッドでStorage内の値を更新します。状態を管理するコンポーネントはどの種類のコンポーネントでもいいのですが、Storageを使用する以外の機能は不要なのでBase COMPを使用しています。Examine DATを使用するとコンポーネントからStorageの値を取得することができます。
use_storage.PNG

Timer CHOPを使う方法

Timer CHOPは一定時間の経過を計るCHOPです。一定時間ごとに値が切り替わるような状態を管理するのに使うのだと思います。
以下のようにTimer CHOPのsegmentsタブ内のColumns to Custom Channelsを使用することで、時間経過に応じて任意の値を変更することができます。Custom Channel Interpolationで補間方法を変更することができます。
use_timer.PNG
Timer CHOPはOperator Snippetsが充実しているので、Timer CHOPの使い方はそちらを見ると参考になると思います。今回の場合はsegment interpolateが対応しています。

Moviefilein TOP + Info CHOPを使う方法

Moviefilein TOPの映像再生の情報をInfo CHOPで取得することができます。
use_moviefilein_info.PNG

ラジオボタンまたは排他ボタンを使う方法

ボタンを複数配置してButton TypeRadio Downなどのラジオボタンにします。この状態でPanel CHOPを配置するとradio channelで現在選択しているボタンの状態を取得することができます。ボタンの選択状態はtext1に書いてあるようなスクリプトでも変更することができます。

use_buttons.PNG

9
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?