View user_channel sample source code.
The samples uses a user channel track to drive attachment state of a box manipulated by a robot’s arm. The track was edited in a DCC tool as a custom property, and imported along side the animation using fbx2ozz.
Initializing WebGL
User-channels are the way to animate data that aren’t joint transformations: float, bool… In this sample the user-data is the boolean attachment state of the box with the robot’s finger. The sample attaches the box (see attachment sample) to the robot’s finger when the boolean becomes true, and detaches it when it’s getting false. The user-channel track was edited in a DCC tool as a custom property and saved in the fbx file alongside the animation. fbx2ozz is used to extract this track using “animations[].tracks[].properties[]” parameter of fbx2ozz json configuration. See config.json.
The sample demonstrates two ways to use the user-channel track, based on ozz API:
The sample exposes usual animation playback settings. It also exposes options to choose to from sampling or edge triggering technique (default option).
ozz::animation::TrackSamplingJob
. User-channel track is sampled at the same time t as the animation, which gives attachment state for the current frame. State changes are thus detected depending on application frame rate.ozz::animation::TrackTriggeringJob
. TrackTriggeringJob computes rising and falling edges for a given period of time. The sample thus queries all edges from the previous frame time to the current one. The exact edge time (aka when the track crosses threshold value) is used to compute finger joint transformation, instead of current frame time (as with sampling case). This make the algorithm frame rate independent.