Palette:initializeStart

From Derivative
Revision as of 00:26, 13 May 2021 by Greg (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The initializeStart component is designed to be installed into users components that have time-dependent behavior. If you follow this procedure, you will have a component that has a TouchDesigner-standard way of being controlled (mostly via parameters), and with standard channels being output. This is modelled after the Timer CHOP.

Time-dependent behavior includes:

  • procedurally-generated dynamic objects like particles, that step forward (iterate) every frame, and that would start from a pre-determined configuration or state.
  • more deterministic playback of (possibly keyframed) animation that has its own internal timeline.

See the Initialize Start standard description.

Once set up, internally, you can use the initializeStart timers and states to step forward in your simulations or playback animations, controlling speeds, pausing, initializing, unloading.

NOTE: This is the first publication of this helper component, feedback on forum appreciated. An automated setup of the procedure below will be made available in next build.

Procedure[edit]

Installing this template into you time-dependent component - example: particlesGpu (which has not been converted to this standard yet)

Copy/paste this COMP into particlesGpu. Attach a Null CHOP to the initializeStart output and name it timerstate. Attach an Out CHOP to timerstate so that particlesGpu outputs the timing information for any external operators to use.

Note: set the Speed to 1. (early versions have 0 as default).

Now we want to duplicate the InitStart page of parameters onto the particleGpu's parameters. With the Component Editor (rclick -> Customize Component), duplicate the InitStart page onto it parent particlesGpu so all parameters are visible at the top level. To do this, set the Component Editor to initailizeStart. On the page called InitStart, right-click and select Copy. Then go up a level and set the Component Editor to particlesGpu. Then in the Page section, right-click and select Paste. Now you should have all the parameters at the top-level.

Then bind all the parameters so that the new parameters on particlesGpu are the masters.

You can delete some top-level parameters if you know you are not going to need them. Like the Callbacks parameter. Or you may know Type will be Infinite Length, so delete that par and the Length par at the top level and set Type inside to Infinite Length.

To put the callbacks in a usable place, copy the initializeStart/initStartCallbacks DAT up a level in particlesGpu. Then set the Callback parameter of initializeStart to point to initStartCallbacks instead of ./initStartCallbacks.

You will finally edit the initStartCallbacks to specifically drive particlesGpu, like fill in onInitialize(), onStart() and onDone().

If your component is a simulation where it iterates forward, you can hook the parent().par.Speed and parent().par.Play parameters to your variable that determines how much time to step forward.

If your component plays back media in a pre-determined way, you can use the op('timerstate')['timer_seconds'] channel or other channels to select which data or frame to display.

You can use the other channels of timerstate at your leisure.

Sometimes you will want to drive the simulation with a timing channel externally, so the External parameters are good for that. See the Timer CHOP for further information about External control. Otherwise, keep External Control off.

If you want to initialize your component to a certain starting point, use the Initialize Time parameter (sorry, not implemented yet). When you pulse Initialize, timer_seconds will be set to that time. You can use top-level parameters, like Pre-Roll to pre-simulate some number of seconds of your sim.

The errors channel is a placeholder for any error state you may want to send out from particlesGpu.

Use[edit]

Press the Initialize parameter. The channels should go into a "ready" state with timers at 0 or an Initialize Time.

Press Start. counters rising

Adjust Speed. timer_seconds and other channels slow down.

Press Play off. Some timers will stop. Press Play on.

Press Go to Done. channels will go into a done state.

Press Initialize again, or to initialize and start in one step, press Start.

If you press Start and it has not been initialized yet, It will do an Initialize first and then start.

This follows the Timer CHOP behavior.