List of Miscellaneous Utility Functions

3DS Max Plug-In SDK

List of Miscellaneous Utility Functions

See Also: Class Interface.

The following functions are not part of any class but are available as part of the API.

Function:

int CoreExecute(int cmd, ULONG arg1=0, ULONG arg2=0, ULONG arg3=0);

Remarks:

This global function is available in release 3.0 and later only.

This is a general purpose function that allows the API to be extended in the future. The 3ds max development team can assign new cmd numbers and continue to add functionality to this class without having to 'break' the API.

This is reserved for future use.

Parameters:

int cmd

The command to execute.

ULONG arg1=0

Optional argument 1 (defined uniquely for each cmd).

ULONG arg2=0

Optional argument 2.

ULONG arg3=0

Optional argument 3.

Return Value:

An integer return value (defined uniquely for each cmd).

Function:

int MaxMsgBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT type, UINT exType=0, DWORD *exRet=NULL);

Remarks:

This global function is available in release 3.0 and later only.

This function provides an extended message box functionality. This is used to easily support message dialogs with a 'Hold' button and/or a 'Don't Show Again' checkbox. Note that MB_ABORTRETRYIGNORE, MB_YESNOCANCEL, and MB_RETRYCANCEL are not supported by ths function and will be treated identically to MB_OKCANCEL.

Parameters:

HWND hWnd

The parent window handle.

LPCTSTR lpText

Address of the string for the dialog body text.

LPCTSTR lpCaption

Address of the string for the dialog title caption.

UINT type

The type is the similar to the Win32 MessageBox() API.

UINT exType=0

The 'extended' type supports the following values (which are ORed together to create this argument):

MAX_MB_HOLD

Indicates to add a "Hold" button to the dialog.

MAX_MB_DONTSHOWAGAIN

Indicates to add a "Don't show this dialog again" checkbox to the dialog.

DWORD *exRet=NULL

If non-NULL and MAX_MB_DONTSHOWAGAIN is specified above then this DWORD will have the MAX_MB_DONTSHOWAGAIN bit set if the checkbox was checked by the user.

Return Value:

The return value is zero if there is not enough memory to create the message box. If the function succeeds, the return value is similar to the Win32 MessageBox() API.

Function:

inline float Dbl2Flt(double val, BOOL *valid = NULL);

Remarks:

This global function is available in release 3.0 and later only.

This function is defined in \MAXSDK\INCLUDE\WINUTIL.H. It provides safe type casting from double to float with an indication of overflow returned in the valid parameter.

Parameters:

double val

The value to cast.

BOOL *valid = NULL

TRUE if the no overflow occurred; otherwise FALSE.

Return Value:

A float version of the double val.

Sample Code:

Depending on machine/compiler settings, the following code may throw an under/overflow exception or quietly return a junk value:

float val = (float)_tcstod(pNptr, ppEndptr);

A safer method would be:

BOOL valid;

float val = Dbl2Flt(_tcstod(pNptr, ppEndptr), &valid);

Function:

inline int Dbl2Int(double val, BOOL *valid = NULL);

Remarks:

This global function is available in release 3.0 and later only.

This function is defined in \MAXSDK\INCLUDE\WINUTIL.H. It provides safe type casting from double to int with an indication of overflow returned in the valid parameter.

Parameters:

double val

The value to cast.

BOOL *valid = NULL

TRUE if the no overflow occurred; otherwise FALSE.

Return Value:

An int version of the double val.

Function:

inline void SinCos(float angle, float *sine, float *cosine);

Remarks:

This global function is available in release 3.0 and later only.

Returns both the sine and cosine of the angle specified, as floats. This rountine uses assembly language on Intel CPUs. This is defined in \MAXSDK\INCLUDE\GFLOAT.H.

Parameters:

float angle

The angle in radians.

float *sine

Points to storage for the output sine of the angle.

float *cosine

Points to storage for the output cosine of the angle.

Function:

inline float Sin(float angle);

Remarks:

This global function is available in release 3.0 and later only.

Returns the sine of the angle specified as a float. This rountine uses assembly language on Intel CPUs. This is defined in \MAXSDK\INCLUDE\GFLOAT.H.

Parameters:

float angle

The angle in radians.

Function:

inline float Cos(float angle);

Remarks:

This global function is available in release 3.0 and later only.

Returns the cosine of the angle specified as a float. This rountine uses assembly language on Intel CPUs. This is defined in \MAXSDK\INCLUDE\GFLOAT.H.

Parameters:

float angle

The angle in radians.

Function:

inline float Sqrt(float arg);

Remarks:

This global function is available in release 3.0 and later only.

Returns the square root of the argument specified as a float. This rountine uses assembly language on Intel CPUs. This is defined in \MAXSDK\INCLUDE\GFLOAT.H.

Parameters:

float arg

The number whose square root is computed.

Function:

bool IsDebugging();

Remarks:

This global function is available in release 4.0 and later only.

Returns true if 3ds max is running under the debugger; otherwise false.

Function:

int NumberOfProcessors();

Remarks:

This global function is available in release 4.0 and later only.

Returns the number of processors in the machine 3ds max is running on.

Function:

bool IsWindows9x();

Remarks:

This global function is available in release 4.0 and later only.

Returns true if 3ds max is running on Windows 9x (95 or 98); otherwise false.

Function:

bool IsWindows98or2000();

Remarks:

This global function is available in release 4.0 and later only.

Returns true if 3ds max is running on Windows 98 or Windows 2000; otherwise false.

Function:

int GetScreenWidth();

Remarks:

This global function is available in release 4.0 and later only.

Returns the width of the screen (taking into consideration if mutliple monitors are in use).

Function:

int GetScreenHeight();

Remarks:

This global function is available in release 4.0 and later only.

Returns the height of the screen (taking into consideration if mutliple monitors are in use).