Main Content

Virtual World Data Types

Nodes use VRML and X3D virtual world data types to define objects and the types of data that can appear in the node fields and events.

This section explains these field data types and data class types.

Field Data Types

The金宝app®3D Animation™product provides an interface between the MATLAB®and Simulink environment and virtual reality scenes. With this interface, you can set and get the scene node field values. Working with these values requires that you understand the relationship between virtual world data types and the corresponding MATLAB data types. The following table illustrates the virtual world data types and how they are converted to and from MATLAB types.

For a detailed description of the VRML fields, refer to the VRML97 Standard.

You can use MATLAB commands to read and save X3D files and to associate X3D files with Simulink models. For additional information about X3D support inSimulink 3D Animation, seeX3D Support.

For information about the supported X3D specification, seeISO/IEC 19775-1:2013. For information about supported X3D encoding, seeISO/IEC 19776-1.3:201xandISO/IEC 19776-2.3:201x.

VRML Type Description Simulink 3D AnimationType

SFBool

Boolean value true or false.

logical

SFFloat

32–bit, floating-point value.

single

SFInt32

32–bit, signed-integer value.

int32

SFTime

Absolute or relative time value.

double

SFVec2f

Vector of two floating-point values that you usually use for 2-D coordinates. For example, texture coordinates.

Single array (1-by-2)

SFVec3f

Vector of three floating-point values that you usually use for 3-D coordinates.

Single array (1-by-3)

SFColor

Vector of three floating-point values you use for RGB color specification.

Single array (1-by-3)

SFRotation

Vector of four floating-point values you use for specifying rotation coordinates (x,y,z) of an axis plus rotation angle around that axis.

Single array (1-by-4)

SFImage

二维数组代表resented by a sequence of floating-point numbers.

uint8 array (n-by-m-by-3)

SFString

String in UTF-8 encoding. Compatible with ASCII, allowing you to use Unicode®characters.

string

SFNode

Container for a node.

vrnode

MFFloat

Array ofSFFloatvalues.

Single array (n-by-1)

MFInt32

Array ofSFInt32values.

int32array (n-by-1)

MFVec2f

Array ofSFVec2fvalues.

Single array (n-by-2)

MFVec3f

Array ofSFvec3fvalues.

Single array (n-by-3)

MFColor

Array ofSFColorvalues.

Single array (n-by-3)

MFRotation

Array ofSFRotationvalues.

Single array (n-by-4)

MFString

Array ofSFStringvalues.

chararray (n-by-1)

MFNode

Array ofSFNodevalues.

vrnode

TheSimulink 3D Animationsoftware can work with various MATLAB data types, converting them if necessary:

  • The inputs for thesetfieldfunction (and its dot notation form) and VR Sink and VR Source blocks, accept all meaningful data types on input. Both convert the data types into natural virtual world types as necessary. The data types include logicals, signed and unsigned integers, singles, and doubles.

  • Thegetfieldfunction and its dot notation form return their natural data types according to the table above.

To ensure backward compatibility with existing models and applications, use theSimulink 3D Animationvrsetpreffunction to define the data type support. Their names are as follows:

Property Description

DataTypeBool

Specifies thebooleandata type forvrnode/setfieldandvrnode/getfield. Valid values are'logical'and'char'. If set to'logical', the virtual worldbooleandata type is returned as a logical value. If set to'char', the virtual worldbooleandata type is returned'on'or'off'.

DataTypeInt32

Specifies theint32data type forvrnode/setfieldandvrnode/getfield. Valid values are'int32'and'double'. If set to'int32', the virtual worldint32data type is returned asint32. If set to'double', the virtual worldint32data type is returned as'double'.

DataTypeFloat

Specifies thefloatdata type forvrnode/setfieldandvrnode/getfield. Valid values are'single'and'double'. If set to'single', the virtual worldfloatandcolordata types (the types of most virtual world fields) are returned as'single'. If set to'double', the virtual worldfloatandcolordata types are returned as'double'.

Virtual World Data Class Types

A node can contain four classes of data:field,exposedField,eventIn, andeventOut. These classes define the behavior of the nodes, how nodes are stored in memory, and how they can interact with other nodes and external objects.

VRML Data Class Description

eventIn

An event that the node can receive

eventOut

An event that the node can send

field

A private node member, holding node data

exposedField

A public node member, holding node data

eventIn

Usually,eventInevents correspond to a field in the node. Node fields are not accessible from outside the node. The only way you can change them is by having a correspondingeventIn.

Some nodes haveeventInevents that do not correspond to any field of that node, but provide additional functionality for it. For example, theTransformnode has anaddChildren eventIn. When this event is received, the child nodes that are passed are added to the list of children of a given transform.

You use this class type for fields that are exposed to other objects.

eventOut

This event is sent whenever the value of a corresponding node field that allows sending events changes its value.

You use this class type for fields that have this functionality.

field

A field can be set to a particular value in the virtual world 3D file. Generally, the field is private to the node and its value can be changed only if its node receives a correspondingeventIn. It is important to understand that other nodes or the external authoring interface cannot change the field.

You use this class type for fields that are not exposed and do not have theeventOutfunctionality.

exposedField

This powerful data class serves many purposes. You use this class type for fields that have botheventInandeventOutfunctionality. The alternative name of the correspondingeventInis always the field name with aset_prefix. The name of theeventOutis always the field name with a_changedsuffix.

TheexposedFieldclass defines how the correspondingeventInandeventOutbehave. For allexposedFieldclasses, when an event occurs, the field value is changed, with a corresponding change to the scene appearance, and aneventOutis sent with the new field value. These changes allow the chaining of events through many nodes.

TheexposedFieldclass is accessible to scripts, whereas thefieldclass is not.

Related Topics