Class SimpleMod

3DS Max Plug-In SDK

Class SimpleMod

See Also: Class Modifier.

class SimpleMod : public Modifier

Description:

The SimpleMod class supplies most of the methods needed to implement an object space modifier.

To be a 'Simple' modifier, the following assumptions are made:

image\bullet.gif The modifier only modifies the geometry channel.

image\bullet.gif The modifier uses an instance of a class derived from Deformer to do the modifying.

image\bullet.gif The modifier's gizmo is represented as a 3D box that has had the modifier applied to it.

This class maintains a pointer to a parameter block. If the client of SimpleMod uses a single parameter block then SimpleMod can manage all the methods associated with SubAnims and References for the client.

If the client of SimpleMod maintains several parameter blocks then the client must implement the methods NumSubs(), SubAnim(i), SubAnimName(i), NumRefs(), GetReference(i) and SetReference(i) and call the SimpleMod methods when 'i' refers to the parameters maintained by SimpleMod.

When clients of SimpleMod are cloning themselves, they should call this method on the clone to copy SimpleMod's data.

void SimpleModClone(SimpleMod *smodSource);

Clients of SimpleMod probably want to override these. If they do they should call these from within their implementation of these methods.

void BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev);

void EndEditParams(IObjParam *ip, ULONG flags,Animatable *next);

Data Members:

public:

Control *tmControl;

Points to the transform controller for the Gizmo.

Control *posControl;

Points to the position controller for the Center.

IParamBlock *pblock;

Pointer to a parameter block. Clients of SimpleMod should use the following value as the reference index of this parameter block. #define SIMPMOD_PBLOCKREF 2

static IObjParam *ip;

Storage for the interface pointer.

static MoveModBoxCMode *moveMode;

Storage for the move modifier box command mode.

static RotateModBoxCMode *rotMode;

Storage for the rotate modifier box command mode.

static UScaleModBoxCMode *uscaleMode;

Storage for the uniform scale modifier box command mode.

static NUScaleModBoxCMode *nuscaleMode;

Storage for the non-uniform scale modifier box command mode.

static SquashModBoxCMode *squashMode;

Storage for the squash modifier box command mode.

static SimpleMod *editMod;

Storage for the instance of SimpleMod that is being edited in the command panel.

Methods:

Prototype:

virtual Deformer& GetDeformer(TimeValue t,ModContext &mc,Matrix3& mat,Matrix3& invmat)=0;

Remarks:

Implemented by the Plug-In.

This method is used to retrieve the callback object that will handle the deformation.

Parameters:

TimeValue t

Specifies the time the modification is being performed.

ModContext &mc

A reference to the ModContext.

Matrix3& mat

A reference to a matrix that describes the space the modification is supposed to happen in. This is computed from the ModContext matrix and the controllers controlling the gizmo and center of the modifier. The plug-in developers job is simply to transform each point to be deformed by this matrix before it performs its own deformation to the point. After the modifier applies its own deformation to the point, the developer transforms the point by the inverse of this matrix (passed below).

Matrix3& invmat

This is the inverse of the matrix above. See the comment above for how this is used.

Return Value:

A C++ reference to the deformer callback object.

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.

Example:

If the plug-in uses a parameter map for handling its UI, it may call a method of the parameter map to handle this: pmapParam->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

 

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 Interval GetValidity(TimeValue t)

Remarks:

Implemented by the Plug-In.

The SimpleMod class calls this method to retrieve the validity interval of the modifier. The modifier provides this interval by starting an interval at FOREVER and intersecting it with each of its parameters validity intervals.

Parameters:

TimeValue t

The time to compute the validity interval.

Default Implementation:

{return FOREVER;}

Return Value:

The validity interval of the modifier.

See Also: The Advanced Topics section on Intervals.

Prototype:

virtual ParamDimension *GetParameterDim(int pbIndex)

Remarks:

Implemented by the Plug-In.

Returns the dimension of the parameter whose index is passed. See Class ParamDimension.

Parameters:

int pbIndex

The index of the parameter.

Default Implementation:

{return defaultDim;}

Return Value:

A pointer to the dimension of the parameter.

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

Index of the parameter.

Default Implementation:

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

Return Value:

The name of the parameter.

Prototype:

virtual BOOL GetModLimits(TimeValue t,float &zmin, float &zmax, int &axis)

Remarks:

Implemented by the Plug-In.

If the effect can be limited (like the way bend/taper/twist/etc. can be limited) then it should specify the min and max limits and the axis that it is limited along. SimpleMod will then display the limits as part of the Gizmo. If it does not support limits then it should return FALSE or simply not implement this method.

Parameters:

TimeValue t

The time to get the limits.

float &zmin

The min limit.

float &zmax

The max limit.

int &axis

The axis that it is limited along: x=0, y=1, z=2.

Return Value:

TRUE if limits are supported; otherwise FALSE.

Default Implementation:

{return FALSE;}