Class SimpleSpline

3DS Max Plug-In SDK

Class SimpleSpline

See Also: Class ShapeObject.

class SimpleSpline : public ShapeObject

Description:

Defines a simple spline object class to make spline primitives easier to create. This class provides default implementations for most of the ShapeObject methods. The plug-in derived from SimpleSpline must only implement a handful of methods to create a shape plug-in.

SimpleSpline plug-ins use a Super Class ID of SHAPE_CLASS_ID.

Data Members:

public:

IParamBlock *ipblock;

Interpolation parameter block (handled by SimpleSpline).

IParamBlock *pblock;

User's parameter block. See Class IParamBlock.

static IParamMap *ipmapParam;

The parameter map. See Class IParamMap.

static int dlgSteps;

The dialog steps settings.

static BOOL dlgOptimize;

The dialog Optimize toggle.

static BOOL dlgAdaptive;

The dialog Adaptive toggle.

BezierShape shape;

The Spline cache.

Interval ivalid;

The validity interval for the spline. See Class Interval.

BOOL suspendSnap;

Flag to suspend snapping used during creation.

static SimpleSpline *editOb;

This is the spline being edited in the command panel.

Methods:

Prototype:

SimpleSpline();

Remarks:

Constructor. The validity interval is set to empty, and the pblocks are set to NULL.

Prototype:

~SimpleSpline();

Remarks:

Destructor.

Clients of SimpleSpline need to implement these methods:

Prototype:

virtual TCHAR *GetObjectName() = 0;

Remarks:

Implemented by the Plug-In.

Returns the name that will appear in the history browser.

Prototype:

virtual void InitNodeName(TSTR& s) = 0;

Remarks:

Implemented by the Plug-In.

This method retrieves the default name of the node when it is created.

Parameters:

TSTR& s

The name is stored here.

Prototype:

virtual Class_ID ClassID() = 0;

Remarks:

Implemented by the Plug-In.

Returns the unique Class_ID of the plug-in. See Class Class_ID for more details.

Prototype:

virtual void GetClassName(TSTR& s) = 0;

Remarks:

Implemented by the Plug-In.

Retrieves the name of the plug-in class. This is used internally for debugging purposes.

Parameters:

TSTR& s

The name is stored here.

Prototype:

virtual void BuildShape(TimeValue t,BezierShape& ashape) = 0;

Remarks:

Implemented by the Plug-In.

This method is called to build the shape at the specified time and store the results in ashape.

Parameters:

TimeValue t

The time to build the shape.

BezierShape& ashape

The created shape is store here.

Prototype:

virtual RefTargetHandle Clone(RemapDir& remap = NoRemap()) = 0;

Remarks:

Implemented by the Plug-In.

This method is called to have the plug-in clone itself. The plug-in should clone all its references as well.

Parameters:

RemapDir &remap = NoRemap()

This class is used for remapping references during a Clone. See Class RemapDir.

Return Value:

A pointer to the cloned item.

Prototype:

virtual void EndEditParams(IObjParam *ip, ULONG flags,

Animatable *next) = 0;

Remarks:

Implemented by the Plug-In.

This method is called when the user is finished editing object’s parameters. The system passes a flag into the EndEditParams() method to indicate if the rollup page should be removed. If this flag is TRUE, the plug-in must un-register the rollup page, and delete it from the panel.

Parameters:

IObjParam *ip

This is an interface pointer passed in. The developer may use the interface pointer to call methods such as DeleteRollupPage().

ULONG flags

The following flag may be set:

END_EDIT_REMOVEUI

If TRUE, the item's user interface should be removed.

Animatable *next

This parameter may be used in the motion and hierarchy branches of the command panel. This pointer allows a plug-in to look at the ClassID of the next item that was being edited, and if it is the same as this item, to not replace the entire UI in the command panel. Note that for items that are edited in the modifier branch this field can be ignored.

Prototype:

virtual CreateMouseCallBack* GetCreateMouseCallBack() = 0;

Remarks:

Implemented by the Plug-In.

This method allows the system to retrieve a callback object used in creating the shape in the 3D viewports. This method returns a pointer to an instance of a class derived from CreateMouseCallBack. This class has a method proc() which is where the developer defines the user/mouse interaction used during the shape creation phase.

Return Value:

A pointer to an instance of a class derived from CreateMouseCallBack.

Prototype:

virtual BOOL ValidForDisplay(TimeValue t) = 0;

Remarks:

Implemented by the Plug-In.

Returns TRUE if it is okay to display the shape at the time passed; otherwise FALSE. Certain shapes may not want to be displayed at a certain time, for example if their size goes to zero at some point.

Parameters:

TimeValue t

The time to check.

Prototype:

virtual void InvalidateUI();

Remarks:

Implemented by the Plug-In.

This is called if the user interface parameters needs to be updated because the user moved to a new time. The UI controls must display values for the current time.

If the plug-in uses a parameter map for handling its UI, it may call a method of the parameter map to handle this: ipmapParam->Invalidate();

If the plug-in does not use parameter maps, it should call the SetValue() method on each of its controls that display a value, for example the spinner controls. This will cause to the control to update the value displayed. The code below shows how this may be done for a spinner control. Note that ip and pblock are assumed to be initialized interface and parameter block pointers

(IObjParam *ip, IParamBlock *pblock).

float newval;

Interval valid=FOREVER;

TimeValue t=ip->GetTime();

// Get the value from the parameter block at the current time.

pblock->GetValue( PB_ANGLE, t, newval, valid );

// Set the value. Note that the notify argument is passed as FALSE.

// This ensures no messages are sent when the value changes.

angleSpin->SetValue( newval, FALSE );

Prototype:

virtual ParamDimension *GetParameterDim(int pbIndex)

Remarks:

Implemented by the Plug-In.

This method returns the parameter dimension of the parameter whose index is passed.

Parameters:

int pbIndex

The index of the parameter to return the dimension of.

Return Value:

Pointer to a ParamDimension. See Class ParamDimension.

Default Implementation:

{return defaultDim;}

Prototype:

virtual TSTR GetParameterName(int pbIndex)

Remarks:

Implemented by the Plug-In.

Returns the name of the parameter whose index is passed.

Parameters:

int pbIndex

The index into the parameter block of the parameter to return the name of.

Default Implementation:

{return TSTR(_T("Parameter"));}

Prototype:

virtual BOOL DisplayVertTicksDuringCreation();

Remarks:

Returns TRUE if the Simple Spline should display vertex ticks during its creation; otherwise FALSE.

Default Implementation:

{ return TRUE; }