主要内容

drawnow

R2026b

Update RoadRunner Viewer scene graph

Since R2026b

    Description

    drawnow(rrViewer) updates the RoadRunner Viewer scene graph by running all queued RoadRunner Viewer commands, such as drawing primitives and setting properties. If you add or modify 3D primitives or overlays and want to see the updates in the scene graph immediately, use this function. This function also blocks MATLAB® until RoadRunner Viewer processes all previously issued commands.

    example

    Examples

    collapse all

    Use a PrimitiveCollection object to draw a series of point primitives in RoadRunner Viewer, and then use drawnow to display the changes in the scene graph. This example assumes you have already added the folder containing the RoadRunner API to your MATLAB path. For information on getting started with RoadRunner Viewer, see Get Started with RoadRunner Viewer.

    Open RoadRunner Viewer and create a roadrunnerViewer object rrViewer.

    rrViewer = roadrunnerViewer;

    To draw 3D primitives, such as points, in the RoadRunner Viewer scene graph, use addPrimitive to create a PrimitiveCollection object, pc.

    pc = addPrimitive(rrViewer);

    Draw a row of red points along the x-axis of the scene graph. Use the drawPoints function and specify the primitive collection pc, the point locations pts, the point color, and the point size.

    pts = [0 0 0; 1 0 0; 2 0 0];
    drawPoints(pc,pts,[1 0 0],10);

    To update the scene graph and view the newly added primitives, use drawnow and specify the RoadRunner Viewer object rrViewer.

    drawnow(rrViewer)

    To cycle through three variations of point primitives, use a for loop and the drawnow function. In each iteration, the loop clears the points and redraws them in a different color specified by ptColors. Because you cannot modify a 3D primitive once you create it, use the reset function to clear the primitives in the PrimitiveCollection object pc. Then, use the drawPoints function to draw a new color variation of the point primitives.

    ptColors = [1 0 0; 0 1 0; 0 0 1];
    for i = 1:size(ptColors,1)
        reset(pc);
        drawPoints(pc, pts,ptColors(i,:),10);
        drawnow(rrViewer);
        pause(1);
    end

    Input Arguments

    collapse all

    RoadRunner Viewer object to update, specified as a roadrunnerViewer object.

    Version History

    Introduced in R2026b