Class CreateMouseCallBack

3DS Max Plug-In SDK

Class CreateMouseCallBack

See Also: Class BaseObject (method GetCreateMouseCallBack()), Class ViewExp, Class Matrix3, Class IPoint2.

class CreateMouseCallBack

Description:

This is the callback object for handling the creation process of a plug-in object.

Methods:

Prototype:

virtual int proc(ViewExp *vpt, int msg, int point, int flags, IPoint2 m, Matrix3& mat)=0;

Remarks:

Implemented by the Plug-In.

This is the method where the developer defines the user / mouse interaction that takes place during the creation phase of an object.

Parameters:

ViewExp *vpt

The viewport the creation process is taking place in.

int msg

This message describes the type of event that occurred. See List of Mouse Callback Messages.

int point

The point number. this is 0 for the first click, 1 for the second, etc.

int flags

These flags describe the state of the mouse button and keyboard Shift/Ctrl/Alt keys. See List of Mouse Callback Flags.

IPoint2 m

The 2D screen point that the user clicked on. Methods in the viewport interface allow this point to be converted into a world space ray or a 3D view space point. A world space ray can be intersected with the active construction plane which results in a point on the active construction plane. See Class ViewExp.

Matrix3& mat

This represents the transformation of the object relative to the construction plane. Typically the plug-in would get a point on the construction plane based on the screen point that the user clicked on and set the translation component of this matrix based on that point.

Return Value:

Return one of the following value to indicate the state of the creation process:

CREATE_CONTINUE

The creation process should continue. In this case the mouse is captured.

CREATE_STOP

The creation process has terminated normally. In this case the mouse is no longer captured and input is then allowed again from any viewport.

CREATE_ABORT

The creation process has been aborted. The system will delete the created object and node.

Prototype:

virtual int override(int mode)

Remarks:

Implemented by the Plug-In.

This method is used to override the default drag mode. Most plug-in will not need to replace the default implementation of this method. What this does is change the way the messages are sent relative to the mouse clicking.

Normally the messages are sent as follows: When the user clicks down this generates a MOUSE_POINT message. Then the user drags the mouse with the button down and a series of MOUSE_MOVE messages are sent. When they let up on the mouse button a MOUSE_POINT messages is generated. Then as the mouse is moved a series of MOUSE_MOVE messages are sent. Then they click down on the mouse again, but this time a point message is not generated until the button is released. All future points are then only sent after the mouse button has been pressed and released.

Parameters:

int mode

The current drag mode. See below.

Return Value:

One of the following drag modes should be returned:

CLICK_MODE_DEFAULT

Returned to indicate the use of the system mouse mode.

CLICK_DRAG_CLICK

This is the default behavior as described above.

CLICK_MOVE_CLICK

In this mode, the first point is entered by clicking the mouse button down and then letting it up. This generates point 0. In other words, a MOUSE_POINT message is only generated after the user has pressed and released the mouse button.

CLICK_DOWN_POINT

In this mode, point messages are sent on mouse-down only.

Default Implementation:

{ return mode; }

Sample Code:

A sample program that uses the override method is \MAXSDK\SAMPLES\OBJECTS\SPLINE.CPP. It uses CLICK_DOWN_POINT.

Prototype:

virtual BOOL StartNewCreation();

Remarks:

This method is available in release 3.0 and later only.

This gets called by the CreationManager to determine if the mouse proc is really starting a new object. The mouse proc for creating always returns CREATE_STOP, which is how it keeps the mouse from being captured, and this function tells the system if it is really ready to start a new object. Thus, this is called only if the mouse proc returned CREATE_STOP to see if the object is really in a state to start a new node.

Return Value:

TRUE if the mouse proc is ready to start a new object; otherwise FALSE.

Default Implementation:

{ return TRUE; }

Prototype:

virtual BOOL TolerateOrthoMode();

Remarks:

This method is available in release 3.0 and later only.

Called by the system to determine if ortho mode makes sense for this creation. Typcially this only makes sense for splines and NURBS curves.

Return Value:

TRUE if ortho mode is okay; otherwise FALSE.

Default Implementation:

{ return FALSE; }