This TouchDesigner component watches for mouse movement above a certain threshold. The typical use case is to display a configuration window when the mouse is moved. This makes it easy for casual users to access your project’s configuration options without diving deep into the network.
The main behavior of the component is for its state channel to go from from 0 to 1 when mouse movement is detected. However, this component particularly shines because of the fine-tuning it provides through its various parameters. Let’s look at them.
Detection Mode & Sensitivity
The Detection Mode parameter specifies whether any mouse movement triggers detection or only mouse movement when the cursor is above a specific Panel.
The Sensitivity parameter allows for detection to be activated only when enough movement has occurred. This is useful to filter out micro-movements such as those caused by vibrations.
Envelope
The component also provides an envelope channel. It is similar to the state channel but instead of being binary and instant, it uses an ASR (attack, sustain, release) model to transition smoothly between values according to the durations set by the user.
When movement is detected, the Attack Duration parameter determines how long it will take for the envelope channel to smoothly transition from 0 to 1. The Release Duration parameter does the same for the fade out transition.
The Hold Duration parameter determines how long the envelope will remain at 1 for. If you specify a Panel through the Hold While Over parameter, the value will always remain at 1 while the mouse hovers the specified Panel. When a Holding Mode of Indefinitely is used, the detection value will remain at 1 until the Reset button is pressed.
The envelope_state channel is a binary channel that is on/off when the envelope actually has reached those states (which is slightly different from state, given the transitions).
Reset & Pause
The Reset button brings the detection back to 0 and clears the envelope. The Pause toggle freezes detection in its current state. Pressing Reset and enabling Pause in sequence freezes detection at 0 (until Pause is toggled again).
If a value greater than 0 is specified in the Auto Un-Pause Delay parameter, the Pause parameter will be switched back to Off after the specified number of seconds.
Callbacks
The component can trigger callback functions when a Callback DAT is specified. To set it up, simply press the Edit… button and a Text DAT will be created and opened for editing. This is what the new DAT will contain:
Download and Use the Component
You can get MouseMoveTrigger.tox on my Patreon. Download the .zip file at the bottom of the page, extract it and simply drag-and-drop the .tox file onto your project. You can then retrieve the detection status by connecting the component’s 3-channel CHOP output to your network:
Note: as a convenience, you can also reference the State, Envelope and Envelope State properties which are available in the component’s Parameter window (see bottom of first image above).