Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ XR Studio

Viewport

  • Last UpdatedFeb 19, 2025
  • 6 minute read

The Viewport node makes it possible to enable/disable, resize, move, set the bit mask, enable/disable cave mode, and set all cave parameters on any viewport at runtime.

At startup, the XR engine creates a Viewport node for each one defined in the RenderSetup XML. The node is named as viewport_%VIEWPORT_NAME%, where %VIEWPORT_NAME% stands for the name of the viewport in the XML definition.

The only way to create a Viewport node is by defining the viewport in the RenderSetup XML. For more information, see Viewports .

Platform support

The Viewport node is fully supported on XR-Windows platform.

These fields are not supported on NX platforms: cave, caveEnable, cavePoints, caveMatrix.

XR-WIN

XR-P-WIN

XR-P-IOS

XR-P-AND

XR-P-WASM

Full support

Partial support

Partial support

Partial support

Partial support

Full support

Limited support

Limited support

Limited support

Limited support

Limitations

Please note that, even with custom viewports definition, there are some limitations:

  • A Viewport named DEFAULT_VIEWPORT must exist in the RenderSetup XML. This viewport must have a Scene Layer named DEFAULT_SCENE_LAYER and a 2D layer named DEFAULT_2D_LAYER with a layer2dName of DEFAULT_2D_LAYER_MAIN.

  • In dualhead rendering, a viewport named RIGHT_VIEWPORT must exist in the RenderSetup XML. This viewport must have a Scene Layer named RIGHT_SCENE_LAYER and a 2D layer named RIGHT_2D_LAYER with a layer2dName of DEFAULT_2D_LAYER_MAIN.

  • Some of the fields of Global node refer only to DEFAULT_VIEWPORT.

  • Interaction and 2D rendering is bound to DEFAULT_VIEWPORT only.

  • Some manager nodes, such as Fgi and PostProcess, only affect DEFAULT_VIEWPORT.

  • Billboarded objects and other features that need rendering pose might not work properly on custom viewports.

  • Viewport cave logic cannot coexist with Camera cave logic. You should either use a viewport with caveEnable set to true or a camera with caveEnable set to true, but never both at the same time. It is recommended to prefer the viewport cave to the Camera cave, as the Camera cave is still supported for backward compatibility only.

  • At startup, the XR engine creates and assigns a VisualContext to each viewport that features a Scene Layer based on the defined visual context in the RenderSetup XML or, if not found, by assigning a default visual context.

  • SGL does not support viewports with size different from the window size, so SGL node will not be rendered inside those viewports. All the visual changes done on SGL are applied regardless of the visual context.

Cave

Cave logic relies on cave points definition. Cave points represent the corners of a wall of the cave in viewer’s camera space (Z is in front, and Y is up).

Example

Let’s look at an example of a cave room with the following dimensions in meters:

  • Width - 3.5m

  • Depth - 3.5m

  • Height - 2.6m

Let’s assume the viewer is at the exact center of the room, and consider the center of the room to be the origin of the cave point coordinate system.

We know that, for instance, the front wall of the cave is at 1.75m from the viewer and it is 3.5m wide and 2.6m tall, spanning from -1.75 to 1.75 on the horizontal plane and from -1.3 to 1.3 on the vertical plane. Therefore, the cave points required to render the cave front wall are:

  • Bottom-Left corner: -1.75, -1.3, 1.75

  • Bottom-Right corner: 1.75, -1.3, 1.75

  • Top-Left corner: -1.75, 1.3, 1.75

Notice how all three points have the same Z because these are the points of the front wall. In the case of the left wall, the Z values would change, but it would be the X values that are always the same -1.75. Once the cave points have been defined, you can apply an additional offset from the center of the room by using a transformation matrix in the caveMatrix field. The transformation matrix represents a roto-translation in the cavePoints coordinate system.

Mouse Position in viewport

The global mouse position gives the position as per the screen, whereas the viewport mouse position gives the position in pixel points.

This image shows the mouse positions with respect to global and viewports.

Viewport fields

These are the fields for Viewport node. Only the node-specific fields are indicated, not fields obtained by inheritance.

Field inheritance: NodeBase > Viewport

Fields

Type

Use

Default value

Description

caveEnable

sbool

Optional

false

If set to true, the rendering is modified by cavePoints and caveMatrix. See those field description for details.

caveMatrix

smatrix

Optional

1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

This matrix is an offset transformation matrix that modifies the point of view created by cavePoints.

cavePoints

mvec3

Optional

-1.75 -1.3 1.75,1.75 -1.3 1.75,-1.75 1.3 1.75

The three points represent, in this order, the bottom-left, bottom-right and top-left corners of a wall of the cave. The values are in meters and relative to the camera/human in the room.

enable

sbool

Optional

true

When true, the Viewport is rendered. When false, the camera is not rendered. Note that when set to false at runtime, the latest rendered frame pixels will not be cleared. Therefore, if no other viewport renders on the same area the latest rendered frame will always be displayed.

getProjectionMatrix

sfunction

Read Only

Returns the Viewport scene layer current projection matrix.

getSceneLayerCamera

sfunction

Read Only

Returns the Viewport scene layer current camera. If the camera has a corresponding Camera node, the node name is returned, otherwise the internal name is returned.

isOver

sbool

Optional

false

Becomes true when the mouse is over the viewport.

mousePositionPixel

svec2

Optional

Internally calculated

Mouse current position in pixel points. When mouse is outside viewport, it shows negative values.

mousePositionUnit

svec2

Optional

Internally calculated

Mouse current position unit in normalized range of 0 - 1.

position

svec2

Optional

Read from Configuration

The normalized position of the viewport in the render panel space. 0 0 represents upper-left corner of the panel, 1 1 represents the lower-right corner.

setSceneLayerCamera

sfunction

Read Only

Sets the Viewport scene layer current camera. If the name passed corresponds to a Camera node, that camera is used, otherwise it is treated as an internal name.

size

svec2

Optional

Read from Configuration

The normalized size of the viewport in the render panel space. 1 1 represents full width and height of the render panel

visibilityMask

sint

Read Only

Internally calculated

Use this field to set the bitMask rendered by the viewport.

visualContextNode

sstring

Mandatory

Read from RenderSetup XML

This field must contain a valid Visual Context node name. The specified Visual Context is used for rendering visual aspects of all the models in the rendered scenes. Changing this field at runtime allows you to rapidly switch visual aspects of the rendered geometries in the Viewport.

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in