animcurve_channel_new

This function creates a new animation curve channel struct.

A channel struct has the following variables:

Animation Curve Channel Struct
Variable NameData TypeDescription
namestringThis is the name of the channel.
typeAnimation Curve Interpolation Type ConstantThis will be one of the constants given in the table below.
iterationsintegerIf the channel is using catmull-rom ("smooth") interpolation this holds how many points have been generated for each segment of the curve (note that these extra points are internal to the function and only used for the runtime calculations). If the channel is using linear interpolation, this value will still exist but can be ignored as it has no bearing on how the curve is interpolated.
pointsarrayThis is an array, where each item in the array is an Animation Curve Point Struct.

 

Animation Curve Interpolation Type Constant
ConstantDescription
animcurvetype_linearUsed for linear interpolation between points.
animcurvetype_catmullromUsed for smooth interpolation between points using Catmull-Rom interpolation.
animcurvetype_bezierUsed for Bezier interpolation between points.


By default when you create a new channel struct, the "name" variable will be an empty string, the "type" will be animcurvetype_linear and the "iterations" will be 16. All these variables can be set to the values that you require (note that the "iterations" value has no effect on linear curve types). Once created you need to add points to the curve, which is done by adding different point structs to the "points" array. These point structs can be created using the function animcurve_point_new().

 

Syntax:

animcurve_channel_new();

 

Returns:

Animation Curve Channel Struct

 

Example:

my_curve = animcurve_create();
my_curve.name = "My_Curve";
var _channels = array_create(1);
_channels[0] = animcurve_channel_new();
_channels[0].name = "alpha";
_channels[0].type = animcurvetype_catmullrom;
_channels[0].iterations = 8;
var _points = array_create(3);
_points[0] = animcurve_point_new();
_points[0].posx = 0;
_points[0].value = 0;
_points[1] = animcurve_point_new();
_points[1].posx = 0.5;
_points[1].value = 1;
_points[2] = animcurve_point_new();
_points[2].posx = 1;
_points[2].value = 0;
_channels[0].points = _points;
my_curve.channels = _channels;

The above code creates a new animation curve struct and stores it in the variable "my_curve". This struct is then populated with a name and a channel array. The channel array contains a single channel with three points.