Class SimpleWSMMod
See Also: Class Modifier, Class IParamBlock, Class INode.
class SimpleWSMMod : public Modifier
Description:
The SimpleWSMMod class supplies most of the methods needed to implement a world space modifier.
To be a 'Simple' WSM modifier, the following assumptions are made:
The modifier only modifies the geometry channel.
The modifier uses an instance of a class derived from Deformer to do the modifying.
This class maintains a pointer to a parameter block. If the client of SimpleWSMMod uses a single parameter block then SimpleWSMMod can manage all the methods associated with SubAnims and References for the client.
If the client of SimpleWSMMod 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 SimpleWSMMod methods when 'i' refers to the parameters maintained by SimpleWSMMod.
Data Members:
Clients of SimpleWSMMod should use the following pointers when the references are created.
protected:
IParamBlock *pblock;
Pointer to a parameter block.
WSMObject *obRef;
Pointer to the world space modifier object referenced by the WSMModifier.
INode *nodeRef;
Pointer to the node in the scene referenced by the WSMModifier.
static IObjParam *ip;
Storage for the interface pointer.
static SimpleWSMMod *editMod;
Storage for the modifier currently being edited in the command panel.
Clients of SimpleWSMMod should use the following values as the reference indexes of the object, node and parameter block.
#define SIMPWSMMOD_OBREF 0
#define SIMPWSMMOD_NODEREF 1
#define SIMPWSMMOD_PBLOCKREF 2
The example code below (from \MAXSDK\SAMPLES\HOWTO\RIPPLE.CPP) shows how these are used:
MakeRefByID(FOREVER,SIMPWSMMOD_NODEREF,node);
MakeRefByID(FOREVER, SIMPWSMMOD_PBLOCKREF,
CreateParameterBlock(descModVer0, MODPBLOCK_LENGTH,
CURRENT_MODVERSION));
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.
See Also: The Advanced Topics section on the Geometry Pipeline System.
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 SimpleWSMMod 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.
Parameters:
int pbIndex
The index of the parameter.
Default Implementation:
{return defaultDim;}
Return Value:
The dimension of the parameter.
See Also: Class ParamDimension.
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:
WSMObject *GetWSMObject(TimeValue t);
Remarks:
Implemented by the System.
Evaluates the node reference and returns the WSM object. If you look in \MAXSDK\SAMPLES\HOWTO\MISC\SIMPMOD.CPP you'll see that all this method does is call EvalWorldState() on the Node reference.
Parameters:
TimeValue t
The time to get the WSMObject.
When clients of SimpleWSMMod are cloning themselves, they should call this method on the clone to copy SimpleWSMMod's data.
void SimpleWSMModClone(SimpleMod *smodSource);
Clients of SimpleWSMMod probably want to override these. If they do they should call these from within their methods.
void BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev);
void EndEditParams(IObjParam *ip, ULONG flags,Animatable *next);