class M3dView

Jump to documentation

A 3-D view (OpenMayaUI) (OpenMayaUI.py)

public members:

enum DisplayStyle
kBoundingBox
bounding box display
kFlatShaded
flat shaded display
kGouraudShaded
gouraud shaded display
kWireFrame
wire frame display
kPoints
points only display
enum DisplayStatus
kActive
object is active (selected)
kLive
object is live (construction surface)
kDormant
object is domant
kInvisible
object is invisible (not drawn)
kHilite
object is hilited (has selectable components)
kTemplate
object is templated (Not renderable)
kActiveTemplate
object is active and templated
kActiveComponent
object has active components
kLead
Last selected object
kIntermediateObject
Construction object (not drawn)
kActiveAffected
Affected by active object(s)
kNoStatus
object does not have a valid display status
enum ColorTable
kActiveColors
colors for active objects
kDormantColors
colors for dormant objects
kTemplateColor
colors for templated objects
kBackgroundColor
colors for background color
enum TextPosition
kLeft
draw text to the left of the point
kCenter
draw text centered around the point
kRight
draw text to the right of the point
enum DisplayObjects
kDisplayEverything
show everything
kDisplayNurbsCurves
show nurbs curves
kDisplayNurbsSurfaces
show nurbs surfaces
kDisplayMeshes
show meshes
kDisplayPlanes
show planes
kDisplayLights
show lights
kDisplayCameras
show camera
kDisplayJoints
show joints
kDisplayIkHandles
show IK handles
kDisplayDeformers
show deformers
kDisplayDynamics
show dynamics
kDisplayLocators
show locators
kDisplayDimensions
show dimensions
kDisplaySelectHandles
show selection handles
kDisplayPivots
show pivots
kDisplayTextures
show textures
kDisplayGrid
show the grid
kDisplayCVs
show NURBS CVs
kDisplayHulls
show NURBS hulls
kDisplayStrokes
show strokes
kDisplaySubdivSurfaces
show subdivision surfaces
enum LightingMode
kLightAll
All lights ON mode
kLightSelected
Selected lights ON mode
kLightActive
Active lights ON mode
kLightDefault
Default light ON mode
enum RendererName
kDefaultQualityRenderer
Equivalent to when the renderer name is "base_OpenGL_Renderer" when queried from the "modelEditor" command
kHighQualityRenderer
Equivalent to when the renderer name is "hwRender_OpenGL_Renderer" when queried from the "modelEditor" command
kExternalRenderer
An externally defined renderer name has been set.
enum DepthBufferFormat
kDepth_8
kDepth_Float
M3dView ()
virtual ~M3dView ()
static M3dView active3dView ( MStatus * ReturnStatus = NULL )
static unsigned int numberOf3dViews ()
static MStatus get3dView ( const unsigned int index, M3dView & view )
AGLContext display ( MStatus * ReturnStatus = NULL )
Mac OS X
Display * display ( MStatus * ReturnStatus = NULL )
Linux
GLXContext glxContext ( MStatus * ReturnStatus = NULL )
Linux
HGLRC display ( MStatus * ReturnStatus = NULL )
Windows
HDC deviceContext ( MStatus * ReturnStatus = NULL )
Windows
static MWindow applicationShell ( MStatus * ReturnStatus = NULL )
M3dWindow window ( MStatus * ReturnStatus = NULL )
int portWidth ( MStatus * ReturnStatus = NULL )
int portHeight ( MStatus * ReturnStatus = NULL )
MStatus pushViewport (unsigned int x, unsigned int y, unsigned int width, unsigned int height)
MStatus popViewport ()
MStatus viewport (unsigned int &x, unsigned int &y, unsigned int &width, unsigned int &height) const
MStatus beginGL ()
MStatus endGL ()
void beginSelect (GLuint *buffer = NULL, GLsizei size = 0)
GLint endSelect ()
bool selectMode () const
bool textureMode () const
void loadName (GLuint name)
void pushName (GLuint name)
void popName ()
void initNames ()
MStatus beginOverlayDrawing ()
MStatus endOverlayDrawing ()
MStatus clearOverlayPlane ()
MStatus setDrawColor ( unsigned int index, ColorTable table = kActiveColors )
MStatus setDrawColor ( const MColor & color )
bool isColorIndexMode ( MStatus * ReturnStatus = NULL )
unsigned int numDormantColors ( MStatus * ReturnStatus = NULL )
unsigned int numActiveColors ( MStatus * ReturnStatus = NULL )
unsigned int numUserDefinedColors ( MStatus * ReturnStatus = NULL )
MStatus setUserDefinedColor ( unsigned int index, const MColor & color )
unsigned int userDefinedColorIndex ( unsigned int index, MStatus * ReturnStatus = NULL )
MColor templateColor ( MStatus * ReturnStatus = NULL )
MColor backgroundColor ( MStatus * ReturnStatus = NULL )
MColor colorAtIndex ( unsigned int index, ColorTable table = kActiveColors , MStatus * ReturnStatus = NULL )
MStatus getColorIndexAndTable ( unsigned int glindex, unsigned int &index, ColorTable &table ) const
MStatus drawText ( const MString & text, const MPoint position, TextPosition textPosition = kLeft )
MStatus getCamera ( MDagPath & camera )
MStatus setCamera ( MDagPath & camera )
MStatus refresh ( bool all = false, bool force = false )
MStatus refresh ( bool all, bool force, bool offscreen )
MStatus refresh ( MPxGlBuffer &buffer )
MStatus refresh ( MPxGlBuffer &buffer, bool offscreen )
MStatus refresh ( MPxGlBuffer &buffer, bool offscreen, const MMatrix & projectionMatrix )
MStatus getLightCount ( unsigned int &count, bool visible = TRUE )
MStatus getLightingMode ( LightingMode &mode )
MStatus getLightPath ( unsigned int lightNumber, MDagPath &light )
MStatus isLightVisible ( unsigned int lightNumber, bool &visible )
MStatus getLightIndex ( unsigned int lightNumber, unsigned int &lightIndex )
MStatus viewToWorld ( short x_pos, short y_pos, MPoint & worldPt, MVector & worldVector ) const
MStatus viewToWorld ( short x_pos, short y_pos, MPoint & nearClipPt, MPoint & farClipPt ) const
MStatus viewToObjectSpace ( short x_pos, short y_pos, const MMatrix & localMatrixInverse, MPoint & oPt, MVector & oVector ) const
bool worldToView ( const MPoint & worldPt, short& x_pos, short& y_pos, MStatus * ReturnStatus = NULL ) const
MStatus projectionMatrix ( MMatrix & projectionMatrix ) const
MStatus modelViewMatrix ( MMatrix & modelViewMatrix ) const
MString viewSelectedPrefix ( MStatus *ReturnStatus) const
MStatus setViewSelectedPrefix ( const MString &prefix)
bool showViewSelectedChildren ( MStatus *ReturnStatus) const
MStatus setShowViewSelectedChildren (bool)
static MStatus getM3dViewFromModelPanel (const MString &modelPaneName, M3dView &view)
static MStatus getM3dViewFromModelEditor (const MString &modelPaneName, M3dView &view)
DisplayStyle displayStyle ( MStatus * ReturnStatus = NULL ) const
bool isShadeActiveOnly ( MStatus * ReturnStatus = NULL ) const
MStatus setDisplayStyle ( DisplayStyle style, bool activeOnly = false)
RendererName getRendererName ( MStatus *ReturnStatus ) const
MString rendererString ( MStatus * ReturnStatus = NULL ) const
bool wireframeOnlyInShadedMode ( MStatus *ReturnStatus ) const
MStatus readColorBuffer ( MImage &image, bool readRGBA = false )
MStatus writeColorBuffer ( const MImage &image, signed short x = 0, signed short y = 0) const
MStatus readDepthMap (unsigned short x, unsigned short y, unsigned int width, unsigned int height, unsigned char* bufferPtr, DepthBufferFormat depthMapPrecision)
MStatus readBufferTo2dTexture (unsigned short x, unsigned short y, unsigned int width, unsigned int height)
MStatus getRendererString ( MString &stringName ) const
NO SCRIPT SUPPORT

Documentation

3-D view class.

Description

M3dView provides methods for working with 3D model views. 3D views are based on OpenGL drawing areas.

Maya can operate in two different color modes, RGBA and color index. Color index mode is used to increase performance when shading is not required. Drawing in color index mode is more complicated, but this class provides methods to simplify color selection.

Maya has four color tables that can be used in RGBA, and that must be used in color index mode. These four color tables represent four sets of bit planes that are independent of each other. So, for example, it is possible to clear all active objects from the display and redraw them without redrawing the dormant and templated objects. The active and dormant color tables contain the same colors, but use different bitplanes.

The extra performance of color index mode comes at the cost of a limited number of colors. If this restriction causes difficulty, then it is possible for the user to force all displays into RGBA mode where any color may be used.

When an object is affected by another in the scene, it is drawn in a magenta colour by default. This is denoted in the DisplayStatus enum by kActiveAffected. These objects are drawn in the active planes even though they are dormant for performance reasons.

Functions

M3dView:: M3dView ()

M3dView:: ~M3dView ()

M3dView M3dView:: active3dView ( MStatus * ReturnStatus )

Description

Returns the active view in the form of a class (M3dView) that can operate on it.

Arguments

  • ReturnStatus

Return Value

  • Active view class.

Status Codes

  • MS::kSuccess The 3d view was successfully returned
  • MS::kFailure Error getting the active 3d view

unsigned int M3dView:: numberOf3dViews ()

Description

Returns the number of 3D views currently in existance.

Return Value

  • number of 3D views.

MStatus M3dView:: get3dView (const unsigned int index, M3dView & view )

Description

Returns the 3D view at the given index.

Arguments

  • index index of the view to get
  • view storage for the returned view

Return Value

  • return status

Status Codes

  • MS::kSuccess operation successful
  • MS::kFailure Error getting the view
  • MS::kInvalidParameter index is out of range

Display * M3dView:: display ( MStatus * ReturnStatus )

Description

Returns the X display for this view.

The X display is neccessary for using openGL.

Arguments

  • ReturnStatus Status Code

Return Value

  • The X display

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

HGLRC M3dView:: display ( MStatus * ReturnStatus )

Description

Returns the display for this view.

The display is neccessary for using openGL.

Arguments

  • ReturnStatus Status Code

Return Value

  • The X display

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

HDC M3dView:: deviceContext ( MStatus * ReturnStatus )

Description

Returns the Windows device context for this view

Arguments

  • ReturnStatus Status Code

Return Value

  • The device context

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

AGLContext M3dView:: display ( MStatus * ReturnStatus )

Description

Returns the display for this view.

The display is neccessary for using openGL.

Arguments

  • ReturnStatus Status Code

Return Value

  • The X display

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

GLXContext M3dView:: glxContext ( MStatus * ReturnStatus )

Description

Returns the GLXContext for this view.

This context is neccessary for using the offscreen rendering API to share textures and display lists with Maya.

Arguments

  • ReturnStatus Status Code

Return Value

  • The GLXContext

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MWindow M3dView:: applicationShell ( MStatus * ReturnStatus )

Description

Returns the Window handle for Maya. On Unix, this is an X Widget on Windows, this is an HWND on Macintosh this is a WindowRef.

This is necessary if you wish to open your own windows on top of Maya.

Arguments

  • ReturnStatus Status Code

Return Value

  • The window handle

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

M3dWindow M3dView:: window ( MStatus * ReturnStatus )

Description

Returns the X window for this view.

The X window is neccessary for using openGL.

Arguments

  • ReturnStatus Status Code

Return Value

  • The X window

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

int M3dView:: portWidth ( MStatus * ReturnStatus )

Description

Returns the width of the current viewport.

Arguments

  • ReturnStatus Status Code

Return Value

  • The width of this viewport

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

int M3dView:: portHeight ( MStatus * ReturnStatus )

Description

Returns the height of the current viewport.

Arguments

  • ReturnStatus Status Code

Return Value

  • The height of this viewport

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: pushViewport (unsigned int x, unsigned int y, unsigned int width, unsigned int height)

Description

Set the current viewport dimensions. Will keep track of the last viewport dimensions on a stack. When finished with this viewport, the current dimensions should be removed from the top of stack using M3dView::popViewport().

Arguments

  • x Lower left corner of viewport (x coordinate).
  • y Lower left corner of viewport (y coordinate).
  • width Width of the viewport.
  • height Height of the viewport.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: popViewport ()

Description

Pop the current viewport off of the viewport stack.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: viewport (unsigned int &x, unsigned int &y, unsigned int &width, unsigned int &height) const

Description

Get the current viewport dimensions.

Arguments

  • x Lower left corner of viewport (x coordinate).
  • y Lower left corner of viewport (y coordinate).
  • width Width of the viewport.
  • height Height of the viewport.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: beginGL ()

Description

Setup port for native OpenGL drawing calls.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: endGL ()

Description

End OpenGL drawing.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

void M3dView:: beginSelect (GLuint *buffer, GLsizei size )

Description

Start selecting. The buffer passed is used to record selection hits. A selection hit consists of the following 4 items:

  • Number of names on selection stack when hit occurred.
  • Min Z window-coordinate of all vertices that intersected view volume since last recorded hit. The value (which lies in the range [0..1] is multiplied by 2^32 - 1 and rounded to the nearest unsigned integer.
  • Max Z window-coordinate. (computed as above)
  • Contents of name stack with bottommost element first. When multiple names are pushed on the stack, several GLuint values will be stored.

Arguments

  • buffer OpenGl pick buffer
  • size Buffer size (number of GLint)

Return Value

  • None

GLint M3dView:: endSelect ()

Description

Finish a selection sequence. Result is stored in the buffer passed in the beginSelect call.

Return Value

  • None

bool M3dView:: selectMode () const

Description

Tells if this M3dView is in selection mode.

Return Value

  • boolean true between beginSelect and endSelect calls.

bool M3dView:: textureMode () const

Description

Tells if this M3dView is in texture mode.

Return Value

  • boolean true if this modelling view is in texture mode.

void M3dView:: loadName (GLuint name)

Description

Replace the top of the name stack with the given name. Valid only when beginSelect() has been called.

Arguments

  • name Name to be loaded onto the top of the stack.

Return Value

  • None

void M3dView:: pushName (GLuint name)

Description

Push a new name on the name stack. Valid only when beginSelect() has been called.

Arguments

  • name Name to be loaded onto the top of the stack.

Return Value

  • None

void M3dView:: popName ()

Description

Removes the top of the name stack. Valid only when beginSelect() has been called.

Return Value

  • None

void M3dView:: initNames ()

Description

Reset the name stack. Valid only when beginSelect() has been called.

Return Value

  • None

MStatus M3dView:: beginOverlayDrawing ()

Description

Setup the OpenGL context for drawing on the overlay plane.

The overlay plane is commonly used for drawing guidelines for tools.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: endOverlayDrawing ()

Description

Set the OpenGL context to for normal screen drawing.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: clearOverlayPlane ()

Description

Clear the overlay plane.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: setDrawColor ( unsigned int index, ColorTable table )

Description

Set the color to draw in. The index argument is an index into the application's color tables. Valid values range between zero and the size of the table minus one. The size of the active and dormant color tables can be found using methods of this class. The background and template color tables are both of size one.

These indices do not directly correspond to those of the underlying OpenGL color index mode. Using the glIndex call directly is not recommended and may cause unpredictable results. This method should be used instead.

Note that this method will work in either RGBA mode or color index mode.

Arguments

  • index index of the color to draw in
  • table color table to index into

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kInvalidParameter Index is out of range
  • MS::kFailure Object error

MStatus M3dView:: setDrawColor ( const MColor & color )

Description

Set the color to draw in. This method should only be used in RGBA mode. It is a convenient replacement for glColor.

Arguments

  • color color to draw in

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kInvalidParameter Index is out of range
  • MS::kFailure Object error

bool M3dView:: isColorIndexMode ( MStatus * ReturnStatus )

Description

Returns true if this view is currently in the OpenGL color index mode. A false return means that it is in RGBA mode.

Arguments

  • ReturnStatus Status code

Return Value

  • boolean indicating if color index mode is in use

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

unsigned int M3dView:: numDormantColors ( MStatus * ReturnStatus )

Description

Returns the number of dormant object colors in the internal application color table.

Arguments

  • ReturnStatus Status code

Return Value

  • the number of dormant colors

Status Codes

  • MS::kSuccess Method was successful

unsigned int M3dView:: numActiveColors ( MStatus * ReturnStatus )

Description

Returns the number of active object colors in the internal application color table.

Arguments

  • ReturnStatus Status code

Return Value

  • the number of active colors

Status Codes

  • MS::kSuccess Method was successful

unsigned int M3dView:: numUserDefinedColors ( MStatus * ReturnStatus )

Description

Returns the number of user defined colors in the internal application color table. These colors may be changed by the user and assigned to specific objects. See the methods of MFnDagNode for information on assigning user defined colors to individual objects.

The user defined colors are not a color table of their own. They exist in the active and dormant color tables.

Arguments

  • ReturnStatus Status code

Return Value

  • the number of user defined colors

Status Codes

  • MS::kSuccess Method was successful

MStatus M3dView:: setUserDefinedColor ( unsigned int index, const MColor & color )

Description

Sets the user defined color at the given index. Valid indices range between zero and the number of user defined colors.

Arguments

  • index index into the user defined color
  • color color to set to

Return Value

  • an index into the application's color table

Status Codes

  • MS::kSuccess Method was successful
  • MS::kInvalidParameter Index is out of range

unsigned int M3dView:: userDefinedColorIndex ( unsigned int index, MStatus * ReturnStatus )

Description

Returns the index for the given user-defined color. Valid values for the index argument range between zero and the number of user-defined colors minus one.

The index returned gives the location of the specified color inside the active and dormant color tables (the index is the same in both tables).

Arguments

  • index Index into user-defined colors
  • ReturnStatus Status code

Return Value

  • index of user-defined color into the active and dormant tables

Status Codes

  • MS::kSuccess Method was successful

MColor M3dView:: templateColor ( MStatus * ReturnStatus )

Description

Returns the RGB values of the template color.

Arguments

  • ReturnStatus Status code

Return Value

  • the template color

Status Codes

  • MS::kSuccess Method was successful

MColor M3dView:: backgroundColor ( MStatus * ReturnStatus )

Description

Returns the RGB values of the active template color.

Arguments

  • ReturnStatus Status code

Return Value

  • the template color

Status Codes

  • MS::kSuccess Method was successful

MColor M3dView:: colorAtIndex ( unsigned int index, ColorTable table, MStatus * ReturnStatus )

Description

Returns the RGB values of the color at the given index in the application's color table.

Arguments

  • index Index of the color to retrieve
  • table Table to index into
  • ReturnStatus Status code

Return Value

  • the color

Status Codes

  • MS::kSuccess Method was successful
  • MS::kInvalidParameter Index is out of range

MStatus M3dView:: getColorIndexAndTable ( unsigned int glindex, unsigned int &index, ColorTable &table ) const

Description

Returns the color table and index representing the given OpenGL color-index value. This method is useful when converting color indices obtained from glReadPixels(GL_COLOR_INDEX) to Maya color-index values suitable for use with the colorAtIndex and setDrawColor methods.

Arguments

  • glindex Value of the OpenGL color-index to retrieve
  • index Returned ColorTable index
  • table Returned ColorTable

Return Value

  • StatusCode

Status Codes

  • MS::kSuccess Method was successful
  • MS::kInvalidParameter Index is out of range

MStatus M3dView:: drawText ( const MString & text, const MPoint position, M3dView::TextPosition textPosition )

Description

Draws the given text at the given spot in the default font. This method is provided as a convienient way to draw OpenGL text.

Arguments

  • text Text to draw
  • position Position in space to draw at
  • textPosition Text position relative to the point

Return Value

  • the color

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: getCamera ( MDagPath & camera )

Description

Get the camera for this view.

Arguments

  • camera Dag path for the camera (allocated by caller)

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: setCamera ( MDagPath & camera )

Description

Set the camera for this view.

Arguments

  • camera Dag path of the camera for this view

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: refresh ( bool all, bool force )

Description

Refresh the this view. If all is set to true then all of the 3d-view will be refreshed.

If force is set to true, then the views will be refreshed even if they do not require it. This option should be used with extreme care because extra refreshes will greatly degrade application performance. In almost all cases it is better to use the default behavior where the view is only refreshed if it is required.

Arguments

  • all If true then refresh all views, otherwise refresh this view.
  • force If true then force views to refresh even if they do not require it.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: refresh ( bool all, bool force, bool offscreen )

Description

Refresh the this view. If all is set to true then all of the 3d-view will be refreshed.

If force is set to true, then the views will be refreshed even if they do not require it. This option should be used with extreme care because extra refreshes will greatly degrade application performance. In almost all cases it is better to use the default behavior where the view is only refreshed if it is required.

Arguments

  • all If true then refresh all views, otherwise refresh this view.
  • force If true then force views to refresh even if they do not require it.
  • offscreen Should the buffer be redrawn if it's offscreen?

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: refresh ( MPxGlBuffer &buffer )

Description

Refresh the this view into the GL buffer buffer.

This refresh function always forces an update and always only draws the this view. The buffer argument should refer to a buffer that has been configured with the correct depth, color, z-buffer, etc. This configuration normally occurs in the constructor of the MPxGlBuffer and the behavior is undefined. If a buffer is configured for one view configuration and then is used for a different configuration. This may occur when Maya switches from wireframe to shaded mode since it also changes from color index to RGB mode.

If the MPxGlBuffer is double buffered, drawing always is done to the back buffer and swapping is left to the user.

Arguments

  • buffer The MPxGlBuffer in which to draw the view.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: refresh ( MPxGlBuffer &buffer, bool offscreen )

Description

Refresh the this view into the GL buffer buffer.

This refresh function always forces an update and always only draws the this view. The buffer argument should refer to a buffer that has been configured with the correct depth, color, z-buffer, etc. This configuration normally occurs in the constructor of the MPxGlBuffer and the behavior is undefined. If a buffer is configured for one view configuration and then is used for a different configuration. This may occur when Maya switches from wireframe to shaded mode since it also changes from color index to RGB mode.

Arguments

  • buffer The MPxGlBuffer in which to draw the view.
  • offscreen Should the buffer be redrawn if it's offscreen?

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: refresh ( MPxGlBuffer &buffer, bool offscreen, const MMatrix & projMatrix )

Description

Refresh the this view into the GL buffer buffer.

This refresh function always forces an update and always only draws the this view. The buffer argument should refer to a buffer that has been configured with the correct depth, color, z-buffer, etc. This configuration normally occurs in the constructor of the MPxGlBuffer and the behavior is undefined. If a buffer is configured for one view configuration and then is used for a different configuration. This may occur when Maya switches from wireframe to shaded mode since it also changes from color index to RGB mode.

Arguments

  • buffer The MPxGlBuffer in which to draw the view.
  • offscreen Should the buffer be redrawn if it's offscreen?
  • projMatrix Projection matrix to provide to openGL before drawing

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: viewToWorld ( short x_pos, short y_pos, MPoint & worldPt, MVector & worldVector ) const

Description

Takes a point in port coordinates and returns a corresponding ray in world coordinates.

Arguments

  • x_pos the x position of the point in port coordinates
  • y_pos the y position of the point in port coordinates
  • worldPt (returned) the source of the ray
  • worldVector (returned) the direction of the ray

Return Value

  • Status Code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: viewToWorld ( short x_pos, short y_pos, MPoint & nearClipPt, MPoint & farClipPt ) const

Description

Takes a point in port coordinates and returns a point on the near and far clipping planes.

Arguments

  • x_pos the x position of the point in port coordinates
  • y_pos the y position of the point in port coordinates
  • nearClipPt (returned) point on near clipping plane
  • farClipPt (returned) point on far clipping plane

Return Value

  • Status Code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: viewToObjectSpace ( short x_pos, short y_pos, const MMatrix & localMatrixInverse, MPoint & oPt, MVector & oVector ) const

Description

Takes a point in port coordinates and returns a corresponding ray in object coordinates.

Arguments

  • x_pos the x position of the point in port coordinates
  • y_pos the y position of the point in port coordinates
  • localMatrixInverse the inclusive matrix inverse of the object in question
  • oPt (returned) the source of the ray in object space
  • oVector (returned) the direction of the ray in object space

Return Value

  • Status Code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

bool M3dView:: worldToView ( const MPoint & worldPt, short& x_pos, short& y_pos, MStatus * ReturnStatus ) const

Description

converts a point in world space to port space. The return value indicates if the point is not clipped.

Arguments

  • worldPt the point to world space
  • x_pos (returned) The x coordinate of the world point in port space.
  • y_pos (returned) The y coordinate of the world point in port space.
  • ReturnStatus Status code

Return Value

  • true point is not clipped
  • false point is undefined or outside frustum

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: projectionMatrix ( MMatrix &projMat ) const

Description

Returns the projection matrix currently being used by OpenGL in the current view

Arguments

  • matrix A place to store the projection matrix

Return Value

  • Status Code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: modelViewMatrix ( MMatrix & modelViewMatrix ) const

Description

Returns the modelview matrix currently being used by OpenGL in the current view

Arguments

  • matrix A place to store the modelview matrix

Return Value

  • Status Code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

M3dView::DisplayStyle M3dView:: displayStyle ( MStatus * ReturnStatus ) const

Description

Return the display style for this 3d view. The display style can be wireframe, flat-shaded, or smooth-shaded.

Arguments

  • ReturnStatus Status code

Return Value

  • The display style for this view

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

bool M3dView:: isShadeActiveOnly ( MStatus * ReturnStatus ) const

Description

Returns true if this view's display style is shaded for objects that are active and wireframe otherwise.

Arguments

  • ReturnStatus Status code

Return Value

  • true Only active objects are shaded if this view is in shaded mode
  • false All objects are shaded if this view is in shaded mode

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: setDisplayStyle ( DisplayStyle style, bool activeOnly )

Description

Sets the display style for this view. The display style can be wireframe, flat-shaded, or smooth-shaded.

Arguments

  • style The display style to be set for this view
  • activeOnly Specifies whether only active objects are to be shaded in shaded mode.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: setViewSelectedPrefix (const MString &prefix)

Description

Sets the prefix for the camera name as displayed in the heads up display when view selected is enabled. The prefix is concatenated with the camera name.

The default value is "isolate: "

Arguments

  • prefix The prefix to use.

Return Value

  • status

Status Codes

  • MS::kSuccess Operation successful

bool M3dView:: showViewSelectedChildren ( MStatus *ReturnStatus ) const

Description

Returns turn if view selected shows all of the children of the obejcts that are flagged for view selected.

Arguments

  • ReturnStatus The return status

Return Value

  • true if the children of view selected objects are drawn.

Status Codes

  • MS::kSuccess Operation successful
  • MS::kSuccess Operation failed

MStatus M3dView:: setShowViewSelectedChildren (bool show)

Description

This method changes the way that view selected works. By default, view selected with show all of the children of the objects in the view selected set. If false is passed to this method, then only the obejcts in the view selected set and their shapes will be drawn.

Arguments

  • show true if all of the children of view selected objects should be displayed. true is the default behavior for view selected.

Return Value

  • return status

Status Codes

  • MS::kSuccess Operation successful
  • MS::kSuccess Operation failed

MString M3dView:: viewSelectedPrefix ( MStatus *ReturnStatus ) const

Description

Returns the Returns the prefix used when displaying the camera name in the heads up display when view selected in on.

Arguments

  • ReturnStatus the return status

Return Value

  • the prefix.

Status Codes

  • MS::kSuccess Operation successful

MStatus M3dView:: getM3dViewFromModelPanel (const MString &name, M3dView &view)

Description

Given the name of a model panel, get the M3dView used by that panel. If this fails, then a panel with the given name could not be located.

Arguments

  • name The name of the model panel.
  • view The M3dView from the model panel.

Return Value

  • Return Status

Status Codes

  • MS::kSuccess Operation successful
  • MS::kSuccess Operation failed

MStatus M3dView:: getM3dViewFromModelEditor (const MString &name, M3dView &view)

Description

Given the name of a model editor, get the M3dView used by that editor. If this fails, then a editor with the given name could not be located.

Arguments

  • name The name of the model editor.
  • view The M3dView from the model editor.

Return Value

  • Return Status

Status Codes

  • MS::kSuccess Operation successful
  • MS::kSuccess Operation failed

MStatus M3dView:: getLightCount ( unsigned int &count, bool visible )

Description

Get the number of lights for the view.

Arguments

  • count The number of visible lights for the view. Returned.
  • visible Specify whether to count visible lights only. By Default this is set true.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: getLightingMode ( M3dView::LightingMode &mode )

Description

Get the current lighting mode for the view.

Arguments

  • mode The lighting mode for the view. Returned.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: getLightPath ( unsigned int lightNumber, MDagPath &lightPath )

Description

Get the path to a certain light.

Arguments

  • lightNumber Number of the light interested in
  • lightPath Path to light. Returned

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: isLightVisible ( unsigned int lightNumber, bool &visible )

Description

Find out if a light is visible in the view

Arguments

  • lightNumber The number of the light to check.
  • visible Whether the light is visible or not. Returned

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: getLightIndex ( unsigned int lightNumber, unsigned int &lightIndex )

Description

Get the internal light index for a given light number

Arguments

  • lightNumber The number of the light to check.
  • lightIndex The internal light index (returned)

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

M3dView::RendererName M3dView:: getRendererName ( MStatus *ReturnStatus ) const

Description

Get the name of the current renderer being used for drawing to this view. The current possible return values are:

kDefaultQualityRenderer : This is equivalent to when the renderer name is "base_OpenGL_Renderer" when queried from the "modelEditor" command kHighQualityRenderer : This is equivalent to when the renderer name is "hwRender_OpenGL_Renderer" when queried from the "modelEditor" command

Note that the latter is not supported on platforms running the IRIX operating system.

Arguments

  • ReturnStatus the return status

Return Value

  • the name of the current renderer.

Status Codes

  • MS::kSuccess Operation successful

MStatus M3dView:: getRendererString ( MString &stringName ) const

Description

Get the string name of the current renderer being used for drawing to this view.

Python Notes

This method is not supported in Python. See the version which returns a string.

Arguments

  • stringName string name (returned).

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MString M3dView:: rendererString ( MStatus * ReturnStatus ) const

Description

Get the string name of the current renderer being used for drawing to this view.

Arguments

  • ReturnStatus Status code (see below)

Return Value

  • string name

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

bool M3dView:: wireframeOnlyInShadedMode ( MStatus *ReturnStatus ) const

Description

Return whether we are in shaded mode, but that only non shaded drawing should occur (wireframe).

In general it will return true only when the current renderer is "hwRender_OpenGL_Renderer". See the M3dView::getRendererString() method for more details.

Arguments

  • ReturnStatus the return status

Return Value

  • true if we are in this mode.

Status Codes

  • MS::kSuccess Operation successful

MStatus M3dView:: readColorBuffer ( MImage &image, bool readRGBA )

Description

Read the RGB values from the frame buffer for a given view. The buffer is read in a pixel format which is BGRA by default, such that each channel is one byte in size.

Arguments

  • image The image contains the frame buffer pixels.
  • readRGBA Read the image back in RGBA format. By default the format is BGRA.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: writeColorBuffer ( const MImage &image, signed short x , signed short y ) const

Description

Overwrite the RGB values for the frame buffer for a given view. Expected input is a block of RGBA, such that each channel is one byte in size.

Arguments

  • image The image containing the block of pixels to write
  • x The location in screen space of the lower left corner (X) of the image to write. The default value is 0.
  • y The location in screen space of the lower left corner (Y) of the image to write. The default value is 0.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: readDepthMap (unsigned short x, unsigned short y, unsigned int width, unsigned int height, unsigned char* bufferPtr, DepthBufferFormat depthMapPrecision)

Description

Read the depth values from the frame buffer for a given view. The buffer is read into a block of data as defined as an argument. The data block size must be large enough to accomodate ( view width * view height * depth map precision ) bytes of data.

Arguments

  • x Start position x to read.
  • y Start position y to read.
  • width Number of pixels in x to read.
  • height Number of pixels in y to read.
  • bufferPtr Pointer to depth data allocated by the caller.
  • depthMapPrecision Enumerated depth precision.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

MStatus M3dView:: readBufferTo2dTexture (unsigned short x, unsigned short y, unsigned int width, unsigned int height)

Description

Read the depth values from the frame buffer for a given view into a predefined OpenGL 2d texture. It is assumed that such a texture has been created and bound before making this call.

Arguments

  • x Start position x to read.
  • y Start position y to read.
  • width Number of pixels in x to read.
  • height Number of pixels in y to read.

Return Value

  • Status code

Status Codes

  • MS::kSuccess Method was successful
  • MS::kFailure Object error

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright