Main Content

Aero.VirtualRealityAnimation Class

Namespace: Aero

Visualize aerospace animation using virtual reality animation object

Description

Aero.VirtualRealityAnimation objects visualize flight data using a virtual reality animation object.

The Aero.VirtualRealityAnimation class is a handle class.

Class Attributes

GetAccess
public
SetAccess
private
Dependent
true
Transient
true
Hidden
true
SetObservable
true
NonCopyable
true

For information on class attributes, see Class Attributes.

Creation

Description

example

h = Aero.VirtualRealityAnimation constructs a virtual reality animation object. The animation object is returned to h.

Properties

expand all

Animation object name, specified as a character vector or string.

Attributes:

Transient
true
SetObservable
true

Data Types: char | string

vrworld object associated with the animation object, specified as an array.

Attributes:

Transient
true
SetObservable
true

vrworld file name, specified as a character vector or string.

Attributes:

Transient
true
SetObservable
true

Data Types: char | string

Old vrworld file name, specified as an array.

Attributes:

Transient
true
SetObservable
true

Data Types: char | string

Temporary vrworld file name, specified as a character vector or string.

Attributes:

Transient
true
SetObservable
true

Data Types: char | string

vrfigure object associated with the animation object, specified as an array.

Attributes:

Transient
true
SetObservable
true

Nodes contained in animation object, specified as an array.

Attributes:

Transient
true
SetObservable
true

Viewpoints contained in animation object, specified as an array.

Attributes:

Transient
true
SetObservable
true

Current time, specified as a scalar, in seconds.

Time source must be a timeseries or timetable object.

Attributes:

Transient
true
SetObservable
true

Data Types: dobule

Save warning display setting, specified as a 0 or 1.

Attributes:

Transient
true
SetObservable
true

Enable video recording, specified as:

  • 'off'

    Disable video recording.

  • 'on'

    Enable video recording.

  • 'scheduled'

    Schedule video recording. Use this property with the VideoTStart and VideoTFinal properties.

Attributes:

Transient
true
SetObservable
true

Video recording file name, specified as a character vector or string.

Attributes:

Transient
true
SetObservable
true

Data Types: char | string

Video recording compression file type, specified as:

  • 'Motion JPEG AVI'

    Compressed AVI format file using Motion JPEG codec.

  • 'Archival'

    Motion JPEG 2000 format file with lossless compression.

  • 'Motion JPEG 2000'

    Compressed Motion JPEG 2000 format file.

  • 'MPEG-4'

    Compressed MPEG-4 format file with H.264 encoding (Windows® 7 systems only).

  • 'Uncompressed AVI'

    Uncompressed AVI format file with RGB24 video.

For more information on video compression, see VideoWriter.

Attributes:

Transient
true
SetObservable
true

Video recording quality, specified as a value between 0 and 100.

Attributes:

Transient
true
SetObservable
true

Data Types: double

Video recording start time for scheduled recording, specified as a value between TStart and TFinal.

Attributes:

Transient
true
SetObservable
true

Data Types: double

Video recording stop time for scheduled recording, specified as a value between TStart and TFinal.

Attributes:

Transient
true
SetObservable
true

Data Types: double

Time scaling, specified as a scalar, in seconds.

Attributes:

Transient
true
SetObservable
true

Data Types: double

Frame rate, specified as a scalar, in frames per second.

Attributes:

Transient
true
SetObservable
true

Data Types: double

Recording start time, specified as a scalar, in seconds.

Time source must be a timeseries or timetable object.

Attributes:

Transient
true
SetObservable
true

Data Types: double

Recording stop time, specified as a scalar, in seconds.

Time source must be a timeseries or timetable object.

Attributes:

Transient
true
SetObservable
true

Data Types: double

Methods

expand all

Examples

collapse all

This example shows how to

  • Record the simulation of a virtual reality animation object

  • Simulate and record flight data

  • Create an animation object

h = Aero.VirtualRealityAnimation;

% Control the frame display rate.

h.FramesPerSecond = 10;

% Configure the animation object to set the seconds of animation data per
% second time scaling (TimeScaling) property.

h.TimeScaling = 5;

% The combination of FramesPerSecond and TimeScaling property determine the
% time step of the simulation. These settings result in a time step of
% approximately 0.5 s.
% This code sets the .wrl file to use in the virtual reality animation.

h.VRWorldFilename = 'asttkoff.wrl';

% Load the animation world described in the 'VRWorldFilename' field of the
% animation object.

initialize(h);

% Set simulation timeseries data. takeoffData.mat contains logged simulated
% data. takeoffData is set up as a 'StructureWithTime', which is one of the
% default data formats.

load takeoffData
[~, idxPlane] = find(strcmp('Plane', h.nodeInfo));
h.Nodes{idxPlane}.TimeseriesSource = takeoffData;
h.Nodes{idxPlane}.TimeseriesSourceType = 'StructureWithTime';

% Use the example custom function vranimCustomTransform to correctly line
% up the position and rotation data with the surrounding objects in the
% virtual world. This code sets the coordinate transformation function for
% the virtual reality animation.

h.Nodes{idxPlane}.CoordTransformFcn = @vranimCustomTransform;

% Set up recording properties.

h.VideoRecord = 'on';
h.VideoQuality = 50;
h.VideoCompression = 'Motion JPEG AVI';
h.VideoFilename = 'astMotion_JPEG_VR';

% Play the animation.

play(h);

% Wait for the animation to stop running before modifying the object.

wait(h);

% Verify that a file named astMotion_JPEG_VR.avi was created in the current folder.
% Disable recording to preserve the file.

h.VideoRecord = 'off';

Simulate flight data for four seconds.

Use the data to create an animation object.

h = Aero.Animation;

Control the frame display rate.

h.FramesPerSecond = 10;

Configure the animation object to set the seconds of animation data per second time-scaling (TimeScaling) property.

h.TimeScaling = 5;

The combination of the FramesPerSecond and TimeScaling properties determines the time step of the simulation (TimeScaling/|FramesPerSecond|). These settings result in a time step of approximately 0.5 s.

Create and load a body for the animation object.

idx1 = createBody(h,'pa24-250_orange.ac','Ac3d');

Load simulated flight trajectory data (simdata).

load simdata;

Set the time series data for the body.

h.Bodies{1}.TimeSeriesSource = simdata;

Create a figure object for the animation object.

show(h);

Set up recording properties.

h.VideoRecord='on';
h.VideoQuality = 50;
h.VideoCompression = 'Motion JPEG AVI';
h.VideoFilename = 'astMotion_JPEG';

Play the animation from TStart to TFinal.

h.TSTart = 1;
h.TFinal = 5;
play(h);

Verify that a file named astMotion_JPEG.avi was created in the current folder. When you rerun the recording, notice that the play time is shorter than that in the previous example when you record for the length of the simulation time.

Wait

Wait for the animation to stop playing before the modifying the object.

wait(h);

Disable recording to preserve the file.

h.VideoRecord = 'off';

This example shows how to schedule a three second recording a virtual reality object animation simulation.

% Create an animation object.
h = Aero.VirtualRealityAnimation;

% Control the frame display rate.
h.FramesPerSecond = 10;

% Configure the animation object to set the seconds of animation data per
% second time scaling (TimeScaling) property.
h.TimeScaling = 5;

% The combination of FramesPerSecond and TimeScaling properties determines
% the time step of the simulation. These settings result in a time step of
% approximately 0.5 s.
% This code sets the .wrl file to use in the virtual reality animation.

h.VRWorldFilename = 'asttkoff.wrl';

% Load the animation world described in the 'VRWorldFilename' field of the
% animation object.
h.initialize();

% Set simulation timeseries data. takeoffData.mat contains logged
% simulated data. takeoffData is set up as a 'StructureWithTime', which is
% one of the default data formats.
load takeoffData
[~, idxPlane] = find(strcmp('Plane', h.nodeInfo));
h.Nodes{idxPlane}.TimeseriesSource = takeoffData;
h.Nodes{idxPlane}.TimeseriesSourceType = 'StructureWithTime';

% Use the example custom function vranimCustomTransform to correctly line
% up the position and rotation data with the surrounding objects in the
% virtual world. This code sets the coordinate transformation function for
% the virtual reality animation.
h.Nodes{idxPlane}.CoordTransformFcn = @vranimCustomTransform;

% Set up recording properties.
h.VideoQuality = 50;
h.VideoCompression = 'Motion JPEG AVI';
h.VideoFilename = 'astMotion_JPEG';

% Set up simulation time from TFinal to TStart.
h.TSTart = 1;
h.TFinal = 5;

% Set up to record between two and four seconds of the four second
% simulation.
h.VideoRecord='scheduled';
h.VideoTSTart = 2;
h.VideoTFinal = 4;

% Play the animation.
h.play();

% Wait for the animation to stop running before modifying the object.

h.wait();

% Verify that a file named astMotion_JPEG_VR.avi was created in the
% current folder. When you rerun the recording, notice that the play time
% is faster than when you record for the length of the simulation time.
% Disable recording to preserve the file.
h.VideoRecord = 'off';

Limitations

The Aero.VirtualRealityAnimation object is not supported in MATLAB Online.

Version History

Introduced in R2007b