Classes | Functions

gfx.h File Reference

This reference page is linked to from the following overview topics: SDK Change Details, Getting and Setting User Preferences.


#include "maxheap.h"
#include "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"

Go to the source code of this file.

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 (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 GraphicsWindow createGW (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 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  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.

Define Documentation

#define GetSelColor ( )    GetUIColor(COLOR_SELECTION)

Retrieves the selection color.

Definition at line 393 of file gfx.h.

#define GetSubSelColor ( )    GetUIColor(COLOR_SUBSELECTION)

Retrieves the sub-object selection color.

Definition at line 395 of file gfx.h.

#define GetFreezeColor ( )    GetUIColor(COLOR_FREEZE)

Retrieves the freeze color.

Definition at line 397 of file gfx.h.


Function Documentation

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.

Legal values are AC_DIR_RL_CROSS or AC_DIR_LR_CROSS.

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.

int ABS ( const int  x ) [inline]

Returns the absolute value of an integer.

Definition at line 231 of file gfx.h.

{ return (x > 0) ? x : -x; }
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.

Definition at line 255 of file gfx.h.

{
    int s = ( (v0[0]-v1[0])*(v2[1]-v1[1]) - (v2[0]-v1[0])*(v0[1]-v1[1]) ) < 0;
    return flip ? !s : s;
}
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.

Definition at line 263 of file gfx.h.

{
    int s = ( (v0[0]-v1[0])*(v2[1]-v1[1]) - (v2[0]-v1[0])*(v0[1]-v1[1]) );
    return flip ? s < 0 : s > 0;
}
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:
v0 The 1st triangle vertex
v1 The 2nd triangle vertex
v2 The 3rd triangle vertex
flip If true, flip the triangle (so backfacing would return frontfacing)

Definition at line 277 of file gfx.h.

{
    int s = ( (v0[0]-v1[0])*(v2[1]-v1[1]) - (v2[0]-v1[0])*(v0[1]-v1[1]) );
    return (s == 0) ? kSideFacing : ((flip ? s > 0 : s < 0) ? kBackFacing : kFrontFacing);
}
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:
v0 The 1st triangle vertex
v1 The 2nd triangle vertex
v2 The 3rd triangle vertex
flip If true, flip the triangle (so backfacing would return frontfacing)

Definition at line 291 of file gfx.h.

{
    int s = ( (v0[0]-v1[0])*(v2[1]-v1[1]) - (v2[0]-v1[0])*(v0[1]-v1[1]) );
    return (s == 0) ? kSideFacing : ((flip ? s < 0 : s > 0) ? kBackFacing : kFrontFacing);
}
DllExport HINSTANCE GetGraphicsLibHandle ( 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 GraphicsWindow* createGW ( HWND  hWnd,
GWinSetup gws 
)

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

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:
hr The hit region to check
rect Points to the returned bounding rectangle.
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 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 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.

Parameters:
p0 The first point of the triangle
p1 The second point of the triangle
p2 The third point of the triangle.
q The point to check.
Returns:
Returns TRUE if the point passed is inside the specified triangle; otherwise FALSE.
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:
p0 The first point of the triangle
p1 The second point of the triangle
p2 The third point of the triangle.
q The screen point to check.
Returns:
Returns TRUE if the point passed is inside the specified triangle; otherwise FALSE.
DllExport int getClosestPowerOf2 ( int  num )

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

DllExport Point3 GetUIColor ( int  which )

Retrieves the current value of the specified custom color.

Parameters:
which The identifier of the custom color to retrieve. See Viewport Drawing Color Indices
Returns:
The current value of the color, as an RGB value
DllExport void SetUIColor ( int  which,
Point3 clr 
)

Sets the current value of the specified custom color.

Parameters:
which The identifier of the custom color to retrieve. See Viewport Drawing Color Indices
clr Pointer to the new color value object
DllExport Point3 GetDefaultUIColor ( int  which )

Retrieves the default value of the specified custom color.

Parameters:
which The identifier of the custom color to retrieve. See Viewport Drawing Color Indices
Returns:
The default value of the color, as an RGB value