- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions

# ViewPort Class Reference

This reference page is linked to from the following overview topics: Mudbox 2013, Scene Graph, Layers and Viewport Filters, Viewports.

Search for all occurrences

## Detailed Description

Represents the 3D viewport where Mudbox renders the scene.

This class provides access to 3D rendering related functions and events. To get a pointer to the current Mudbox viewport, call Kernel()->ViewPort().

Definition at line 147 of file viewport.h.

`#include <viewport.h>`

Inheritance diagram for ViewPort:
[legend]

List of all members.

## Public Types
enum | RedrawType { eFull, eArea, eOverlayOnly }
| This type controls the behaviour of the Redraw function, used as a parameter there. More...
enum | SceneRenderMode { srmNormal = 0, srmFlatTexturesOnBlack, srmFlatTexturesOnWhite, srmFlatNoTextures, srmNoTextures }
| Describes how to render the scene off-screen with RenderScene. More...
## Public Member Functions
virtual unsigned int | FilterCount (void) const
| Returns the number of ViewPortFilters associated with this ViewPort.
virtual ViewPortFilter * | Filter (unsigned int iIndex) const
| Returns a pointer to a ViewPortFilter associated with this ViewPort.
virtual void | AddFilter (ViewPortFilter *pFilter)
| Associates a ViewPortFilter with this ViewPort.
virtual void | RemoveFilter (unsigned int iIndex)
| Removes a ViewPortFilter that was associated with this ViewPort. The filter is not deleted.
void | LockFilterCalibration (bool bLocked)
| Locks/unlocks the calibration of all viewport filters associated with this ViewPort. (See ViewPortFilter::LockCalibration())
virtual void | SaveScreenshot (const QString &sFileName) const
| Saves a snapshot of the current viewport to the given image file name.
virtual int | Width (void)
| Returns the width of the ViewPort in pixels.
virtual int | Height (void)
| Returns the height of the ViewPort in pixels.
class ImagePlaneInterface * | ActiveImagePlane ()
| Returns the current image plane.
virtual float | CursorXPosition (void) const
| Returns the current cursor horizontal position inside the viewport in the 0-1 range.
virtual float | CursorYPosition (void) const
| Returns the current cursor vertical position inside the viewport in the 0-1 range.
const SurfacePoint * | CursorSurfacePoint (bool bMirrored=false) const
| Returns the surface point which is under the cursor.
unsigned int | LayerCount (void) const
| This is the same as FilterCount()
class Layer * | Layer (unsigned int iLayerIndex) const
| This is the same as Filter()
void | UnlinkLayer (class Layer *pLayer)
| This is the same as RemoveFilter()
class Layer * | CreateLayer (void)
| Returns a new ViewPortFilter.
void | AddLayer (class Layer *pLayer)
| This is the same as AddFilter()
class Layer * | ActiveLayer (void) const
| Returns a pointer to the active layer (filter). That is, the one last clicked on by the user.
void | SetActiveLayer (class Layer *pLayer)
| Set a layer (filter) to be the active one.
ViewPortFilter::RequirementValue | ViewPortFilterRequirements (void) const
| Returns the combined requirements of all visible ViewPortFilters associated with this ViewPort.
void | Redraw (RedrawType eType=eFull, float fXStart=0, float fYStart=0, float fXEnd=0, float fYEnd=0)
| Calling this function will redraw the viewport.
Image * | RenderScene (const QString &sChannel, int iWidth, int iHeight, SceneRenderMode renderMode, enum Image::Format fmt=Image::e8integer, bool bTiledImg=true)
| Renders the scene, and returns it in an image.
Image * | RenderScene (int iWidth, int iHeight, SceneRenderMode renderMode, enum Image::Format fmt=Image::e8integer, bool bTiledImg=true)
| Renders the scene, and returns it in an image.
Image * | RenderScene (int iWidth, int iHeight, enum Image::Format fmt=Image::e8integer, bool bTiledImg=true) const
| Renders the scene, including background and post-process filters, and returns it in an image.
virtual struct ViewPortState | ViewPortState (void)
| Returns the viewport state structure.
virtual bool | ShowCurves (void) const
| Returns true if curves are being rendered in this viewport. False otherwise.
## Static Public Attributes
static aevent | PreRenderEvent
| This event is triggered when a new frame is about to be drawn.
static aevent | FrameEvent
| This event is triggered when a new frame is displayed on the viewport. See the class EventGate for more details.
static aevent | EndRenderEvent
| This event is triggered when rendering a new image of the scene is finished. See the class EventGate for more details.
static aevent | PostRenderEvent
| This event is triggered at the end of rendering the scene into a rendertarget.
static aevent | MouseMoveEvent
| This event is triggered when a mouse move event occurs inside the viewport.
static aevent | LeftMouseButtonPressEvent
| This event is triggered when left mouse button down occurs.
static aevent | LeftMouseButtonReleaseEvent
| This event is triggered when left mouse button release occurs.
static aevent | ContextMenuEvent
| This event is triggered on context menu (right mouse button)
static aevent | SceneRenderEvent
| This event is triggered after scene is rendered.
static aevent | ViewportResizeEvent
| This event is triggered when viewport's size is changed.
## Protected Member Functions
| ViewPort (void)
| Do not use the constructor directly.
virtual Image * | RenderRegion (ImgTile bounds, ImgTile region, enum Image::Format eFormat, bool bTiled) const

## Member Enumeration Documentation

enum RedrawType

Search for all occurrences

This type controls the behaviour of the Redraw function, used as a parameter there.

Enumerator:

  eFull | Search for all occurrences
  eArea | Schedule a full redraw of the 3d viewport later, ViewPort::Redraw returns immediately when this parameter is used. Search for all occurrences
  eOverlayOnly | Schedule a redraw of the 3d viewport for the specified area only, ViewPort::Redraw returns immediately when this parameter is used. Redraws the overlay part of the viewport right away. The 3d content is not redrawn. Search for all occurrences

Definition at line 249 of file viewport.h.

        {
            eFull,
            eArea,
            eOverlayOnly
        };

enum SceneRenderMode

Search for all occurrences

Describes how to render the scene off-screen with RenderScene.

Enumerator:

  srmNormal | Renders the scene as it would appear in the interactive viewport. Search for all occurrences
  srmFlatTexturesOnBlack | flat shaded, textures on black material background, no grids, curves or background Search for all occurrences
  srmFlatTexturesOnWhite | flat shaded, textures on white material background, no grids, curves or background Search for all occurrences
  srmFlatNoTextures | flat shaded, no textures, grids, curves or background Search for all occurrences
  srmNoTextures | flat shading off, textures off, no grids, curves or background Search for all occurrences

Definition at line 266 of file viewport.h.

                             {
            srmNormal = 0,
            srmFlatTexturesOnBlack,
            srmFlatTexturesOnWhite,
            srmFlatNoTextures,
            srmNoTextures
        };

## Constructor & Destructor Documentation

ViewPort | ( | void |  | ) | `[protected]`

Do not use the constructor directly.

It is unlikely that you would ever create your own scene in a plug-in. If you do need to, you should not call the constructor directly. Instead, use CreateInstances, like this:

            Viewport *myNewScene = CreateInstance<Viewport>();

## Member Function Documentation

virtual unsigned int FilterCount | ( | void |  | ) | const `[virtual]`

Search for all occurrences

Returns the number of ViewPortFilters associated with this ViewPort.

virtual ViewPortFilter* Filter | ( | unsigned int | iIndex | ) | const `[virtual]`

Search for all occurrences

Returns a pointer to a ViewPortFilter associated with this ViewPort.

Parameters:

  [in] | iIndex | index of the ViewPortFilter to be returned

virtual void AddFilter | ( | ViewPortFilter * | pFilter | ) | `[virtual]`

Search for all occurrences

Associates a ViewPortFilter with this ViewPort.

Parameters:

  [in] | pFilter | a pointer to the ViewPortFilter to be added

virtual void RemoveFilter | ( | unsigned int | iIndex | ) | `[virtual]`

Search for all occurrences

Removes a ViewPortFilter that was associated with this ViewPort. The filter is not deleted.

Parameters:

  [in] | iIndex | index of the ViewPortFilter to be removed

void LockFilterCalibration | ( | bool | bLocked | ) |

Search for all occurrences

Locks/unlocks the calibration of all viewport filters associated with this ViewPort. (See ViewPortFilter::LockCalibration())

Parameters:

  [in] | bLocked | Set this true to lock calibration, and false to unlock it

virtual void SaveScreenshot | ( | const QString & | sFileName | ) | const `[virtual]`

Search for all occurrences

Saves a snapshot of the current viewport to the given image file name.

The file type will be determined by the extension of the file name (eg .png, .bmp, .tif).

See also Kernel()->RenderScene() for a more flexible method.

Parameters:

  [in] | sFileName | Name of the image file where the screenshot should be saved

virtual int Width | ( | void |  | ) | `[virtual]`

Search for all occurrences

Returns the width of the ViewPort in pixels.

virtual int Height | ( | void |  | ) | `[virtual]`

Search for all occurrences

Returns the height of the ViewPort in pixels.

class ImagePlaneInterface* ActiveImagePlane | ( |  | ) |

Search for all occurrences

Returns the current image plane.

virtual float CursorXPosition | ( | void |  | ) | const `[virtual]`

Search for all occurrences

Returns the current cursor horizontal position inside the viewport in the 0-1 range.

virtual float CursorYPosition | ( | void |  | ) | const `[virtual]`

Search for all occurrences

Returns the current cursor vertical position inside the viewport in the 0-1 range.

const SurfacePoint* CursorSurfacePoint | ( | bool | bMirrored = `false` | ) | const

Search for all occurrences

Returns the surface point which is under the cursor.

Parameters:

  [in] | bMirrored | a bool to determine whether getting the mirrored surface point.

unsigned int LayerCount | ( | void |  | ) | const `[virtual]`

Search for all occurrences

This is the same as FilterCount()

Reimplemented from LayerContainer.

class Layer* Layer | ( | unsigned int | iLayerIndex | ) | const `[virtual]`

Search for all occurrences

This is the same as Filter()

Parameters:

  [in] | iLayerIndex | index of the layer (filter) to be returned

Reimplemented from LayerContainer.

void UnlinkLayer | ( | class Layer * | pLayer | ) | `[virtual]`

Search for all occurrences

This is the same as RemoveFilter()

Parameters:

  [in] | pLayer | index of the layer (filter) to be removed

Reimplemented from LayerContainer.

class Layer* CreateLayer | ( | void |  | ) | `[virtual]`

Search for all occurrences

Returns a new ViewPortFilter.

Reimplemented from LayerContainer.

void AddLayer | ( | class Layer * | pLayer | ) | `[virtual]`

Search for all occurrences

This is the same as AddFilter()

Parameters:

  [in] | pLayer | a pointer to the layer (filter) to be added

Reimplemented from LayerContainer.

class Layer* ActiveLayer | ( | void |  | ) | const `[virtual]`

Search for all occurrences

Returns a pointer to the active layer (filter). That is, the one last clicked on by the user.

Reimplemented from LayerContainer.

void SetActiveLayer | ( | class Layer * | pLayer | ) | `[virtual]`

Search for all occurrences

Set a layer (filter) to be the active one.

Parameters:

  [in] | pLayer | a pointer to the layer (filter) to be made active

Reimplemented from LayerContainer.

ViewPortFilter::RequirementValue ViewPortFilterRequirements | ( | void |  | ) | const

Search for all occurrences

Returns the combined requirements of all visible ViewPortFilters associated with this ViewPort.

void Redraw | ( | RedrawType | eType = `eFull`,
|  | float | fXStart = `0`,
|  | float | fYStart = `0`,
|  | float | fXEnd = `0`,
|  | float | fYEnd = `0`
| ) |  |

Search for all occurrences

Calling this function will redraw the viewport.

Parameters:

  [in] | eType | This parameter determined what should be affected by the function. See ViewPort::RedrawType for mode details.
  [in] | fXStart | Left side of the area which has to be refreshed in the 0-1 intervall. Ignored if eType != eArea.
  [in] | fYStart | Top side of the area which has to be refreshed in the 0-1 intervall. Ignored if eType != eArea.
  [in] | fXEnd | Right side of the area which has to be refreshed in the 0-1 intervall. Ignored if eType != eArea.
  [in] | fYEnd | Upper side of the area which has to be refreshed in the 0-1 intervall. Ignored if eType != eArea.

Examples:
  MeshBuilder/MeshBuilder.cpp.

Image* RenderScene | ( | const QString & | sChannel,
|  | int | iWidth,
|  | int | iHeight,
|  | SceneRenderMode | renderMode,
|  | enum Image::Format | fmt = `Image::e8integer`,
|  | bool | bTiledImg = `true`
| ) |  |

Search for all occurrences

Renders the scene, and returns it in an image.

Does not include extra things like the HUD or the cursor ring. Returns a pointer to an image object that the scene was rendered into. You can specify the desired size for the rendering, or leave the input variables set to 0 to render at the current screen resolution.

You can also describe a render mode -- the different render modes can be used together to extract unprojected textures or extract shading/shadow information.

currently only 8 bit images are supported by this operation Note: Once the image is returned, it is your responsibility to delete it when you are done with it.

Parameters:

  [in] | sChannel | the name of the channel to render
  [in] | iWidth | The width of the rendering in pixels. Set to 0 to use current screen size.
  [in] | iHeight | The height of the rendering in pixels. Set to 0 to use current screen size.
  | renderMode | describes variations on how to render the scene.
  [in] | fmt | Desired image format.
  [in] | bTiledImg | hint -- true if the resulting image is to be tiled, false if contiguous.

Image* RenderScene | ( | int | iWidth,
|  | int | iHeight,
|  | SceneRenderMode | renderMode,
|  | enum Image::Format | fmt = `Image::e8integer`,
|  | bool | bTiledImg = `true`
| ) |  |

Search for all occurrences

Renders the scene, and returns it in an image.

Does not include extra things like the HUD or the cursor ring. Returns a pointer to an image object that the scene was rendered into. You can specify the desired size for the rendering, or leave the input variables set to 0 to render at the current screen resolution.

You can also describe a render mode -- the different render modes can be used together to extract unprojected textures or extract shading/shadow information.

currently only 8 bit images are supported by this operation Note: Once the image is returned, it is your responsibility to delete it when you are done with it.

Parameters:

  [in] | iWidth | The width of the rendering in pixels. Set to 0 to use current screen size.
  [in] | iHeight | The height of the rendering in pixels. Set to 0 to use current screen size.
  | renderMode | describes variations on how to render the scene.
  [in] | fmt | Desired image format.
  [in] | bTiledImg | hint -- true if the resulting image is to be tiled, false if contiguous.

Image* RenderScene | ( | int | iWidth,
|  | int | iHeight,
|  | enum Image::Format | fmt = `Image::e8integer`,
|  | bool | bTiledImg = `true`
| ) |  | const

Search for all occurrences

Renders the scene, including background and post-process filters, and returns it in an image.

Does not include extra things like the HUD or the cursor ring. Returns a pointer to an image object that the scene was rendered into. You can specify the desired size for the rendering, or leave the input variables set to 0 to render at the current screen resolution.

currently only 8 bit images are supported by this operation Note: Once the image is returned, it is your responsibility to delete it when you are done with it.

Parameters:

  [in] | iWidth | The width of the rendering in pixels. Set to 0 to use current screen size.
  [in] | iHeight | The height of the rendering in pixels. Set to 0 to use current screen size.
  [in] | fmt | Desired image format.
  [in] | bTiledImg | hint -- true if the resulting image is to be tiled, false if contiguous.

virtual struct ViewPortState ViewPortState | ( | void |  | ) | `[read, virtual]`

Search for all occurrences

Returns the viewport state structure.

virtual bool ShowCurves | ( | void |  | ) | const `[virtual]`

Search for all occurrences

Returns true if curves are being rendered in this viewport. False otherwise.

virtual Image* RenderRegion | ( | ImgTile | bounds,
|  | ImgTile | region,
|  | enum Image::Format | eFormat,
|  | bool | bTiled
| ) |  | const `[protected, virtual]`

Search for all occurrences

## Member Data Documentation

aevent PreRenderEvent `[static]`

Search for all occurrences

This event is triggered when a new frame is about to be drawn.

Definition at line 344 of file viewport.h.

aevent FrameEvent `[static]`

Search for all occurrences

This event is triggered when a new frame is displayed on the viewport. See the class EventGate for more details.

Definition at line 347 of file viewport.h.

aevent EndRenderEvent `[static]`

Search for all occurrences

This event is triggered when rendering a new image of the scene is finished. See the class EventGate for more details.

Definition at line 350 of file viewport.h.

aevent PostRenderEvent `[static]`

Search for all occurrences

This event is triggered at the end of rendering the scene into a rendertarget.

Plugins can use this event to render additional content to the rendertargets, like gizmos or overlays. See the class EventGate for more details.

Definition at line 354 of file viewport.h.

aevent MouseMoveEvent `[static]`

Search for all occurrences

This event is triggered when a mouse move event occurs inside the viewport.

Definition at line 357 of file viewport.h.

aevent LeftMouseButtonPressEvent `[static]`

Search for all occurrences

This event is triggered when left mouse button down occurs.

Definition at line 360 of file viewport.h.

aevent LeftMouseButtonReleaseEvent `[static]`

Search for all occurrences

This event is triggered when left mouse button release occurs.

Definition at line 363 of file viewport.h.

aevent ContextMenuEvent `[static]`

Search for all occurrences

This event is triggered on context menu (right mouse button)

Definition at line 366 of file viewport.h.

aevent SceneRenderEvent `[static]`

Search for all occurrences

This event is triggered after scene is rendered.

Should be used if plug in has any widgets to render into the scene.

Definition at line 370 of file viewport.h.

aevent ViewportResizeEvent `[static]`

Search for all occurrences

This event is triggered when viewport's size is changed.

Definition at line 373 of file viewport.h.

The documentation for this class was generated from the following file:

- Mudbox/viewport.h

ViewPort ViewPort ViewPort ViewPort ViewPort ViewPort ViewPort ViewPort ViewPort ViewPort
ViewPort ViewPort ViewPort ViewPort ViewPort ViewPort ViewPort ViewPort ViewPort ViewPort