This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Viewport Class

Warning
UnigineScript is deprecated and will be removed in future releases. Please consider using C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScipt is not guaranteed, as the current level of support assumes only fixing critical issues.

A Viewport class is used to render a scene with the specified settings.

The main use cases of the Viewport class are as follows:

  1. Render a scene to the image interface (data will be transferred from GPU memory to CPU memory), using the following methods:
    Source code (UnigineScript)
    // initialization
    Viewport viewport = new Viewport();
    
    Image image = new Image();
    image.create2D(512, 512, IMAGE_FORMAT_RGBA8);// create 512 x 512 render target
    
    CameraPtr camera = new Camera();
    // set modelview & projection matrices to camera instance
    
    // rendering an image from the camera to the image
    viewport.renderImage2D(camera, image);
  2. Render a node to the image (data will be transferred from GPU memory to CPU memory)
Notice

To set any viewport as a main, use the setViewport() method of the Render class.

A single viewport should be used with a single camera, otherwise it may cause visual artefacts. To avoid artefacts, when using several cameras with a single viewport, all post effects must be disabled using the setSkipFlags() method with the SKIP_POSTEFFECTS flag.

Viewport Class

Members


static Viewport ( ) #

Creates a new viewport with default settings.

void setAspectCorrection ( int correction ) #

Sets the aspect correction for current viewport. 1 enables correction, 0 disables.

Arguments

  • int correction - 1 to enable aspect correction, 0 to disable.

int getAspectCorrection ( ) #

Return the value indicating if the aspect correction enabled for current viewport.

Return value

1 if the aspect correction enabled, otherwise 0.

void setFirstFrame ( int frame ) #

Sets a value indicating if the first frame should be enabled over the current frame.

Arguments

  • int frame - 1 to set the first frame flag; otherwise, 0.

int getFirstFrame ( ) #

Returns a value indicating if the first frame is enabled over the current frame.

Return value

1 if the first frame flag is set; otherwise, 0.

int getID ( ) #

Returns the viewport ID.

Return value

Viewport ID.

void setMode ( int mode ) #

Sets the rendering mode for the current viewport. It can be one of the stereo or panoramic modes or the default mode.

Arguments

  • int mode - A rendering mode.

int getMode ( ) #

Returns the rendering mode set for the current viewport. It can be one of the stereo or panoramic modes or the default mode.

Return value

The current rendering mode.

void setNodeEnvironmentTextureName ( string name ) #

Sets a name for the environment texture.

Arguments

  • string name - A texture name.

void setNodeLightUsage ( int usage ) #

Sets the type of lighting for the render node.

Arguments

int getNodeLightUsage ( ) #

Returns the type of lighting of the render node.

Return value

The lighting type. Can be one of the following:

int isPanorama180 ( ) #

Returns a value indicating if a 180-degree panoramic rendering is enabled.

Return value

1 if a 180-degree panoramic rendering is enabled; otherwise, 0.

int isPanorama360 ( ) #

Returns a value indicating if a 360-degree panoramic rendering is enabled.

Return value

1 if a 360-degree panoramic rendering is enabled; otherwise, 0.

void setRenderMode ( int mode ) #

Sets the specified render mode. The mode determines the set buffers to be rendered.

Arguments

int getRenderMode ( ) #

Returns the current render mode. The mode determines the set buffers to be rendered.

Return value

Current render mode. Can be one of the following:

void setSkipFlags ( int flags ) #

Sets the skip flag for the current viewport.

Arguments

int getSkipFlags ( ) #

Returns the skip flag set for the current viewport.

Return value

A skip flag.

int isStereo ( ) #

Returns a value indicating if the stereo rendering is enabled for the current viewport (one of the stereo modes is set).

Return value

1 if the stereo rendering is enabled; otherwise, 0.

void setStereoDistance ( float distance ) #

Sets the focal distance for stereo rendering (distance in the world space to the point where two views line up, i.e. to the zero parallax plane).

Arguments

  • float distance - A focal distance in units.

float getStereoDistance ( ) #

Returns the focal distance for stereo rendering (distance in the world space to the point where two views line up, i.e. to the zero parallax plane).

Return value

A focal distance in units.

void setStereoOffset ( float offset ) #

Updates the virtual camera offset (an offset after the perspective projection).

Arguments

  • float offset - A virtual camera offset in units.

float getStereoOffset ( ) #

Returns the virtual camera offset (an offset after the perspective projection).

Return value

A virtual camera offset in units.

void setStereoRadius ( float radius ) #

Updates the radius for stereo (the half of the separation distance between the cameras (i.e. between eyes)).

Arguments

  • float radius - A stereo radius in units. If a negative value is provided, 0 will be used instead.

float getStereoRadius ( ) #

Returns the current radius for stereo (the half of the separation distance between the cameras (i.e. between eyes)).

Return value

Stereo radius in units.

void appendSkipFlags ( int flags ) #

Appends specified skip flags to the list of currently used ones.

Arguments

int checkSkipFlags ( int flags ) #

Returns a value indicating if the specified skip flags are set for the current viewport.

Arguments

Return value

1 if the skip flags are set; otherwise, 0.

void removeSkipFlags ( int flags ) #

Removes specified skip flags from the list of currently used ones.

Arguments

void render ( Camera camera ) #

Renders an image from the specified camera.

To render an image from the camera to the RenderTarget interface, do the following:

Source code (UnigineScript)
camera = new Camera();

rendertarget->enable();
	viewport->render(camera);
rendertarget->disable();

Arguments

  • Camera camera - Camera an image from which should be rendered.

void render ( Camera camera, int width, int height ) #

Renders an image of the specified size from the specified camera to the current rendering target.

Arguments

  • Camera camera - Camera, an image from which should be rendered.
  • int width - Image width, in pixels.
  • int height - Image height, in pixels.

void renderEngine ( Camera camera ) #

Renders an Engine viewport for the specified camera to the current rendering target. This method renders a splash screen and provides an image in accordance with panoramic and stereo rendering settings.

Arguments

  • Camera camera - Camera, an image from which should be rendered.

void renderImage2D ( Camera camera, Image image ) #

Renders an image from the camera to the given 2D image.
Notice
This method sets the format of the 2D image to one of the following values:
  • RGBA16F - in case if initial image format was 16-bit or 32-bit per channel float
  • RGBA8 - otherwise

Arguments

  • Camera camera - Camera, an image from which should be rendered.
  • Image image - Target 2D image to save the result to.

void renderImage2D ( Camera camera, Image image, int width, int height, int hdr = 0 ) #

Renders an image of the specified size from the camera to the 2D image.

Arguments

  • Camera camera - Camera, an image from which should be rendered.
  • Image image - Target 2D image to save the result to.
  • int width - Image width, in pixels.
  • int height - Image height, in pixels.
  • int hdr - HDR flag.
    Notice
    This parameter determines the format of the 2D image:
    • 1 - image format will be set to RGBA16F
    • 0 - image format will be set to RGBA8

void renderImageCube ( Camera camera, Image image, int size, int hdr = 0, int local_space = 0 ) #

Renders the image from the camera to the cube map of the specified size.

Arguments

  • Camera camera - Camera, an image from which should be rendered.
  • Image image - Target cube map to save the result to.
  • int size - Cube map edge size.
  • int hdr - HDR flag.
    Notice
    This parameter determines the format of the 2D image:
    • 1 - image format will be set to RGBA16F
    • 0 - image format will be set to RGBA8
  • int local_space - A flag indicating if the camera angle should be used for the cube map rendering.

void renderImageCube ( Camera camera, Image image ) #

Renders the image from the camera into the cube map.

Arguments

  • Camera camera - Camera, an image from which should be rendered.
  • Image image - Target cube map to save the result to.

void renderNode ( Camera camera, Node node ) #

Renders the given node with all children to the current rendering target.

Arguments

  • Camera camera - Camera, an image from which should be rendered.
  • Node node - Node to be rendered.

void renderNode ( Camera camera, Node node, int width, int height ) #

Renders the given node with all children to the current rendering target.

Arguments

  • Camera camera - Camera, an image from which should be rendered.
  • Node node - Node to be rendered.
  • int width - Image width, in pixels.
  • int height - Image height, in pixels.

void renderNodeImage2D ( Camera camera, Node node, Image image, int width, int height, int hdr ) #

Renders the given node with all children to the 2D image of the specified size.

Arguments

  • Camera camera - Camera, an image from which should be rendered.
  • Node node - Node to be rendered.
  • Image image - Target 2D image to save the result to.
  • int width - Image width, in pixels.
  • int height - Image height, in pixels.
  • int hdr - HDR flag.
    Notice
    This parameter determines the format of the 2D image:
    • 1 - image format will be set to RGBA16F
    • 0 - image format will be set to RGBA8

void renderNodeImage2D ( Camera camera, Node node, Image image ) #

Renders the given node with all children to the specified 2D image.

Arguments

  • Camera camera - Camera, an image from which should be rendered.
  • Node node - Node to be rendered.
  • Image image - Target 2D image to save the result to.

void renderNodeTexture2D ( Camera camera, Node node, Texture texture ) #

Renders the given node with all children to the specified 2D texture.

Arguments

  • Camera camera - Camera, an image from which should be rendered.
  • Node node - Node to be rendered.
  • Texture texture - Target 2D texture to save the result to.

void renderStereo ( Camera camera_left, Camera camera_right, string stereo_material ) #

Renders a stereo image in the current viewport.

Arguments

  • Camera camera_left - Camera that renders an image for the left eye.
  • Camera camera_right - Camera that renders an image for the right eye.
  • string stereo_material - List of names of stereo materials to be used.

void renderTexture2D ( Camera camera, Texture texture ) #

Renders an image from the camera to the specified 2D texture.

Arguments

  • Camera camera - Camera, an image from which should be rendered.
  • Texture texture - Target 2D texture to save the result to.

void setStereoHiddenAreaMesh ( Mesh hidden_area_mesh_left, Mesh hidden_area_mesh_right ) #

Sets custom meshes to be used for culling pixels, that are not visible in VR.
Notice

Arguments

  • Mesh hidden_area_mesh_left - Mesh representing hidden area for the left eye.
  • Mesh hidden_area_mesh_right - Mesh representing hidden area for the right eye.

void clearStereoHiddenAreaMesh ( ) #

Clears meshes that represent hidden areas for both, left and right eye. Hidden areas are used for culling pixels, that are not visible in VR
Last update: 2020-06-01
Build: ()