Public Member Functions

SphereGizmoObject Class Reference

Search for all occurrences

Detailed Description

See also:
Class GizmoObject, Class CylGizmoObject, Class BoxGizmoObject.

Description:
This class is available in release 2.0 and later only.

This is a class developer can use to provide a spherical gizmo helper object for their plug-ins. It provides implementations of all the required methods. The following #defines are used to access the parameters from the pblock pointer of the base class GizmoObject.

#define PB_GIZMO_RADIUS 0

#define PB_GIZMO_HEMI 1

#define PB_GIZMO_SEED 2

The ClassID for this class is defined as: SPHEREGIZMO_CLASSID

#include <gizmoimp.h>

Inheritance diagram for SphereGizmoObject:
Inheritance graph
[legend]

List of all members.

Public Member Functions

CoreExport  SphereGizmoObject ()
CoreExport  ~SphereGizmoObject ()
CoreExport CreateMouseCallBack GetCreateMouseCallBack ()
  This method allows the system to retrieve a callback object used in creating an object in the 3D viewports.
CoreExport void  BeginEditParams (IObjParam *ip, ULONG flags, Animatable *prev)
CoreExport void  EndEditParams (IObjParam *ip, ULONG flags, Animatable *next)
CoreExport MCHAR *  GetObjectName ()
CoreExport void  InitNodeName (MSTR &s)
  Implemented by the System.
CoreExport void  GetClassName (MSTR &s)
  Retrieves the name of the plugin class.
CoreExport void  DeleteThis ()
  Deletes an instance of this class.
Class_ID  ClassID ()
  Retrieves a constant that uniquely identifies the plugin class.
CoreExport RefTargetHandle  Clone (RemapDir &remap)
  This method is used by 3ds Max to clone an object.
Interval  ObjectValidity (TimeValue t)
CoreExport void  InvalidateUI ()
CoreExport ParamDimension GetParameterDim (int pbIndex)
CoreExport MSTR  GetParameterName (int pbIndex)
CoreExport void  DrawGizmo (TimeValue t, GraphicsWindow *gw)
CoreExport void  GetBoundBox (Matrix3 &mat, TimeValue t, Box3 &box)

Constructor & Destructor Documentation

CoreExport SphereGizmoObject ( )
CoreExport ~SphereGizmoObject ( )

Member Function Documentation

CoreExport CreateMouseCallBack* GetCreateMouseCallBack ( ) [virtual]

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.

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

Implements BaseObject.

CoreExport void BeginEditParams ( IObjParam ip,
ULONG  flags,
Animatable prev 
) [virtual]
Remarks:
This method is called by the system when the user may edit the item's (object, modifier, controller, etc.) parameters.
Parameters:
ip Interface pointer. The developer can use it to call methods such as AddRollupPage(). Note that this pointer is only valid between BeginEditParams() and EndEditParams(). It should not be used outside this interval.
flags Describe which branch of the command panel or dialog the item is being edited in. The following are possible values:

BEGIN_EDIT_CREATE
Indicates an item is being edited in the create branch.

BEGIN_EDIT_MOTION
Indicates a controller is being edited in the motion branch.

BEGIN_EDIT_HIERARCHY
Indicates a controller is being edited in the Pivot subtask of the hierarchy branch.

BEGIN_EDIT_IK
Indicates a controller is being edited in the IK subtask of the hierarchy branch.

BEGIN_EDIT_LINKINFO
Indicates a controller is being edited in the Link Info subtask of the hierarchy branch.

prev Pointer to an Animatable object. 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 previous item that was being edited, and if it is the same as this item, to not replace the entire UI in the command panel, but simply update the values displayed in the UI fields. This prevents the UI from 'flickering' when the current item begins its edit. For example, if you are in the motion branch and are looking at an item's PRS controller values, and then select another item that is displayed with a PRS controller, the UI will not change - only the values displayed in the fields will change. If however you selected a target camera that has a lookat controller (not a PRS controller) the UI will change because a different set of parameters need to be displayed. Note that for items that are edited in the modifier branch this field can be ignored.

Reimplemented from GizmoObject.

CoreExport void EndEditParams ( IObjParam ip,
ULONG  flags,
Animatable next 
) [virtual]
Remarks:
This method is called when the user is finished editing an objects 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:
ip An interface pointer. The developer may use the interface pointer to call methods such as DeleteRollupPage().

flags The following flag may be set:

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

next Animatable pointer. Can be used in the motion and hierarchy branches of the command panel. It 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.

Reimplemented from GizmoObject.

CoreExport MCHAR* GetObjectName ( ) [virtual]
Returns:
the name that will appear in the history browser (modifier stack).

Reimplemented from BaseObject.

CoreExport void InitNodeName ( MSTR s ) [virtual]

Implemented by the System.

Sets the default node name to "Helper".

Reimplemented from GizmoObject.

CoreExport void GetClassName ( MSTR s ) [virtual]

Retrieves the name of the plugin class.

This name is usually used internally for debugging purposes. For Material plug-ins this method is used to put up the material "type" name in the Material Editor.

Parameters:
s Reference to a string filled in with the name of the plugin class

Reimplemented from ReferenceTarget.

CoreExport void DeleteThis ( ) [virtual]

Deletes an instance of this class.

3ds Max calls this method when it needs to delete a plugin object (an instance of a class derived from Animatable). Similarly, plugins that need to delete instances of an Animatable or a class directly derived from it via an Animatable pointer, should call this method instead of calling directly operator delete. Following these rules will ensure that the same memory manager is used to allocate and deallocate the object. The default implementation of this method deletes the object. Plugin instances that never need to be deleted from the heap can overwrite this method to do nothing.

Note:
See the method ClassDesc::Create() for details on how Max allocates plugin objects.
See ReferenceMaker::DeleteMe() and ReferenceTarget::MaybeAutoDelete() for information on how plugin instances are deleted by the system.
Remarks:
See Memory Allocation.

See also:
Plugin DLL Functions, Class ClassDesc.

Reimplemented from Animatable.

Class_ID ClassID ( ) [inline, virtual]

Retrieves a constant that uniquely identifies the plugin class.

This method must return the unique ID for the plugin class. If two ClassIDs conflict, the system will only load the first conflicting one it finds. A program (gencid.exe) is provided to generate unique class id values.

Returns:
A class id that uniquely identifies a plugin class
See also:
Class ClassID, List of Class IDs.

Reimplemented from Animatable.

{return SPHEREGIZMO_CLASSID;}
CoreExport RefTargetHandle Clone ( RemapDir remap ) [virtual]

This method is used by 3ds Max to clone an object.

See also:
CloneRefHierarchy(), class RemapDir This method is called by 3ds Max to have the plugin clone itself. The plug-in's implementation of this method should copy both the data structure and all the data residing in the data structure of this reference target. The plugin should clone all its references as well. Also, the plug-in's implementation of this method must call BaseClone(). In order for classes derived from this class to clone cleanly, the Clone method should just create the new instance, and then call an implementation of BaseClone that clones the references and copies any other necessary data. For example:
            class MyDerivedPlugin
                : public MyBasePlugin
            {
                const int MY_REFERENCE = 1;

                ReferenceTarget* Clone(RemapDir& remap)
                {
                    ReferenceTarget* result = new MyDerivedPlugin();
                    BaseClone(this, result, remap);
                    return result;
                }

                void BaseClone(ReferenceTarget* from, ReferenceTarget* to, RemapDir& remap)
                {
                    if (!to || !from || from == to)
                        return;    
                    MyBasePlugin::BaseClone(from, to, remap);
                    to->ReplaceReference(MY_REFERENCE, remap->CloneRef(from->GetReference(MY_REFERENCE)));
                }
            };

This method should not be directly called by plug-ins. Instead, either RemapDir::CloneRef() or CloneRefHierachy() should be used to perform cloning. These methods ensure that the mapping from the original object to the clone is added to the RemapDir used for cloning, which may be used during backpatch operations

Note:
See the remarks in method BaseClone() below.
Parameters:
remap - A RemapDir instance used for remapping references during a Clone.
Returns:
A pointer to the cloned item.

Reimplemented from ReferenceTarget.

Interval ObjectValidity ( TimeValue  t ) [virtual]
Remarks:
Returns the validity interval of the gizmo object around the specified time.
Parameters:
TimeValue t

Specifies the time at which the gizmo validity is returned.
Default Implementation:
{return FOREVER;}

Reimplemented from GizmoObject.

CoreExport void InvalidateUI ( ) [virtual]
Remarks:
Invalidates the user interface for the gizmo so it will get redrawn on the next screen update.
Default Implementation:
{}
Sample Code:
This is the code from the Sphere GizmoObject implementation of this method. Note that it simply calls Invalidate() on the parameter map.
        void SphereGizmoObject::InvalidateUI() {
            if (pmapParam) pmapParam->Invalidate();
        }

Reimplemented from GizmoObject.

CoreExport ParamDimension* GetParameterDim ( int  pbIndex ) [virtual]
Remarks:
Returns the dimension of the parameter whose parameter block index is passed.
Parameters:
int pbIndex

Specifies which parameter name to return.
Default Implementation:
{return defaultDim;}
Sample Code:
        ParamDimension *SphereGizmoObject::GetParameterDim(int pbIndex) {
            switch (pbIndex) {
                case PB_GIZMO_RADIUS: return stdWorldDim;
                default: return defaultDim;
            }
        }

Reimplemented from GizmoObject.

CoreExport MSTR GetParameterName ( int  pbIndex ) [virtual]
Remarks:
Returns the name of the parameter whose parameter block index is passed.
Parameters:
int pbIndex

Specifies which parameter name to return.
Default Implementation:
{return MSTR(_M("Parameter"));}

Reimplemented from GizmoObject.

CoreExport void DrawGizmo ( TimeValue  t,
GraphicsWindow gw 
) [virtual]
Remarks:
This method is called to draw the gizmo at the specified time into the specified viewport.
Parameters:
TimeValue t

The time to draw the gizmo.

GraphicsWindow *gw

The GraphicsWindow associated with the viewport in which to draw the gizmo.
Default Implementation:
{}

Reimplemented from GizmoObject.

CoreExport void GetBoundBox ( Matrix3 mat,
TimeValue  t,
Box3 box 
) [virtual]
Remarks:
Returns the bounding box for the gizmo, as transformed by the matrix passed, at the time passed.
Parameters:
Matrix3 &mat

The points of the gizmo object should be transformed by this matrix before the bounding box is computed from them.

TimeValue t

The time to compute the bounding box.

Box3 &box

The result is stored here.
Default Implementation:
{}
Sample Code:
        void SphereGizmoObject::GetBoundBox(Matrix3 &mat, TimeValue t, Box3 &box) {
            float radius;
            int hemi;
            pblock->GetValue(PB_GIZMO_RADIUS,t,radius,FOREVER);
            pblock->GetValue(PB_GIZMO_HEMI,t,hemi,FOREVER);
            BoxLineProc proc(&mat);
            DrawSphere(proc,radius,hemi);
            box += proc.Box();
        }

Reimplemented from GizmoObject.


SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject
SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject SphereGizmoObject