Class SimpleObject
See Also: Class GeomObject, Class IParamBlock, Class Mesh.
class SimpleObject : public GeomObject
Description:
This is a base class for creating procedural objects. This class implements many of the methods required to create a procedural object. The only limitation for a procedural object using SimpleObject as a base class is that it must represent itself with a mesh.
Data Members:
Note: Methods of the base class refer to these data members. For example the base class implementations of the bounding box methods use the mesh data member. Therefore the plug-in derived from SimpleObject must use these same data members.
public:
IParamBlock *pblock;
The parameter block for managing the object's parameters.
Mesh mesh;
The mesh object that is built by BuildMesh().
Interval ivalid;
The validity interval for the mesh. This interval is used to determine how BuildMesh() is called. If this interval is not set BuildMesh() will be called over and over as the system won't know when the mesh is valid or not. Make sure you set this interval to accurately reflect the validity interval for the mesh.
BOOL suspendSnap;
If TRUE, this causes no snapping to occur. This is commonly used to prevent an object from snapping to itself when it is creating. For example, in the mouse proc used to create an object, the following code is often used when snapping mouse points:
ob->suspendSnap = TRUE;
p0 = vpt->SnapPoint(m,m,NULL,SNAP_IN_PLANE);
This disables snapping temporarily to keep the object from snapping to itself.
Procedural Object plug-ins which subclass off SimpleObject must implement these methods. The default implementations are noted.
Methods:
Prototype:
virtual void BuildMesh(TimeValue t)=0;
Remarks:
Implemented by the Plug-In.
This method is called to build the mesh representation of the object using its parameter settings at the time passed. The plug-in should use the data member mesh to store the built mesh.
Parameters:
TimeValue t
The time at which to build the mesh.
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.
Example:
return stdNormalizedDim;
Default Implementation:
The default implementation returns defaultDim.
See Also: ParamDimension
Prototype:
virtual TSTR GetParameterName(int pbIndex)
Remarks:
Implemented by the Plug-In.
This method returns the name of the parameter whose index is passed.
Parameters:
int pbIndex
The index of the parameter to return the name of.
Return Value:
The name of the parameter.
Default Implementation:
The default implementation returns TSTR(_T("Parameter"))
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
(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 BOOL OKtoDisplay(TimeValue t)
Remarks:
Implemented by the Plug-In.
This method returns a BOOL to indicate if it is okay to draw the object at the time passed. Normally it is always OK to draw the object, so the default implementation returns TRUE. However for certain objects it might be a degenerate case to draw the object at a certain time (perhaps the size went to zero for example), so these objects could return FALSE.
Parameters:
TimeValue t
The time at which the object would be displayed.
Default Implementation:
{ return TRUE; }
Return Value:
TRUE if the object may be displayed; otherwise FALSE.