Class ICurve

3DS Max Plug-In SDK

Class ICurve

See Also: Class ReferenceTarget, Class ICurveCtl, Class CurvePoint, COLORREF, Class BitArray.

class ICurve : public ReferenceTarget

Description:

This class is available in release 3.0 and later only.

This class is an interface to a single curve used by a ICurveCtl. A pointer to one of these is returned from the method ICurveCtl::GetControlCurve().

All methods of this class are implemented by the system.

Methods:

public:

Prototype:

virtual void SetPenProperty(COLORREF color, int width = 0, int style = PS_SOLID)=0;

Remarks:

Sets the pen properties of a curve

Parameters:

COLORREF color

The color for the curve lines.

int width = 0

The width of the lines in pixels.

int style = PS_SOLID

The pen style to use. One of the following types may be used. See the Win32 API Reference for more information on pen styles.

PS_SOLID

PS_DASH

PS_DOT

PS_DASHDOT

PS_DASHDOTDOT

PS_NULL

PS_INSIDEFRAME

Prototype:

virtual void GetPenProperty(COLORREF &color, int &width, int &style)=0;

Remarks:

Retrieves the color, width and style of a curve.

Parameters:

COLORREF &color

The color in use.

int &width

The width in use.

int &style

The style in use. One of the following types:

PS_SOLID

PS_DASH

PS_DOT

PS_DASHDOT

PS_DASHDOTDOT

PS_NULL

PS_INSIDEFRAME

Prototype:

virtual void SetDisabledPenProperty(COLORREF color, int width = 0, int style = PS_SOLID)=0;

Remarks:

Sets the pen properties of a curve if it is disabled.

Parameters:

COLORREF color

The color to set.

int width = 0

The width to set.

int style = PS_SOLID

The style to set. One of the following types:

PS_SOLID

PS_DASH

PS_DOT

PS_DASHDOT

PS_DASHDOTDOT

PS_NULL

PS_INSIDEFRAME

Prototype:

virtual void GetDisabledPenProperty(COLORREF &color, int &width, int &style)=0;

Remarks:

Retrieves the color of a curve if it is disabled.

Parameters:

COLORREF &color

The color in use.

int &width

The width in use.

int &style

The style in use. One of the following types:

PS_SOLID

PS_DASH

PS_DOT

PS_DASHDOT

PS_DASHDOTDOT

PS_NULL

PS_INSIDEFRAME

Prototype:

virtual float GetValue(TimeValue t, float fX, Interval &ivalid = FOREVER, BOOL UseLookupTable = FALSE)=0;

Remarks:

Returns the Y-value for a given X-Value of the curve. Note that values outside the X-range are extrapolated from the curve using a straight line based on the tangents of the first or last point.

Parameters:

TimeValue t

The time to get the value.

float fX

The input X value.

Interval &ivalid = FOREVER

The validity interval which is updated by this method to reflect the validity of the curve.

BOOL UseLookupTable = FALSE

If TRUE a lookup table is used to get the value (for speed). If FALSE the value is computed.

This is used to speed up value access. The default value for the lookup table size is 1000. The lookup table will be calculated whenever this method is called with TRUE and the current lookup table is not initialized yet, or invalid (it will be invalidated, when a point or tangent is moved, or the time has changed in case it is animated).

Prototype:

virtual void SetCanBeAnimated(BOOL Animated)=0;

Remarks:

Sets if the curve can be animated or not.

Parameters:

BOOL Animated

TRUE if it can be animated; FALSE if it can't.

Prototype:

virtual BOOL GetCanBeAnimated()=0;

Remarks:

Returns TRUE if the curve can be animated; otherwise FALSE.

Prototype:

virtual int IsAnimated(int index)=0;

Remarks:

Returns nonzero if the specified point is animated; otherwise zero.

Parameters:

int index

The zero based index of the curve to check.

Prototype:

virtual int GetNumPts()=0;

Remarks:

Returns the number of points in the curve.

Prototype:

virtual void SetNumPts(int count)=0;

Remarks:

Sets the number of points in the curve.

Parameters:

int count

The number to set.

Prototype:

virtual BitArray GetSelectedPts()=0;

Remarks:

Returns a BitArray which contains the selected / de-selected state for each point. The BitArray is GetNumPts() in size where the 0-th bit corresponds to the 0-th point.

Prototype:

virtual void SetSelectedPts(BitArray &sel, int flags)=0;

Remarks:

Sets the selected state of the points in the curve using the BitArray passed. Bits which are are affected as specified by the flags.

Parameters:

BitArray &sel

Specifies which points are affected. The 0-th bit corresponds to the 0-th point.

int flags

One or more of the following values:

SELPTS_SELECT

Select the points.

SELPTS_DESELECT

De-select the points.

SELPTS_CLEARPTS

If this bit is set the method de-selects (clears) all the points before performing the operation as specified by the flags above.

Prototype:

virtual void SetPoint(TimeValue t, int index, CurvePoint *point, BOOL CheckConstraints = TRUE, BOOL notify = TRUE)=0;

Remarks:

Sets the specified point at the time passed.

Parameters:

TimeValue t

The time at which to set the point.

int index

The zero based index of the point in the curve.

CurvePoint *point

Points to the curve point to set.

BOOL CheckConstraints = TRUE

When you're setting a point, it checks the in and outtan handles to prevent them from going beyond the previous or next point's location, since that would create an invalid curve. Thus the Curve Control will adjust the tangents due to the constraints. However, if you set the first point, there is no next point, to check the tangent location against, thus you have to have a possibility to turn CheckConstraints off, so the constraints won't be checked (developers have to make sure that they are inserting valid points/tangents. )

BOOL notify = TRUE

This parameter is available in release 4.0 and later only.

This allows developers to control whether the command sends windows messages or not. When set to FALSE windows messages are not sent to the message handler. This lets developers constrain points when the user attempts to move them without getting into a message loop. When TRUE messages are sent.

Prototype:

virtual CurvePoint GetPoint(TimeValue t, int index, Interval &valid = FOREVER)=0;

Remarks:

Retrieves data about the specfied point and updates the validity interval to reflect the validity of the point's controller.

Parameters:

TimeValue t

The time to get the data.

int index

The zero based index of the point.

Interval &valid = FOREVER

The validity interval which is updated.

Prototype:

virtual void SetOutOfRangeType(int type)=0;

Remarks:

This method is available in release 4.0 and later only.

This method allows you to set the out of range type.

Parameters:

int type

Currently these types are supported;

CURVE_EXTRAPOLATE_LINEAR

CURVE_EXTRAPOLATE_CONSTANT

Prototype:

virtual int GetOutOfRangeType()=0;

Remarks:

This method is available in release 4.0 and later only.

This method returns the out of range type.

Return Value:

One of the following; CURVE_EXTRAPOLATE_LINEAR, CURVE_EXTRAPOLATE_CONSTANT

Prototype:

virtual int Insert(int where, CurvePoint &p)=0;

Remarks:

Inserts the specified point at the location passed.

Parameters:

int where

This value becomes the new index of the point.

CurvePoint &p

The point to insert.

Return Value:

Nonzero if the point was inserted; otherwise zero.

Prototype:

virtual int Insert(int where, CurvePoint& p, BOOL do_not_hold)=0;

Remarks:

This method is available in release 4.0 and later only.

This is identical to the Insert above but allows you to turn off/on the hold that occurs.this is useful when you are doing interactive inserts and moves from code, the original Insert hold would often get in the way

Parameters:

int where

This value becomes the new index of the point.

CurvePoint &p

The point to insert.

BOOL do_not_hold

TRUE in order not to hold; otherwise FALSE.

Return Value:

Nonzero if the point was inserted; otherwise zero.

Prototype:

virtual void Delete(int index)=0;

Remarks:

Deletes the point whose index is passed.

Parameters:

int index

The zero based index of the point to delete.

Prototype:

virtual void SetLookupTableSize(int size)=0;

Remarks:

This method sets the size of the Curve Control lookup table. The lookup table allows users of the Curve Control to easily speed up their value access. The default value for the lookup table size is 1000. The lookup table will be calculated whenever GetValue() is called with the parameter UseLookupTable==TRUE and the current LookupTable is not initialized yet, or invalid (it will be invalidated, when a point or tangent is moved, or the time has changed in case it is animated).

Parameters:

int size

The size to set.

Prototype:

virtual int GetLookupTableSize()=0;

Remarks:

Returns the current size of the lookup table. See SetLookupTableSize() above.