Main Content

vr.utils.stereo3d Class

Superclasses:

(To be removed) Stereoscopic vision settings for vr.canvas and vr.figure objects

vr.utils.stereo3d will be removed in a future release. For more information, see Version History.

Description

Tip

Use the vr.utils.stereo3d class for advanced tuning of stereoscopic viewer and canvas properties. You can select and use basic stereoscopic settings from the Viewer menu.

Specifies these stereoscopic vision properties:

  • Active, anaglyph, or no stereoscopic vision

  • Camera offset

  • Camera angle

  • Color filter for the left and right cameras

  • Horizontal image translation (HIT)

Use a vr.utils.stereo3d object to set the Stereo3D, Stereo3DCameraOffset, and Stereo3DHIT stereoscopic vision properties of vrfigure and vr.canvas objects. Specifying a vr.utils.stereo3d object to set one vrfigure and vr.canvas property also sets the other stereoscopic vision properties. Using a vr.utils.stereo3d object also specifies color filters for the left and right cameras. You cannot set camera color filters directly using the vrfigure/set method or vr.canvas properties.

Construction

stereoVision = vr.utils.stereo3d.OFF disables stereoscopic vision.

stereoVision = vr.utils.stereo3d.ACTIVE enables active stereoscopic vision.

stereoVision = vr.utils.stereo3d.ANAGLYPH enables red-cyan anaglyph stereoscopic vision.

stereoVision = vr.utils.stereo3d.RED_CYAN enables red-cyan anaglyph stereoscopic vision.

example

stereoVision = vr.utils.stereo3d.ANAGLYPH_GREEN_MAGENTA enables green-magenta anaglyph stereoscopic vision.

stereoVision = vr.utils.stereo3d.ANAGLYPH_RED_GREEN enables red-green anaglyph stereoscopic vision.

stereoVision = vr.utils.stereo3d.ANAGLYPH_RED_BLUE enables red-blue anaglyph stereoscopic vision.

stereoVision = vr.utils.stereo3d.ANAGLYPH_YELLOW_BLUE enables yellow-blue anaglyph stereoscopic vision.

Output Arguments

expand all

Stereoscopic vision settings for vr.canvas and vrfigure objects, represented by a vr.utils.stereo3d object.

Properties

expand all

Camera angle, specified using the predefined DEFAULT_CAMERA_ANGLE or in radians. This property is in effect when you enable stereoscopic vision.

This property does not apply to vr.canvas or vrfigure objects.

Camera offset, specified as a number representing the distance in virtual world units of left/right camera from parallax. The parallax is the difference in the apparent position of an object viewed from two cameras.

This property sets the Stereo3DCameraOffset property of a vr.canvas or vrfigure object.

Horizontal image translation, specified as either the predefined DEFAULT_HIT or as a floating-point number from 0 through 1, inclusive. The number of pixels for stereo 3D horizontal image translation (HIT) derives from this number. Horizontal image translation is the horizontal relationship of the two stereo images. By default, the background image is at zero and the foreground image appears to pop out from the monitor toward the person viewing the virtual world. The larger the value, the further back the background appears to be.

This property sets the Stereo3DHIT property of a vr.canvas or vrfigure object.

Color filter of the left camera, specified as a row vector of nine floating-point numbers or using a predefined filter.

If you specify a row vector, use floating-point numbers from 0 through 1. The first three numbers represent the red value, the second three numbers represent the green value, and the last three numbers represent the blue value. For example, specifying 1 for the first three numbers and zeros for the other numbers produces a pure red filter.

The predefined filters are:

  • CAMERA_FILTER_FULL

  • CAMERA_FILTER_RED

  • CAMERA_FILTER_CYAN

  • CAMERA_FILTER_GREEN

  • CAMERA_FILTER_MAGENTA

  • CAMERA_FILTER_YELLOW

  • CAMERA_FILTER_BLUE

This property specifies the left camera filter for vr.canvas or vrfigure objects.

Example: stereo3d_object.LeftCameraFilter = [0.1 0.5 0.5 0.0 0.0 0.0 1.0 0.5 0.5];

Example: stereo3d_object.LeftCameraFilter = stereo3d_object.CAMERA_FILTER_RED

Stereoscopic vision mode. Read only.

  • STEREO3D_OFF — No stereoscopic vision.

  • STEREO3D_ACTIVE — Active stereoscopic vision. Stereoscopic vision uses quad-buffered rendering. You can use a graphics card driver to output stereoscopic vision. This mode allows active stereoscopic vision via shutter glasses.

  • STEREO3D_ANAGLYPH — Anaglyph stereoscopic vision. Stereoscopic vision is enabled using red-cyan anaglyph. Use appropriate anaglyph 3D glasses to see the effect.

This property sets the Stereo3D property of a vr.canvas or vrfigure object.

Color filter of the right camera, specified as a row vector of nine floating-point numbers or using a predefined filter.

If you specify a row vector, use floating-point numbers from 0 through 1. The first three numbers represent the red value, the second three numbers represent the green value, and the last three numbers represent the blue value. For example, specifying 1 for the first three numbers and zeros for the other numbers produces a pure red filter.

The predefined filters are:

  • CAMERA_FILTER_FULL

  • CAMERA_FILTER_RED

  • CAMERA_FILTER_CYAN

  • CAMERA_FILTER_GREEN

  • CAMERA_FILTER_MAGENTA

  • CAMERA_FILTER_YELLOW

  • CAMERA_FILTER_BLUE

This property specifies the right camera filter for vr.canvas or vrfigure objects.

Example: stereo3d_object.RightCameraFilter = [0.1 0.5 0.5 0.0 0.0 0.0 1.0 0.5 0.5];

Example: stereo3d_object.RightCameraFilter = stereo3d_object.CAMERA_FILTER_RED

Examples

collapse all

Create a virtual world.

w = vrworld('vrmount');
open(w);
c = vr.canvas(w);

Specify stereoscopic vision settings.

s3d = vr.utils.stereo3d.ANAGLYPH_RED_CYAN;
s3d.CameraOffset = 0.05;
s3d.CameraAngle = pi/128;

Modify the red component of filter for the left camera.

s3d.LeftCameraFilter(1:3) = s3d.LeftCameraFilter(1:3)...
                            + [0.1 -0.05 -0.05];

Apply stereoscopic vision settings of vr.utils.stereo3d object s3d to vr.canvas object c.

        set(c,'Stereo3D',s3d)

Version History

Introduced in R2015a

collapse all

R2023b: To be removed

The vr.utils.stereo3d will be removed in a future release. Instead, use sim3d classes and Simulation 3D blocks to interface MATLAB® and Simulink® with the Unreal Engine® 3D simulation environment. To get started, see Create 3D Simulations in Unreal Engine Environment.