Class BaseObject

3DS Max Plug-In SDK

Class BaseObject

See Also: Class ReferenceTarget, Class INode, Class ViewExp, Class Box3, Class IPoint2, Class Matrix3, Structure SnapInfo, Class Point3, Class CreateMouseCallBack, Template Class Tab, Class Interface.

class BaseObject : public ReferenceTarget

Description:

This is the base class for objects and modifiers. Anything with a representation in the 3D viewports is derived from BaseObject (including modifiers and controllers whose gizmos appear in the viewports). The methods here are things such as displaying the object in the viewports, checking for intersection of the object and points the user clicks with the mouse, snapping to the object, and computing various bounding boxes for the object. Also there are methods for returning the name of the object to appear in the modifier stack, a method to deal with creating the object in the viewports (if appropriate), and named selection set related methods. There are also methods that allow other plug-ins to access the changeable parameters of the object. Finally there are several method that deal with sub-object selection, sub-object display, sub-object hit testing, and moving/rotating/scaling sub-object components of the object.

Method Groups:

The hyperlinks below jump to the start of groups of related methods within the class:

Object Name and Create Callback

Object Level Display, Hit Test, Snap, and Bounding Box Methods

Parameter Block Access

Named Selection Sets

Topology Change

Sub-Object Selection

Sub-Object Cloning

Sub-Object Display, Hit Testing, and Bound Box Methods

Sub-Object Center and TM Methods

Methods:

Object Name and Create Callback

Prototype:

virtual TCHAR *GetObjectName()

Remarks:

Implemented by the Plug-In.

Returns the name that will appear in the history browser (modifier stack).

Default Implementation:

{ return _T("Object"); }

Prototype:

virtual CreateMouseCallBack* GetCreateMouseCallBack()=0;

Remarks:

Implemented by the Plug-In.

This method allows the system to retrieve a callback object used in creating an object 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 programmer defines the user/mouse interaction during the object creation phase.

Return Value:

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

Named Selection Sets

A modifier that supports sub-object selection can choose to support named sub-object selection sets. Methods in the interface passed to objects allow them to add items to the sub-object selection set drop down list in the 3ds max toolbar. A modifier that wishes to support this capability maintains its list of named sub-object selections. When the user enters sub-object selection mode the modifier adds its named selection sets into the drop down (using Interface:: AppendSubObjectNamedSelSet()). See the Advanced Topics section on Sub-Object Selection for details.

Prototype:

virtual BOOL SupportsNamedSubSels();

Remarks:

Implemented by the Plug-In.

Returns TRUE if the plug-in supports named sub-object selection sets; otherwise FALSE.

Default Implementation:

{return FALSE;}

The following three methods are called when the user picks items from the drop down list.

Prototype:

virtual void ActivateSubSelSet(TSTR &setName);

Remarks:

Implemented by the Plug-In.

When the user chooses a name from the drop down list this method is called. The plug-in should respond by selecting the set identified by the name passed.

Parameters:

TSTR &setName

The name of the set to select.

Prototype:

virtual void NewSetFromCurSel(TSTR &setName);

Remarks:

Implemented by the Plug-In.

If the user types a new name into the named selection set drop down then this method is called. The plug-in should respond by creating a new set and give it the specified name.

Parameters:

TSTR &setName

The name for the selection set.

Prototype:

virtual void RemoveSubSelSet(TSTR &setName);

Remarks:

Implemented by the Plug-In.

If the user selects a set from the drop down and then chooses Remove Named Selections from the Edit menu this method is called. The plug-in should respond by removing the specified selection set.

Parameters:

TSTR &setName

The selection set to remove.

Prototype:

virtual void SetupNamedSelDropDown();

Remarks:

This method is available in release 2.0 and later only.

To support the new Edit Named Selections dialog, plug-ins must implement this method.

This method is called to rebuild the named selelction set drop down list. This is usually done by calling Interface::ClearSubObjectNamedSelSets() followed by calls to Interface:: AppendSubObjectNamedSelSet().

Default Implementation:

{}

Prototype:

virtual int NumNamedSelSets();

Remarks:

This method is available in release 2.0 and later only.

To support the new Edit Named Selections dialog, plug-ins must implement this method.

Returns the number of named selection sets.

Default Implementation:

{return 0;}

Prototype:

virtual TSTR GetNamedSelSetName(int i);

Remarks:

This method is available in release 2.0 and later only.

To support the new Edit Named Selections dialog, plug-ins must implement this method.

Returns the name of the 'i-th' named selection set.

Parameters:

int i

The index of the selection set whose name is returned.

Default Implementation:

{return _T("");}

Prototype:

virtual void SetNamedSelSetName(int i,TSTR &newName);

Remarks:

This method is available in release 2.0 and later only.

To support the new Edit Named Selections dialog, plug-ins must implement this method.

This methods sets the name of the selection set whose index is passed to the name passed.

Note: Developers need to implement Undo / Redo for modifications to their named selection sets.

Parameters:

int i

The index of the selection set whose name is to be set.

TSTR &newName

The new name for the selection set the plug-in should store.

Default Implementation:

{}

Prototype:

virtual void NewSetByOperator(TSTR &newName,Tab<int> &sets,int op);

Remarks:

This method is available in release 2.0 and later only.

To support the new Edit Named Selections dialog, plug-ins must implement this method.

The user may bring up the Edit Named Selections dialog via the Edit / Edit Named Selection ... command. This dialog allows the user to create new selection sets using 'boolean' operations to the sets including 'Combine', 'Subtract (A-B)', 'Subtract (B-A)' and 'Intersection'. This method is called on the plug-in to generate a new selection set via one of these operations.

This method assumes the developer will append a new seleciton set with the name passed. This will result in two sets with identical names. Then the system will call RemoveSubSelSet() afterwards, so that the first one that is found (the old one, since the new one was appended) will be deleted.

Note: Developers need to implement Undo / Redo for modifications to their named selection sets. See \MAXSDK\SAMPLES\MODIFIERS\MESHSEL.CPP for an example.

Parameters:

TSTR &newName

The new name for the selection set is passed here.

Tab<int> &sets

A table of the selection sets to operate on. There are sets.Count() sets in the table.

int op

One of the following values:

NEWSET_MERGE

The sets should be merged.

NEWSET_INTERSECTION 

The sets should be intersected -- that is the items common to both sets should appear in the new set.

NEWSET_SUBTRACT

The new set should be the result of subtracting the 1st thru nth set from the 0th set.

Default Implementation:

{}

Object Level Display, Hit Test, Snap, and Bounding Box Methods

Prototype:

virtual int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags)

Remarks:

Implemented by the Plug-In.

This is called by the system to have the item display itself (perform a quick render in viewport, using the current TM). Note: For this method to be called the object's validity interval must be invalid at the specified time t. If the interval is valid, the system may not call this method since it thinks the display is already valid.

Parameters:

TimeValue t

The time to display the object.

INode* inode

The node to display.

ViewExp *vpt

An interface pointer that may be used to call methods associated with the viewports.

int flags

See List of Display Flags.

Return Value:

The return value is not currently used.

Default Implementation:

{ return 0; };

Prototype:

virtual void SetExtendedDisplay(int flags);

Remarks:

This method is used for storing mode-dependent display attributes.

Before an object's Display() method is called, the appropriate bits of the extended display flag variable are set and this method is called. After that, the Display() method is called. If the object must display itself differently based on the settings of the extended display bit fields, then the object must save the flags passed into the this method. Otherwise, there is no need for the object to store the flags.

Parameters:

int flags

The flags to store.

Default Implementation:

{}

Prototype:

virtual int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt);

Remarks:

Implemented by the Plug-In.

This method is called to determine if the specified screen point intersects the item. The method returns nonzero if the item was hit; otherwise 0.

Parameters:

TimeValue t

The time to perform the hit test.

INode* inode

A pointer to the node to test.

int type

The type of hit testing to perform. See Hit Test Types for details.

int crossing

The state of the crossing setting. If TRUE crossing selection is on.

int flags

The hit test flags. See Hit Test Flags for details.

IPoint2 *p

The screen point to test.

ViewExp *vpt

An interface pointer that may be used to call methods associated with the viewports.

Return Value:

Nonzero if the item was hit; otherwise 0.

Default Implementation:

{return 0;}

Prototype:

virtual void Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt);

Remarks:

Implemented by the Plug-In.

Checks the point passed for a snap and updates the SnapInfo structure.

Note: The new snapping system introduced in release 2.0 causes this method to no longer be called. Developers wanting to find snap points on an Editable Mesh object should see the method XmeshSnap::Snap() in \MAXSDK\SAMPLES\SNAPS\XMESH\XMESH.CPP.

Parameters:

TimeValue t

The time to check.

INode* inode

The node to check.

SnapInfo *snap

The snap info structure to update.

IPoint2 *p

The screen point to check.

ViewExp *vpt

An interface pointer that may be used to call methods associated with the viewports.

Prototype:

virtual void GetWorldBoundBox(TimeValue t, INode * inode, ViewExp* vp, Box3& box )

Remarks:

Implemented by the Plug-In.

This method returns the world space bounding box for Objects (see below for the Sub-object gizmo or Modifiers gizmo version). The bounding box returned by this method does not need to be precise. It should however be calculated rapidly. The object can handle this by transforming the 8 points of its local bounding box into world space and take the minimums and maximums of the result. Although this isn't necessarily the tightest bounding box of the objects points in world space, it is close enough.

Parameters:

TimeValue t

The time to compute the bounding box.

INode* inode

The node to calculate the bounding box for.

ViewExp* vp

An interface pointer that may be used to call methods associated with the viewports.

Box3& box

The bounding box is returned through box.

Prototype:

virtual void GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vp, Box3& box )

Remarks:

Implemented by the Plug-In.

This is the object space bounding box, the box in the object's local coordinates. The system expects that requesting the object space bounding box will be fast.

Parameters:

TimeValue t

The time to retrieve the bounding box.

INode* inode

The node to calculate the bounding box for.

ViewExp* vp

An interface pointer that may be used to call methods associated with the viewports.

Box3& box

The bounding box is returned through box.

Topology Methods

Prototype:

virtual BOOL OKToChangeTopology(TSTR &modName)

Remarks:

Implemented by the System.

This method is called to see if any modifiers down in the pipeline depend on topology. It sends the message REFMSG_IS_OK_TO_CHANGE_TOPOLOGY to see if any modifiers or objects down the pipeline depend on topology.

Parameters:

TSTR &modName

This parameter is set to the dependent modifier's name if there is an item that depends on topology.

Return Value:

Returns TRUE if it is okay to change the topology; FALSE if it is not okay to change the topology.

Prototype:

virtual BOOL ChangeTopology()

Remarks:

Implemented by the Plug-In.

This method asks the question of an object or modifier "Do you change topology"? An object or modifier returns TRUE if it is capable of changing topology when its parameters are being edited; otherwise FALSE.

When an item is selected for editing, and there is a modifier in the pipeline that depends on topology, the system calls this method to see if it may potentially change the topology. If this method returns TRUE the system will put up a warning message indicating that a modifier exists in the stack that depends on topology.

Default Implementation:

{return TRUE;}

Prototype:

virtual void ForceNotify(Interval& i)

Remarks:

This method is no longer used.

Parameter Block Access

Prototype:

virtual IParamArray *GetParamBlock();

Remarks:

Implemented by the Plug-In.

An object or modifier should implement this method if it wishes to make its parameter block available for other plug-ins to access it. The system itself doesn't actually call this method. This method is optional.

Return Value:

A pointer to the item's parameter block. See Class IParamArray.

Default Implementation:

{return NULL;}

Prototype:

virtual int GetParamBlockIndex(int id);

Remarks:

Implemented by the Plug-In.

If a plug-in makes its parameter block available (using GetParamBlock()) then it will need to provide #defines for indices into the parameter block. These defines should not be directly used with the parameter block but instead converted by this function that the plug-in implements. This way if a parameter moves around in a future version of the plug-in the #define can be remapped. A return value of -1 indicates an invalid parameter id.

Parameters:

int id

The parameter block id. See: List of Parameter Block IDs.

Return Value:

The parameter block index or -1 if it is invalid.

Default Implementation:

{return -1;}

Sub-Object Selection

Affine transformation methods

Prototype:

virtual void Move(TimeValue t, Matrix3& partm, Matrix3& tmAxis, Point3& val, BOOL localOrigin=FALSE )

Remarks:

Implemented by the Plug-In.

When this method is called the plug-in should respond by moving its selected sub-object components.

Parameters:

TimeValue t

The time of the transformation.

Matrix3& partm

The 'parent' transformation matrix. This matrix represents a transformation that would take points in the modifier's space and convert them into world space points. This is constructed as the node's transformation matrix times the inverse of the ModContext's transformation matrix. The node whose transformation is used is the node the user clicked on in the scene - modifiers can be instanced so there could be more than one node.

Matrix3& tmAxis

The matrix that represents the axis system. This is the space in which the transformation is taking place.

Point3& val

This value is a vector with X, Y, and Z representing the movement along each axis.

BOOL localOrigin=FALSE

When TRUE the transformation is occurring about the sub-object's local origin.

Prototype:

virtual void Rotate(TimeValue t, Matrix3& partm, Matrix3& tmAxis, Quat& val, BOOL localOrigin=FALSE )

Remarks:

Implemented by the Plug-In.

When this method is called the plug-in should respond by rotating its selected sub-object components.

Parameters:

TimeValue t

The time of the transformation.

Matrix3& partm

The 'parent' transformation matrix. This matrix represents a transformation that would take points in the modifier's space and convert them into world space points. This is constructed as the node's transformation matrix times the inverse of the ModContext's transformation matrix. The node whose transformation is used is the node the user clicked on in the scene - modifiers can be instanced so there could be more than one node.

Matrix3& tmAxis

The matrix that represents the axis system. This is the space in which the transformation is taking place.

Quat& val

The amount to rotate the selected components.

BOOL localOrigin=FALSE

When TRUE the transformation is occurring about the sub-object's local origin. Note: This information may be passed onto a transform controller (if there is one) so they may avoid generating 0 valued position keys for rotation and scales. For example if the user is rotating an item about anything other than its local origin then it will have to translate in addition to rotating to achieve the result. If a user creates an object, turns on the animate button, and rotates the object about the world origin, and then plays back the animation, the object does not do what the was done interactively. The object ends up in the same position, but it does so by both moving and rotating. Therefore both a position and a rotation key are created. If the user performs a rotation about the local origin however there is no need to create a position key since the object didn't move (it only rotated). So a transform controller can use this information to avoid generating 0 valued position keys for rotation and scales.

Prototype:

virtual void Scale(TimeValue t, Matrix3& partm, Matrix3& tmAxis, Point3& val, BOOL localOrigin=FALSE )

Remarks:

Implemented by the Plug-In.

When this method is called the plug-in should respond by scaling its selected sub-object components.

Parameters:

TimeValue t

The time of the transformation.

Matrix3& partm

The 'parent' transformation matrix. This matrix represents a transformation that would take points in the modifier's space and convert them into world space points. This is constructed as the node's transformation matrix times the inverse of the ModContext's transformation matrix. The node whose transformation is used is the node the user clicked on in the scene - modifiers can be instanced so there could be more than one node.

Matrix3& tmAxis

The matrix that represents the axis system. This is the space in which the transformation is taking place.

Point3& val

This value is a vector with X, Y, and Z representing the scale along X, Y, and Z respectively.

BOOL localOrigin=FALSE

When TRUE the transformation is occurring about the sub-object's local origin. See the note above in the Rotate method.

The following methods may be used to receive notification about the starting and ending phases of transforming the item when in sub-object selection.

Prototype:

virtual void TransformStart(TimeValue t);

Remarks:

Implemented by the Plug-In.

This method is called before the first Move(), Rotate() or Scale() call and before a hold is in effect.

Parameters:

TimeValue t

The current time when this method is called.

Prototype:

virtual void TransformHoldingStart(TimeValue t);

Remarks:

Implemented by the Plug-In.

This method is called before the first Move(), Rotate() or Scale() call and after a hold is in effect.

Parameters:

TimeValue t

The current time when this method is called.

Prototype:

virtual void TransformHoldingFinish(TimeValue t);

Remarks:

Implemented by the Plug-In.

This method is called after the user has completed the Move(), Rotate() or Scale() operation and before the undo object has been accepted.

Parameters:

TimeValue t

The current time when this method is called.

Prototype:

virtual void TransformFinish(TimeValue t);

Remarks:

Implemented by the Plug-In.

This method is called after the user has completed the Move(), Rotate() or Scale() operation and the undo object has been accepted.

Parameters:

TimeValue t

The current time when this method is called.

Prototype:

virtual void TransformCancel(TimeValue t);

Remarks:

This method is called when the transform operation is canceled by a right-click and the undo has been canceled.

Parameters:

TimeValue t

The current time when this method is called.

Sub-Object Display, Hit Test, and Bounding Box Methods

The following methods are for sub-object selection. If the derived class is NOT a modifier, the modContext pointer passed to some of these methods will be NULL.

Prototype:

virtual int Display(TimeValue t, INode* inode, ViewExp *vpt, int flags, ModContext* mc)

Remarks:

Implemented by the Plug-In.

When this method is called the plug-in should respond by performing a quick render of the modifier gizmo in viewport using the current TM.

Note for Modifiers: For this method to be called properly, one must send two reference messages using NotifyDependents.

In BeginEditParams send:

NotifyDependents(Interval(t,t), PART_ALL, REFMSG_MOD_DISPLAY_ON);

In EndEditParams send:

NotifyDependents(Interval(t,t), PART_ALL, REFMSG_MOD_DISPLAY_OFF);

Parameters:

TimeValue t

The time to display the item.

INode* inode

The node to render.

ViewExp *vpt

An interface pointer that may be used to call methods associated with the viewports.

int flags

See List of Display Flags.

ModContext* mc

A pointer to the modifiers ModContext.

Return Value:

Nonzero if the item was displayed; otherwise 0.

Default Implementation:

{ return 0; }

Prototype:

virtual int HitTest(TimeValue t, INode* inode, int type, int crossing, int flags, IPoint2 *p, ViewExp *vpt, ModContext* mc)

Remarks:

Implemented by the Plug-In.

This method is used in modifier gizmo hit testing. It is called to determine if the specified screen point intersects the gizmo. The method returns nonzero if the item was hit; otherwise 0.

Parameters:

TimeValue t

The time to perform the hit test.

INode* inode

A pointer to the node to test.

int type

The type of hit testing to perform. See Hit Test Types for details.

int crossing

The state of the crossing setting. If TRUE crossing selection is on.

int flags

The hit test flags. See Hit Test Flags for details.

IPoint2 *p

The screen point to test.

ViewExp *vpt

An interface pointer that may be used to call methods associated with the viewports.

ModContext* mc

A pointer to the modifiers ModContext.

Return Value:

Nonzero if the item was hit; otherwise 0.

Default Implementation:

{ return 0; }

Prototype:

virtual void GetWorldBoundBox(TimeValue t, INode* inode, ViewExp *vpt, Box3& box, ModContext *mc)

Remarks:

Implemented by the Plug-In.

This method computes the world space bounding box of the modifier gizmo (or any object that when in sub-object mode has a gizmo).

Parameters:

TimeValue t

The time to compute the bounding box.

INode* inode

The node to calculate the bounding box for.

ViewExp *vpt

An interface pointer that may be used to call methods associated with the viewports.

Box3& box

The bounding box is returned through box.

ModContext *mc

A pointer to the modifiers ModContext.

 

Prototype:

virtual BOOL HasUVW();

Remarks:

Implemented by the Plug-In.

This method is available in release 2.0 and later only.

It is called to find out if the object is has UVW coordinates. This method returns TRUE if the object has UVW coordinates; otherwise FALSE. In 3ds max 2.0 and later there is code in the renderer that will automatically turn on the UVW coordinates of the base object if UV's are missing (and needed). The base object has to implement two simple methods to make this work: HasUVW() and SetGenUVW().

Developers are encouraged to put these methods in their objects: it makes using the program easier for the user. If they are not implemented, it doesn't cause any real harm: it will just operate as before and put up the missing UVW's message.

Here is how the procedural sphere implements these methods:

BOOL SphereObject::GetGenUVW() {

BOOL genUVs;

Interval v;

pblock->GetValue(PB_GENUVS, 0, genUVs, v);

return genUVs;

}

void SphereObject::SetGenUVW(BOOL sw) {

if (sw==GetGenUVW()) return;

pblock->SetValue(PB_GENUVS,0, sw);    

}

Important Note: The pblock->SetValue() will cause a call to NotifyDependents(FOREVER, PART_TEXMAP, REFMSG_CHANGE), which will invalidate the UVW cache. It is essential that this call be made, so if the 'generate UVW' boolean is not handled by a parameter block, then NotifyDependents() needs to be called explicitly.

Also Note: For "modifiable objects" that pass up the pipeline getting modified, such as TriObject, EditTriObject, etc., which cannot generate their own UVWs, but can carry them in their data structures, only this HasUVW() method needs to be implemented. For example, here is the implementation for TriObject:

BOOL TriObject::HasUVW() { return mesh.tvFace?1:0; }

Default Implementation:

{ return 1; }

Prototype:

virtual BOOL HasUVW(int mapChannel);

Remarks:

This method is available in release 3.0 and later only.

It is called to find out if the object is has UVW coordinates for the specified mapping channel. This method returns TRUE if the object has UVW coordinates; otherwise FALSE. See the method HasUVW() above for more details.

Parameters:

int mapChannel

See List of Mapping Channels Values.

Default Implementation:

{ return (mapChannel==1) ? HasUVW() : FALSE; }

 

Prototype:

virtual void SetGenUVW(BOOL sw);

Remarks:

Implemented by the Plug-In.

This method is available in release 2.0 and later only.

This method is called to change the state of its Generate UVW boolean. If the state changes, the object must send a REFMSG_CHANGE up the pipeline by calling NotifyDependents(). This applies to map channel 1.

Parameters:

BOOL sw

The new state for the generate UVW flag.

Default Implementation:

{}

Prototype:

virtual void SetGenUVW(int mapChannel, BOOL sw);

Remarks:

This method is available in release 3.0 and later only.

This method is called to change the state of its Generate UVW boolean for the specified mapping channel. If the state changes, the object must send a REFMSG_CHANGE up the pipeline by calling NotifyDependents().

Parameters:

int mapChannel

The mapping channel index. See List of Mapping Channel Index Values.

BOOL sw

The new state for the generate UVW flag.

Default Implementation:

{ if (mapChannel==1) SetGenUVW(sw); }

Prototype:

virtual void ShowEndResultChanged(BOOL showEndResult);

Remarks:

This method is available in release 3.0 and later only.

This method notifies the BaseObject that the end result display has been switched (the "Show End Result" button has been toggled). Sometimes this is needed for display changes.

This method is implemented in Edit Mesh, which uses it as shown below:

void EditMeshMod::ShowEndResultChanged(BOOL showEndResult) {

NotifyDependents(FOREVER, PART_DISPLAY, REFMSG_CHANGE);

}

This allows the Edit Mesh modifier to update itself in repsonse to a user click of the "Show End Result" button in the modifier panel.

Parameters:

BOOL showEndResult

TRUE if Show End Result is on; FALSE if off.

Default Implementation:

{ }

Sub-Object Cloning

Prototype:

virtual void CloneSelSubComponents(TimeValue t)

Remarks:

Implemented by the Plug-In.

This method is called to make a copy of the selected sub-object components of the item. If this is called on an object, the selection level of the object is used to determine which type of sub-objects are cloned. For instance in a Mesh, the selection level determines if selected verticies, edges or faces are cloned. If this is called on a Modifier then the selection level of the modifier is used. Modifiers call Interface::GetModContexts() to get a list of ModContexts, one for each object the modifier is applied to. Then the selected sub-objects are cloned for each object in the list.

Parameters:

TimeValue t

The time at which to clone the selected sub-object components.

Prototype:

virtual void AcceptCloneSelSubComponents(TimeValue t)

Remarks:

This method is available in release 2.0 and later only.

This method is called when the user mouses up after shift-cloning a sub-object selection.

Parameters:

TimeValue t

The time at which the clone of the selected components is being done.

Default Implementation:

{}

Sub-Object Selection

Prototype:

virtual void SelectSubComponent(HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert=FALSE)

Remarks:

Implemented by the Plug-In.

This method is called to change the selection state of the component identified by hitRec.

Parameters:

HitRecord *hitRec

Identifies the component whose selected state should be set. See Class HitRecord .

BOOL selected

TRUE if the item should be selected; FALSE if the item should be de-selected.

BOOL all

TRUE if all components in the HitRecord chain should be selected; FALSE if only the top-level HitRecord should be selected. (A HitRecord contains a Next() pointer; typically you want to do whatever you're doing to all the Next()'s until Next() returns NULL).

BOOL invert=FALSE

This is set to TRUE when all is also set to TRUE and the user is holding down the Shift key while region selecting in select mode. This indicates the items hit in the region should have their selection state inverted

Prototype:

virtual void ClearSelection(int selLevel);

Remarks:

Implemented by the Plug-In.

This method is called to clear the selection for the given sub-object level. All sub-object elements of this type should be deselected. This will be called when the user chooses Select None from the 3ds max Edit menu.

Parameters:

int selLevel

Specifies the selection level to clear.

Default Implementation:

{}

Prototype:

virtual void SelectAll(int selLevel);

Remarks:

Implemented by the Plug-In.

This method is called to select every element of the given sub-object level. This will be called when the user chooses Select All from the 3ds max Edit menu.

Parameters:

int selLevel

Specifies the selection level to select.

Default Implementation:

{}

Prototype:

virtual void InvertSelection(int selLevel);

Remarks:

This method is called to invert the specified sub-object level. If the element is selected it should be deselected. If it's deselected it should be selected. This will be called when the user chooses Select Invert from the 3ds max Edit menu.

Parameters:

int selLevel

Specifies the selection level to invert.

Default Implementation:

{}

Prototype:

virtual int SubObjectIndex(HitRecord *hitRec);

Remarks:

Implemented by the Plug-In.

Returns the index of the sub-object element identified by the HitRecord hitRec. See Class HitRecord. The sub-object index identifies a sub-object component. The relationship between the index and the component is established by the modifier. For example an edit modifier may allow the user to select a group of faces and these groups of faces may be identified as group 0, group 1, group 2, etc. Given a hit record that identifies a face, the edit modifier's implementation of this method would return the group index that the face belonged to.

Default Implementation:

{return 0;}

Prototype:

virtual void ActivateSubobjSel(int level, XFormModes& modes )

Remarks:

Implemented by the Plug-In.

When the user changes the selection of the sub-object drop down, this method is called to notify the plug-in. This method should provide instances of a class derived from CommandMode to support move, rotate, non-uniform scale, uniform scale, and squash modes. These modes replace their object mode counterparts however the user still uses the move/rotate/scale tool buttons in the toolbar to activate them. If a certain level of sub-object selection does not support one or more of the modes NULL may be passed. If NULL is specified the corresponding toolbar button will be grayed out.

Parameters:

int level

The sub-object selection level the command modes should be set to support. A level of 0 indicates object level selection. If level is greater than or equal to 1 the index refers to the types registered by the object in the order they appeared in the list when registered by Interface::RegisterSubObjectTypes(). See Class Interface.

XFormModes& modes

The command modes to support

Sample Code:

void SimpleMod::ActivateSubobjSel(int level, XFormModes& modes )

 {

 switch ( level ) {

  case 1: // Modifier box

   modes = XFormModes(moveMode,rotMode,nuscaleMode,

    uscaleMode,squashMode,NULL);

   break;

  case 2: // Modifier Center

   modes = XFormModes(moveMode,NULL,NULL,NULL,NULL,NULL);

   break;

  }

 NotifyDependents(FOREVER,PART_DISPLAY,REFMSG_CHANGE);

 }

See Also: Class XFormModes.

Sub-Object Centers and TMs

Prototype:

virtual void GetSubObjectCenters(SubObjAxisCallback *cb,TimeValue t,INode *node, ModContext *mc)

Remarks:

Implemented by the Plug-In.

When the user is in a sub-object selection level, the system needs to get the reference coordinate system definition from the current modifier being edited so that it can display the axis. This method specifies the position of the center. The plug-in enumerates its centers and calls the callback cb once for each.

Parameters:

SubObjAxisCallback *cb

The callback object whose methods may be called. See Class SubObjAxisCallback.

TimeValue t

The time to enumerate the centers.

INode *node

A pointer to the node.

ModContext *mc

A pointer to the ModContext.

Prototype:

virtual void GetSubObjectTMs(SubObjAxisCallback *cb, TimeValue t,INode *node, ModContext *mc)

Remarks:

Implemented by the Plug-In.

When the user is in a sub-object selection level, the system needs to get the reference coordinate system definition from the current modifier being edited so that it can display the axis. This method returns the axis system of the reference coordinate system. The plug-in enumerates its TMs and calls the callback cb once for each. See Sub-Object Coordinate Systems.

Parameters:

SubObjAxisCallback *cb

The callback object whose methods may be called.

TimeValue t

The time to enumerate the TMs.

INode *node

A pointer to the node.

ModContext *mc

A pointer to the ModContext.

Prototype:

virtual void NotifyPreCollapse(INode *node, IDerivedObject *derObj, int index);

Remarks:

This method is available in release 4.0 and later only.

This method is called before a modifier or object is collapsed. See also Class NotifyCollapseEnumProc.

Parameters:

INode *node

Points to the node for the object being collapsed.

IDerivedObject *derObj

If the object associated with node above is a Modifier this points to the derived object.If it's an object then this is NULL.

int index

If the object associated with node above is a Modifier this is the index of this modifier in the DerivedObject.. If it's an object then this is 0.

Default Implementation:

{}

Prototype:

virtual void NotifyPostCollapse(INode *node, Object *obj, IDerivedObject *derObj, int index);

Remarks:

This method is available in release 4.0 and later only.

This method is called after a modifier or object is collapsed. See also Class NotifyCollapseEnumProc.

Parameters:

INode *node

Points to the node for the object being collapsed.

IDerivedObject *derObj

If the object associated with node above is a Modifier this points to the derived object. If it's an object then this is NULL.

int index

If the object associated with node above is a Modifier this is the index of this modifier in the DerivedObject. If it's an object then this is 0.

Default Implementation:

{}

Prototype:

virtual int NumSubObjTypes();

Remarks:

This method is available in release 4.0 and later only.

Returns the number of sub-object types supported by the object or modifier. In R4 objects or modifier must override this method and GetSubObjType() below.

Default Implementation:

{ return 0;}

Prototype:

virtual ISubObjType *GetSubObjType(int i);

Remarks:

This method is available in release 4.0 and later only.

Returns a pointer to the sub-object type for the sub-object whose index is passed.

If the parameter i passed is -1 the system requests an ISubObjType for the current SubObjectLevel that flows up the modifier stack. If the subobject selection of the modifier or base object does not affect the sub-object selection that flows up the stack NULL must be returned. See the sample code in \MAXSDK\SAMPLES\MODIFIERS\MESHSEL.CPP.

Parameters:

int i

The zero based index of the sub-object type to get. See the remarks above.

Return Value:

The sub-object type. See Class ISubObjType.

Default Implementation:

{ return NULL; }

Prototype:

virtual int GetSubObjectLevel();

Remarks:

This method is available in release 4.0 and later only.

This method returns an integer which indicates the current sub-object level of the modifier or base object.

Return Value:

A value of 0 indicates object level. A value of 1 through NumSubObjTypes() are the sub-object levels in the same order as they are returned by GetSubObjType(int i) (with an offset of 1 of course).