Hauptinhalt

ImageOverlay

R2026b

Specify image overlay in RoadRunner Viewer viewport

Since R2026b

    Description

    The ImageOverlay object represents an image overlay in the RoadRunner Viewer viewport. Use an ImageOverlay object to change the size, position, and image file of the corresponding image overlay.

    Creation

    The addImageOverlay function adds an empty image overlay to the viewport of the specified RoadRunner Viewer. For example, img = addImageOverlay(rrViewer); adds the empty image overlay img to the viewport of the RoadRunner Viewer object rrViewer.

    Properties

    expand all

    Path to the image file, specified as a string scalar or character vector. The path you specify must be relative to the Assets folder in your project. RoadRunner Viewer supports these file types for image overlays:

    • .png

    • .jpeg

    • .bmp

    • .svg

    RoadRunner Viewer scales and centers the image in the dimensions specified by Size and maintains the original aspect ratio of the image.

    Position of the image overlay in the viewport, specified as a 1-by-2 vector in the range [0, 1]. This value is relative to the size of the viewport, measured from the top-left corner. The value [0 0] is the top-left corner and [1 1] is the bottom-right.

    If you specify WorldPosition, RoadRunner Viewer ignores this property.

    Size of the image overlay in the viewport, specified as a 1-by-2 vector of the form [w h] in the range [0, 1]. The value of w extends the overlay to the right, and the value of h extends the overlay down, relative to Position and the size of the viewport.

    By default, the size of the image overlay is [0 0]. To see the image overlay, set this property to a value greater than 0.

    Position of the image overlay in the scene graph using world coordinates, specified as a 1-by-3 vector of the form [x y z]. RoadRunner Viewer places the top-left corner of the overlay at the specified position. If you specify this property, RoadRunner Viewer ignores the value of Position.

    By default, the image overlay position is relative to the RoadRunner Viewer viewport regardless of the camera position. You can use this property to specify for the image overlay to maintain a fixed position relative to the scene graph so that it remains at that position as the camera orbits, pans, or zooms.

    Examples

    collapse all

    Use addImageOverlay to add an image overlay to the RoadRunner Viewer viewport. Then, modify the properties of the ImageOverlay object to specify the image file, position, and size. This example assumes you have already added the folder containing the RoadRunner API to your MATLAB® path and created a project folder. For information on getting started with RoadRunner Viewer, see Get Started with RoadRunner Viewer (RoadRunner Scenario).

    Specify the path to a project folder. RoadRunner Viewer uses the 3D mesh, material, and image files in the Assets folder of the specified project.

    If you do not have a project folder and want to create one that already contains an Assets folder with sample files, create a RoadRunner project. By default, RoadRunner projects contain an Assets folder prepopulated with sample assets, such as a Sedan.fbx file, that you can use in RoadRunner Viewer. For information on creating a RoadRunner project, see RoadRunner Project and Scene System (RoadRunner).

    myProject="C:\users\MyProject"

    Open RoadRunner Viewer and specify your project folder.

    rrViewer = roadrunnerViewer(ProjectFolder=myProject);
    

    To add an image overlay, img, to the RoadRunner Viewer viewport, use addImageOverlay.

    img = addImageOverlay(rrViewer);

    To specify the image file to display, set the ImagePath property of img to the location of an image file in your project. The path you specify must be relative to the Assets folder in your project.

    img.ImagePath = "CustomFolder/myImage.png";
    

    To specify the position and size of the overlay, modify the Position and Size properties of img, respectively. The position and size values of the image overlay are relative to the size of the RoadRunner Viewer viewport, measured from the top-left corner.

    img.Position = [0.85 0.02];
    img.Size = [0.12 0.12];

    To update RoadRunner Viewer and view the changes to the overlay, use the drawnow function.

    drawnow(rrViewer)

    Version History

    Introduced in R2026b