3ds Max C++ API Reference
Loading...
Searching...
No Matches
gfx.h File Reference
#include "maxheap.h"
#include "geom/geomlib.h"
#include "export.h"
#include "tab.h"
#include "mtl.h"
#include "BaseInterface.h"
#include "HWMesh.h"
#include "MeshFaceFlagConstants.h"
#include "GraphicsConstants.h"
#include "GraphicsTypes.h"
#include "GraphicsViewPortColorConstants.h"
#include "maxtypes.h"
#include "TabTypes.h"
#include "LightTypeEnums.h"
#include "Strip.h"
#include "GraphicsWindow.h"

Classes

class  VertexBuffer
 A vertex buffer, containing a Point3 and color. More...
 
class  LineBuffer
 A line buffer, containing a single Point3 and color. More...
 
class  GWFace
 A triangular face, which is represented as indexes into a vertex array. More...
 
class  Light
 Describes lights used in the interactive renderer. More...
 
class  Camera
 Represents the projection matrix and common properties of a perspective or orthographic camera. More...
 
struct  CIRCLE
 Represents a circular region when doing hit testing. More...
 
class  HitRegion
 Describes the properties of a region used for built-in hit testing of items in the interactive renderer. More...
 
class  GWinSetup
 

Functions

int ABS (const int x)
 Returns the absolute value of an integer.
 
int wIsFacingBack (const IPoint3 &v0, const IPoint3 &v1, const IPoint3 &v2, int flip=0)
 Given three points in a windows coordinate system (where the upper-left of the window is origin) returns TRUE if the face is facing backwards, FALSE otherwise.
 
int hIsFacingBack (const IPoint3 &v0, const IPoint3 &v1, const IPoint3 &v2, int flip=0)
 Given three points in a coordinate system where the lower-left of the window is origin returns TRUE if the face is facing backwards, FALSE otherwise.
 
FacingType wFacingType (const IPoint3 &v0, const IPoint3 &v1, const IPoint3 &v2, int flip=0)
 Returns the facing of a given triangle relative to the screen.
 
FacingType hFacingType (const IPoint3 &v0, const IPoint3 &v1, const IPoint3 &v2, int flip=0)
 Returns the facing of a given triangle relative to the screen.
 
DllExport HINSTANCE GetGraphicsLibHandle (const MCHAR *driverLibName)
 
DllExport BOOL GraphicsSystemIsAvailable (HINSTANCE drv)
 
DllExport BOOL GraphicsSystemCanConfigure (HINSTANCE drv)
 
DllExport BOOL GraphicsSystemConfigure (HWND hWnd, HINSTANCE drv)
 
DllExport void FreeGraphicsLibHandle (HINSTANCE drv)
 
DllExport GraphicsWindowcreateGW (HWND hWnd, GWinSetup &gws)
 
DllExport void getRegionRect (HitRegion *hr, RECT *rect)
 Returns a bounding rectangle that encloses the entire hit region.
 
DllExport BOOL pointInRegion (int x, int y, HitRegion *hr)
 Returns TRUE if the specified point is inside the region hr or FALSE otherwise.
 
DllExport int distToLine (int x, int y, int *p1, int *p2)
 Returns the signed distance from x, y to the line defined by p1->p2.
 
DllExport float distToSegment (int x, int y, int *p1, int *p2)
 Returns the unsigned distance from the 2D point x, y to the 2D line segment defined by p1->p2.
 
DllExport int zDepthToLine (int x, int y, int *p1, int *p2)
 Returns z depth at closest point in the line defined by p1->p2 to x,y v = the vector from p1 to p2 w = the vector from p1 to q=(x,y) t = (w dot v) / (v dot v) p1[2] + (p2[2] - p1[2]) * t.
 
DllExport int zDepthToSegment (int x, int y, int *p1, int *p2)
 Returns z depth at closest point in the segment defined by p1->p2 to x,y v = the vector from p1 to p2 w = the vector from p1 to q=(x,y) t = (w dot v) / (v dot v) t = clamp(t, 0.0, 1.0) p1[2] + (p2[2] - p1[2]) * t.
 
DllExport int lineCrossesRect (RECT *rc, int *p1, int *p2)
 Returns nonzero if the line defined by p1->p2 crosses into the RECT and 0 otherwise.
 
DllExport int segCrossesRect (RECT *rc, int *p1, int *p2)
 Returns nonzero if the line-segment defined by p1->p2 crosses into the RECT and 0 otherwise.
 
DllExport int segCrossesCircle (int cx, int cy, int r, int *p1, int *p2)
 Returns nonzero if the line-segment defined by p1->p2 crosses the circle center at (cx, cy) with a radius of r 0 otherwise.
 
DllExport BOOL insideTriangle (IPoint3 &p0, IPoint3 &p1, IPoint3 &p2, IPoint3 &q)
 Returns TRUE if the point passed is inside the specified triangle.
 
DllExport int getZfromTriangle (IPoint3 &p0, IPoint3 &p1, IPoint3 &p2, IPoint3 &q)
 Returns the z value of where the projected screen point q would intersect the triangle defined by (p0, p1, p2).
 
DllExport int getClosestPowerOf2 (int num)
 Given an integer returns another integer which is the closest power of 2.
 
Window / Crossing Mode Functions


DllExport void setAutoCross (int onOff)
 Set to a non-zero value if crossing mode is used for selections, or zero if windowing mode is used instead.
 
DllExport int getAutoCross ()
 Returns a non-zero value if crossing mode is used for selections, or zero if windowing mode is used instead.
 
DllExport void setAutoCrossDir (int dir)
 Sets the type of crossing mechanism used in crossing mode of selections.
 
DllExport int getAutoCrossDir ()
 Sets the type of crossing mechanism used in crossing mode of selections.
 

User-Defined Colors

Access to customizable colors used to draw viewport, scene and user interface elements (not elements of different color schemes available in 3ds Max).

Clients of these methods should consider registering for NOTIFY_COLOR_CHANGE notification in order to ensure that they use the current custom colors.

#define GetSelColor()   GetUIColor(COLOR_SELECTION)
 Retrieves the selection color.
 
#define GetSubSelColor()   GetUIColor(COLOR_SUBSELECTION)
 Retrieves the sub-object selection color.
 
#define GetFreezeColor()   GetUIColor(COLOR_FREEZE)
 Retrieves the freeze color.
 
DllExport Point3 GetUIColor (int which)
 Retrieves the current value of the specified custom color.
 
DllExport void SetUIColor (int which, Point3 *clr)
 Sets the current value of the specified custom color.
 
DllExport Point3 GetDefaultUIColor (int which)
 Retrieves the default value of the specified custom color.
 

Macro Definition Documentation

◆ GetSelColor

#define GetSelColor ( )    GetUIColor(COLOR_SELECTION)

Retrieves the selection color.

◆ GetSubSelColor

#define GetSubSelColor ( )    GetUIColor(COLOR_SUBSELECTION)

Retrieves the sub-object selection color.

◆ GetFreezeColor

#define GetFreezeColor ( )    GetUIColor(COLOR_FREEZE)

Retrieves the freeze color.

Function Documentation

◆ setAutoCross()

DllExport void setAutoCross ( int  onOff)

Set to a non-zero value if crossing mode is used for selections, or zero if windowing mode is used instead.

◆ getAutoCross()

DllExport int getAutoCross ( )

Returns a non-zero value if crossing mode is used for selections, or zero if windowing mode is used instead.

◆ setAutoCrossDir()

DllExport void setAutoCrossDir ( int  dir)

Sets the type of crossing mechanism used in crossing mode of selections.

Legal values are AC_DIR_RL_CROSS or AC_DIR_LR_CROSS.

◆ getAutoCrossDir()

DllExport int getAutoCrossDir ( )

Sets the type of crossing mechanism used in crossing mode of selections.

This is either AC_DIR_RL_CROSS or AC_DIR_LR_CROSS.

◆ ABS()

int ABS ( const int  x)
inline

Returns the absolute value of an integer.

229{ return (x > 0) ? x : -x; }
controller mat max min numsubs x z controller keys x z controller keys x
Definition: generics.inl:212

◆ wIsFacingBack()

int wIsFacingBack ( const IPoint3 v0,
const IPoint3 v1,
const IPoint3 v2,
int  flip = 0 
)
inline

Given three points in a windows coordinate system (where the upper-left of the window is origin) returns TRUE if the face is facing backwards, FALSE otherwise.

254{
255 int s = ( (v0[0]-v1[0])*(v2[1]-v1[1]) - (v2[0]-v1[0])*(v0[1]-v1[1]) ) < 0;
256 return flip ? !s : s;
257}

◆ hIsFacingBack()

int hIsFacingBack ( const IPoint3 v0,
const IPoint3 v1,
const IPoint3 v2,
int  flip = 0 
)
inline

Given three points in a coordinate system where the lower-left of the window is origin returns TRUE if the face is facing backwards, FALSE otherwise.

262{
263 int s = ( (v0[0]-v1[0])*(v2[1]-v1[1]) - (v2[0]-v1[0])*(v0[1]-v1[1]) );
264 return flip ? s < 0 : s > 0;
265}

◆ wFacingType()

FacingType wFacingType ( const IPoint3 v0,
const IPoint3 v1,
const IPoint3 v2,
int  flip = 0 
)
inline

Returns the facing of a given triangle relative to the screen.

Returns whether a given triangle is front-facing, side-facing, or back-facing relative to the screen. The triangle is passed as three points in screen space. This function is used for "w" format device coordinates.

Parameters
v0The 1st triangle vertex
v1The 2nd triangle vertex
v2The 3rd triangle vertex
flipIf true, flip the triangle (so backfacing would return frontfacing)
276{
277 int s = ( (v0[0]-v1[0])*(v2[1]-v1[1]) - (v2[0]-v1[0])*(v0[1]-v1[1]) );
278 return (s == 0) ? kSideFacing : ((flip ? s > 0 : s < 0) ? kBackFacing : kFrontFacing);
279}
@ kSideFacing
Definition: GraphicsTypes.h:69
@ kFrontFacing
Definition: GraphicsTypes.h:68
@ kBackFacing
Definition: GraphicsTypes.h:70

◆ hFacingType()

FacingType hFacingType ( const IPoint3 v0,
const IPoint3 v1,
const IPoint3 v2,
int  flip = 0 
)
inline

Returns the facing of a given triangle relative to the screen.

The methods wFacingType() and hFacingType() will return whether a given triangle is front-facing, side-facing, or back-facing relative to the screen. The triangle is passed as three points in screen space. This function is used for "h" format device coordinates.

Parameters
v0The 1st triangle vertex
v1The 2nd triangle vertex
v2The 3rd triangle vertex
flipIf true, flip the triangle (so backfacing would return frontfacing)
290{
291 int s = ( (v0[0]-v1[0])*(v2[1]-v1[1]) - (v2[0]-v1[0])*(v0[1]-v1[1]) );
292 return (s == 0) ? kSideFacing : ((flip ? s < 0 : s > 0) ? kBackFacing : kFrontFacing);
293}

◆ GetGraphicsLibHandle()

DllExport HINSTANCE GetGraphicsLibHandle ( const MCHAR driverLibName)

◆ GraphicsSystemIsAvailable()

DllExport BOOL GraphicsSystemIsAvailable ( HINSTANCE  drv)

◆ GraphicsSystemCanConfigure()

DllExport BOOL GraphicsSystemCanConfigure ( HINSTANCE  drv)

◆ GraphicsSystemConfigure()

DllExport BOOL GraphicsSystemConfigure ( HWND  hWnd,
HINSTANCE  drv 
)

◆ FreeGraphicsLibHandle()

DllExport void FreeGraphicsLibHandle ( HINSTANCE  drv)

◆ createGW()

DllExport GraphicsWindow * createGW ( HWND  hWnd,
GWinSetup gws 
)

This function is used internally to create a new graphics window.

◆ getRegionRect()

DllExport void getRegionRect ( HitRegion hr,
RECT *  rect 
)

Returns a bounding rectangle that encloses the entire hit region.

For example if the hit regions was a fence region, this method would return the smallest rectangle that included the entire set of fence region points.

Parameters
hrThe hit region to check
rectPoints to the returned bounding rectangle.

◆ pointInRegion()

DllExport BOOL pointInRegion ( int  x,
int  y,
HitRegion hr 
)

Returns TRUE if the specified point is inside the region hr or FALSE otherwise.

◆ distToLine()

DllExport int distToLine ( int  x,
int  y,
int p1,
int p2 
)

Returns the signed distance from x, y to the line defined by p1->p2.

◆ distToSegment()

DllExport float distToSegment ( int  x,
int  y,
int p1,
int p2 
)

Returns the unsigned distance from the 2D point x, y to the 2D line segment defined by p1->p2.

Parameters
xThe x coordinate of the 2D point.
yThe y coordinate of the 2D point.
p1The first end point of the 2D line segment.
p2The second end point of the 2D line segment. A line segment is the finite segment between two end points p1 p2, different from the infinite line used in distToLine. Notice that this routine returns unsigned distance, which means not matter on which side of the line the point is, the returned value is always non-negative.

◆ zDepthToLine()

DllExport int zDepthToLine ( int  x,
int  y,
int p1,
int p2 
)

Returns z depth at closest point in the line defined by p1->p2 to x,y v = the vector from p1 to p2 w = the vector from p1 to q=(x,y) t = (w dot v) / (v dot v) p1[2] + (p2[2] - p1[2]) * t.

◆ zDepthToSegment()

DllExport int zDepthToSegment ( int  x,
int  y,
int p1,
int p2 
)

Returns z depth at closest point in the segment defined by p1->p2 to x,y v = the vector from p1 to p2 w = the vector from p1 to q=(x,y) t = (w dot v) / (v dot v) t = clamp(t, 0.0, 1.0) p1[2] + (p2[2] - p1[2]) * t.

◆ lineCrossesRect()

DllExport int lineCrossesRect ( RECT *  rc,
int p1,
int p2 
)

Returns nonzero if the line defined by p1->p2 crosses into the RECT and 0 otherwise.

◆ segCrossesRect()

DllExport int segCrossesRect ( RECT *  rc,
int p1,
int p2 
)

Returns nonzero if the line-segment defined by p1->p2 crosses into the RECT and 0 otherwise.

◆ segCrossesCircle()

DllExport int segCrossesCircle ( int  cx,
int  cy,
int  r,
int p1,
int p2 
)

Returns nonzero if the line-segment defined by p1->p2 crosses the circle center at (cx, cy) with a radius of r 0 otherwise.

◆ insideTriangle()

DllExport BOOL insideTriangle ( IPoint3 p0,
IPoint3 p1,
IPoint3 p2,
IPoint3 q 
)

Returns TRUE if the point passed is inside the specified triangle.

Parameters
p0The first point of the triangle
p1The second point of the triangle
p2The third point of the triangle.
qThe point to check.
Returns
Returns TRUE if the point passed is inside the specified triangle; otherwise FALSE.

◆ getZfromTriangle()

DllExport int getZfromTriangle ( IPoint3 p0,
IPoint3 p1,
IPoint3 p2,
IPoint3 q 
)

Returns the z value of where the projected screen point q would intersect the triangle defined by (p0, p1, p2).

Parameters
p0The first point of the triangle
p1The second point of the triangle
p2The third point of the triangle.
qThe screen point to check.
Returns
Returns TRUE if the point passed is inside the specified triangle; otherwise FALSE.

◆ getClosestPowerOf2()

DllExport int getClosestPowerOf2 ( int  num)

Given an integer returns another integer which is the closest power of 2.

◆ GetUIColor()

DllExport Point3 GetUIColor ( int  which)

Retrieves the current value of the specified custom color.

Parameters
whichThe identifier of the custom color to retrieve. See ViewportDrawingColors
Returns
The current value of the color, as an RGB value

◆ SetUIColor()

DllExport void SetUIColor ( int  which,
Point3 clr 
)

Sets the current value of the specified custom color.

Parameters
whichThe identifier of the custom color to retrieve. See ViewportDrawingColors
clrPointer to the new color value object

◆ GetDefaultUIColor()

DllExport Point3 GetDefaultUIColor ( int  which)

Retrieves the default value of the specified custom color.

Parameters
whichThe identifier of the custom color to retrieve. See ViewportDrawingColors
Returns
The default value of the color, as an RGB value