VRML Data Types

Section Overview

VRML data types are used by VRML nodes to define objects and types of data that can appear in the VRML node fields and events.

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

VRML Field Data Types

The Simulink® 3D Animation™ product provides an interface between the MATLAB® and Simulink environment and VRML scenes. With this interface, you can set and get the VRML scene node field values. To work with these values, you must understand the relationship between VRML data types and the corresponding MATLAB data types. The following table illustrates the VRML 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.

VRML TypeDescriptionSimulink 3D Animation Type

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

Two-dimensional array represented 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.

char

SFNode

Container for a VRML node.

vrnode

MFFloat

Array of SFFloat values.

Single array (n-by-1)

MFInt32

Array of SFInt32 values.

int32 array (n-by-1)

MFVec2f

Array of SFVec2f values.

Single array (n-by-2)

MFVec3f

Array of SFvec3f values.

Single array (n-by-3)

MFColor

Array of SFColor values.

Single array (n-by-3)

MFRotation

Array of SFRotation values.

Single array (n-by-4)

MFString

Array of SFString values.

char array (n-by-1)

MFNode

Array of SFNode values.

vrnode

The Simulink 3D Animation software can work with various MATLAB data types, converting them if necessary:

  • The inputs for the setfield function (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 VRML types as necessary. The data types include logicals, signed and unsigned integers, singles, and doubles.

  • The getfield function (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 the Simulink 3D Animation vrsetpref function to define the data type support. Their names are as follows:

PropertyDescription

DataTypeBool

Specifies the boolean data type for vrnode/setfield and vrnode/getfield. Valid values are 'logical' and 'char'. If set to 'logical', the VRML boolean data type is returned as a logical value. If set to 'char', the VRML boolean data type is returned 'on' or 'off'.

DataTypeInt32

Specifies the int32 data type for vrnode/setfield and vrnode/getfield. Valid values are 'int32' and 'double'. If set to 'int32', the VRML int32 data type is returned as int32. If set to 'double', the VRML int32 data type is returned as 'double'.

DataTypeFloat

Specifies the float data type for vrnode/setfield and vrnode/getfield. Valid values are 'single' and 'double'. If set to 'single', the VRML float and color data types (the types of most VRML fields) are returned as 'single'. If set to 'double', the VRML float and color data types are returned as 'double'.

VRML Data Class Types

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

VRML Data ClassDescription

eventIn

An event that can be received by the node

eventOut

An event that can be sent by the node

field

A private node member, holding node data

exposedField

A public node member, holding node data

eventIn

Usually, eventIn events 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 corresponding eventIn.

Some nodes have eventIn events that do not correspond to any field of that node, but provide additional functionality for it. For example, the Transform node has an addChildren 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 VRML file. Generally, the field is private to the node and its value can be changed only if its node receives a corresponding eventIn. It is important to understand that the field itself cannot be changed on the fly by other nodes or via the external authoring interface.

You use this class type for fields that are not exposed and do not have the eventOut functionality.

exposedField

This is a powerful VRML data class that serves many purposes. You use this class type for fields that have both eventIn and eventOut functionality. The alternative name of the corresponding eventIn is always the field name with a set_ prefix. The name of the eventOut is always the field name with a _changed suffix.

The exposedField class defines how the corresponding eventIn and eventOut behave. For all exposedField classes, when an event occurs, the field value is changed, with a corresponding change to the scene appearance, and an eventOut is sent with the new field value. This allows the chaining of events through many nodes.

The exposedField class is accessible to scripts, whereas the field class is not.

Was this topic helpful?