HDK
|
CHOP stands for Channel Operation. Each CHOP is responsible for creating or modifying channel data. All CHOPs are derived from the CHOP_Node base class. To write a custom CHOP, you need to do the following things:
The cook method basically comes in two flavors, cooks that have inputs and those that don't. All cooking involves evaluating the parameters, processing the sample data and returning the status. CHOPs without inputs generally begin the cook by calling the destroyClip
method to make sure all the sample data is created fresh. Cooks that have inputs call the copyInput
method which gets information from the parent clip.
Below are the two common examples of a CHOP's cookMyChop()
method.
Generator skeleton example:
Filter skeleton example:
CHOP_Node provides several useful methods for CHOP cooking:
cookMyChop(OP_Context &context)
getClip(OP_Context *context = 0)
inputClip(int index, OP_Context &context)
usesScope() const
isScoped(const UT_String &name)
destroyClip()
copyInput(OP_Context &context, int index, int data, int slerps)
Handles allow for interactive modification of parameters in the graph window. They appear as boxes or squares and may have bars in horizontal or vertical directions depending on their function. CHOPs are not required to have handles. Handles are based on @c CHOP_Handle.h and required methods for cooking and recognizing changes. @c cookMyHandles example:
This creates a handle which modifies the offset parameter and allows for motion in the vertical direction only. The handle is positioned three quarters of the way between the start and end of the clip. The general form of the CHOP_Handle allows for many variations:
@c CHOP_HandleLook can be one of three types: - @c HANDLE_GUIDE - a line that cannot be moved - @c HANDLE_BOX - a filled in square - @c HANDLE_SQUARE - a square outline. CHOP_HandleMotion can be one of three types as well: - @c HANDLE_HORIZONTAL - a vertical line that slides horizontally - @c HANDLE_VERTICAL - a horizontal line that slides vertically - @c HANDLE_PLANE - a square that allows both types of motion Other flags further describe the appearance of the handle: - @c HANDLE_LABEL_LEFT - place the label to the left of the handle - @c HANDLE_LABEL_RIGHT - place the label to the right of the handle - @c HANDLE_LABEL_TOP - place the label above the handle - @c HANDLE_LABEL_BOTTOM - place the label below the handle - @c HANDLE_BAR - allows the handle to be used in bar mode - @c HANDLE_GRAPH - allows the handle to be used in graph mode - @c HANDLE_WIDTH_END - the handle is at the end of the clip The DEFAULT_FLAGS are set to position the label below and to the left of the handle in graph mode. Along with a cook method, a method to handle changes in the CHOP (including changes to the handles) is also necessary. @c handleChanged example:
This example checks for changes in three handles and modifies the parameter associated with the affected handle. Handles are selected based on their Id numbers. Any changes in the CHOP from something other than a handle should also be included in this method.
When dealing with handles, it is important to make sure the units are correct. The xoffset is always in samples and should be rounded off to the nearest integer value just to be safe. In order to return the proper value, the toUnit method must be used. This converts the xoffset value to the type of unit currently displayed by the graph. If the handle is at the end of an interval (has a HANDLE_WIDTH_END flag), a 1 must be provided as the third parameter. Only values in the x-plane need to be converted to the proper units.