Documentation Center

  • Trial Software
  • Product Updates

Using CAD Models with the Simulink 3D Animation Product

Section Overview

When you work with models of dynamic systems, it is often necessary to visualize them in a three-dimensional virtual reality environment. As most of the 3D designs in companies are created using CAD tools, users need to be able to convert these designs into forms that can be used with Simulink® or SimMechanics™ models and applications based on the MATLAB® software.

This section describes how to adapt existing CAD designs for visualization using the Simulink 3D Animation™ software.

This section assumes that the reader has a moderate knowledge of the Simulink 3D Animation product. For VRML-specific information, such as the description of VRML nodes and their fields, refer to the VRML97 standard.

Import STL and Physical Modeling XML Files Directly into a VRML Virtual World

CAD models frequently use STL (STereoLithography) format files or Physical Modeling XML files.

You can use the 3D World Editor to import STL and Physical Modeling XML files directly into a VRML scene. You can integrate content from those files into a virtual world, converting the structure into VRML.

To import an STL or Physical Modeling XML file:

  1. In the 3D World Editor, select the Root node or an MFNode node (usually the children node of a Transform or Group node).

  2. From the Nodes > Import From menu item, select either STL File or Physical Modeling XML File.

      Tip   Alternatively, you can right-click the Root node or an MFNode node and use the Import From menu item. However, to insert the new node in the middle of a node list, after the selected node (both at the main level or inside a MFNode node, use the Nodes > Import From menu path.

      Note:   To import a Physical Modeling XML file, the target folder must be writable.

Alternatively, you can use the stl2vrml function.


Importing an STL file creates a Transform node containing a Shape node with IndexedFaceSet geometry that represents the original STL shape. The new Transform is created either at the main level of the scene hierarchy (at the end of the file), or as a child of a selected grouping node.

Importing a Physical Modeling XML file creates an individual VRML file for each STL file that is referenced from that XML file. The created VRML files are stored in the folder where the edited VRML file is located.

In the edited VRML file, the newly created Transform contains hierarchical structure Transforms that correspond to the structure of objects described in the XML file. Individual VRML shape files in this structure are referenced using Inline nodes.

    Note:   When importing a Physical Modeling XML file into a new, unsaved VRML model, children VRML files are created in the current working folder. If you save the file into a different folder, move the referenced VRML files to the new location.

Import VRML Models from CAD Tools

To import VRML models from CAD tools, you first convert your product assembly model into the VRML format used by the Simulink 3D Animation software. Most CAD tools have VRML export filters, but there are conversion utilities available from third parties if the export filter is not directly available in the CAD tool.

When exporting CAD models into the VRML format, several options can be set to customize the output. These include options specific to the export filters or are general CAD file properties (consult your CAD system documentation for specific details on how to set these properties). The most typical and useful properties are the following:

VRML Format Type

There are two major versions of the VRML format used by graphic tools: the older format, called VRML1, and the newer format, called VRML2 (or more often VRML97, according to the adoption year of the ISO® standard). The Simulink 3D Animation software uses VRML97, so select VRML97 as the export format.

If your CAD tool allows only VRML1 export, you can use the Ligos® V-Realm Builder application, a native VRML scene editor supplied with the Simulink 3D Animation software, to convert models from VRML1 to VRML97. Simply open a VRML1 file and resave it in V-Realm so that the file is automatically saved in the VRML97 format.

    Note:   All references to the general abbreviation, VRML, refer to the VRML97 standard.

Level of Detail Considerations

CAD models are usually parametric models that use proprietary object rendering methods for use in various contexts. During VRML model export, the internal parametric model of the assembly is tessellated. In this process, the model surface is divided into triangular meshes, represented in VRML by the IndexedFaceSet nodes. During tesselation, it is important to set the granularity of the mesh so that it is suitable for further use. Modifying the polygon count afterwards would not only be very difficult, but also not practical, as the resolution independent information of the object shape and structure is lost and cannot be reconstructed based on the tessellated model.

For the effective rendering of moving parts, VRML models should be as simple as possible. However, usually little, if any, visible model degradation is desired. It is often just an issue of finding the appropriate compromise between these two requirements.

As there are significant performance differences among various computers and graphic accelerators, there is no firm recommendation for the number of polygons or triangles suitable for use with the Simulink 3D Animation product. To assess the model's complexity, you can display the resulting VRML file in the Simulink 3D Animation viewer and observe the viewer response to navigation. If you can navigate the virtual world without any significant delays, the model is usually suitable for further work. If you connect the virtual world to a Simulink model, you have access to more precise measures of suitability, such as the number of frames rendered per second during simulation.

Units Used in Exported Files

VRML length units are meters. To scale exported parts correctly in the virtual world, export the parts using meters. If the exported objects are very small or very large, you may want to create your virtual world in some other scale. In this case, you should export the objects using units other than meters.

VRML viewers are made to measure using dimensions that are comparable to the dimensions of people, to achieve the immersion effect of virtual reality. Viewers assume that the author prepared the scene so that it can be walked through or examined by a virtual visitor to the scene (sometimes called the Avatar), whose physical dimensions are used in calculations for purposes like collision detection, near-object clipping, or terrain following. You can customize avatar dimensions (and also other navigation-specific parameters such as default navigation speed) using the NavigationInfo VRML node. The Simulink 3D Animation viewer enables effective navigation in the virtual world, including scaled scenes (e.g., inspecting miniature objects or visualizing a large-scale aircraft operation in space). For such navigation to be successful, the scene's author must define the NavigationInfo parameters correctly.

Coordinate System Used

VRML uses a Cartesian coordinate system with axes defined so that:

  • +x points right

  • +y points up

  • +z points out of the screen

To avoid transforming object axes into the VRML system later on, export CAD models using an identical coordinate system whenever possible. If your CAD tool uses a different coordinate system, and it does not allow you to change it for the exported objects, make sure to note the difference between the systems so that you can implement axes transformations in your model later.

Also, make a note of the orientation of the parts in the coordinate system. For instance, if a vehicle model is exported so that it points towards the +x axis on a road in the virtual world, then the road should also point towards the +x direction, and the model of vehicle dynamics should also use the x coordinate.

When the CAD tool allows you to animate parts and assemblies, reset their positions to the initial state before the export.

Assembly Hierarchy

How assembly of parts are exported depends on the structure of the model, which usually comes in two forms:

  • All parts are independent from each other, or objects in the scene are independent from each other at the same level of the scene hierarchy. The exported VRML file has a flat structure, with all part coordinates defined in global coordinates.

  • Parts follow some kind of hierarchy defined in the CAD tool. The exported VRML file will use this hierarchy via the VRML Transform-children mechanism, to create a nested structure. In this case, part coordinates are usually defined in the part's parent local coordinate system.

    For example, a robot can be exported with the following object hierarchy, in which each part's coordinates are defined in the parent's local coordinate system:

    rotating support — arm — wrist — hand — tool

    So when the rotating support moves, all other parts are usually designed to move with it.

The hierarchy of the VRML file must correspond to the coordinates used in the dynamic model of the assembly as follows:

  • If all parts in the Simulink or SimMechanics model are defined in global coordinates, use a flat virtual world structure.

  • If all parts in the Simulink or SimMechanics model follow hierarchical relationships, use a nested virtual world structure.

To illustrate these two cases, imagine a rotating pendulum according to the following figure. The gray arm rotates about the vertical axis, while the orange pendulum swings about the z axis in the rotating gray arm's local coordinates.

If the pendulum dynamics model uses global coordinates for all moving parts, the VRML model has a flat structure as shown in the following figure.

If the pendulum dynamics model uses local coordinates for moving parts, the corresponding VRML model has a nested structure, as shown in the following figure.

Some third-party tools allow you to export each part of the assembly into separate VRML files. All parts are then referenced in one main file using the VRML Inline mechanism. Referencing in this manner is the recommended way to work with assemblies, as the main file is small in size and easy to understand and modify.

CAD Virtual World Modeling

You can use the 3D World Editor or other editor to manually modify the results of CAD tool export filters (for example, composing the converted model into an urban or manufacturing environment, or adding objects such as viewpoints, backgrounds, and lights) before using them in Simulink 3D Animation virtual worlds. Typically, adjusting exported files manually in an editor requires the following changes:

Wrap Shape Objects with Transforms

CAD tools export parts into VRML as individual shapes using various VRML object types (e.g., a VRML Shape node or the Inline mechanism). To control part positions and orientations, you need to wrap each such Shape or Inline node with a node that allows for the changing of these properties. This wrapping node is the Transform node, whose purpose is to transform the coordinates of its children. For instance, after wrapping with a Transform node, an Inline node may have the following syntax:

Transform {
     children [
          Inline {
               url ["robot_arm1.wrl"]

To set the initial location of the entire assembly in the virtual world, it is a good practice to wrap all parts of the assembly with an additional Transform node.

Add DEF Names

CAD export filters often export objects with no names or with synthetic nondescriptive names. To be accessible from MATLAB interface, each VRML object needs to be given a unique name in the VRML file. You name the object by adding a DEF Object_Name statement to the Transform line. After adding the DEF Object_Name, the Robot_Arm1 definition in the main VRML file has the following syntax:

DEF Robot_Arm1 Transform {
     children [
          Inline {
               url ["robot_arm1.wrl"]

These object names are used in the Simulink 3D Animation functions and in the user interface such as the descriptions of inputs to the VR Sink block. Therefore, it is good practice to give the parts descriptive names to help you manage the orientation in the object hierarchy.

    Note:   Sometimes it is necessary to correct bugs introduced in the file by the CAD tool export filter. As the VRML format is a text-based format codified by an ISO standard, these bugs are relatively easy to identify and correct. If problems occur when you are using exported VRML files in the Simulink 3D Animation software, consult technical support.

Creating a Virtual World

The VRML file, adjusted manually in the previous steps, is now ready for association with Simulink or SimMechanics models. To work with the virtual world effectively, however, you may want to make additional modifications to the scene file. These changes can be added on an ongoing basis, in parallel with developing and using the dynamic model.

These modifications can be done using a text editor, V-Realm, or any other VRML editor:

  1. Add the WorldInfo node with a scene title (used as the virtual world description in the Simulink 3D Animation software).

  2. Add the NavigationInfo node defining the scene default navigation speed and avatar size that ensures correct display of the object from near and far distances.

  3. Add the Background node to specify a color backdrop that simulates the ground and sky, as well as optional background textures, such as panoramas for the scene.

  4. Add several viewpoints to be able to observe the object conveniently from different positions. The viewpoints can be static (defined as independent objects at the top level of the scene hierarchy) or attached to objects that move in the scene for observation during simulation. Such viewpoints are defined as siblings of moving objects in the scene hierarchy. For an example of a viewpoint moving with the object, see the viewpoint Ride on the Plane in the Simulink 3D Animation vrtkoff.wrl example.

  5. Add lights to the scene in order to illuminate it. Although VRML viewers always have a "headlight" available, it is good practice to define lights in the scene so that it looks the same for every user, according to the scene author's preferences. The most useful type of VRML light to illuminate a whole scene is the DirectionalLight node. It is often practical to use a combination of several such lights to illuminate objects from several directions.

  6. Add scene surroundings. This step is not crucial for the visualization of interactions between parts in a machine assembly, but is very important for the visualization of simulations, such as those for aircraft and vehicle dynamics, where the position of one object relative to the scene in which it operates is important.

    For example, if you want to visualize vehicle dynamics, you would place a virtual car on a virtual road. Both objects need to be to scale (the length units in the car and road models must match), and the car must be placed in an appropriate position relative to the road. You achieve proper car scaling, placement, and orientation in the scene by defining corresponding fields of the main object's Transform node mentioned in Wrap Shape Objects with Transforms.

For an example of a complete scene definition, see the octavia_scene.wrl VRML file that belongs to the Simulink 3D Animation vr_octavia example.

Link to CAD Virtual Worlds

The purpose of this step is to create associations between dynamic model object quantities and corresponding VRML object properties (positions, rotations, etc.) to establish a live data connection between the model and the virtual world.

Mechanical systems are typically modeled using SimMechanics or Simulink, but the Simulink 3D Animation product allows for the visualization of models implemented in MATLAB. The following section describes the specifics of using the MATLAB interface.

Linking the Virtual World to a Simulink Model

You associate Simulink model signals to virtual world object properties through the VR Sink block from the Simulink 3D Animation block library, vrlib.

To associate a Simulink signal to a virtual object property:

  1. From the vrlib library, insert a VR Sink block into your Simulink model.

  2. Double-click the VR Sink block to open the block parameters dialog, where you can define the virtual world. Enter the name of the scene's VRML file in Source file, or click Browse to select the file interactively. Click Apply to load the selected VRML scene.

  3. For smooth visualization of the movement, it is sometimes necessary to change the block's Sample time. For example, to update the virtual world 25 times per simulation second, set the Sample time to 0.04. Be careful when using the inherited sample time for the VR Sink block. Depending on the solver used, using inherited sample time might result in nonequidistant (in simulation time) updating of the virtual world, giving the user a false impression of system dynamics.

  4. In VRML Tree in the right side of the dialog box, expand the main object's Transform branch, and, in the scene object hierarchy, locate all parts you want to control from Simulink according to their names as given in Add DEF Names. Each part is represented by named Transform nodes, and you select the check box next to its rotation and position fields. These selections tell the VR Sink block that you want to control the rotation and position of these parts. You can also select other properties of virtual world objects, such as color, but rotations and positions are the ones most frequently controlled.

  5. Click OK. For each selected field, the VR Sink block creates an input port. Increase the VR Sink block size as appropriate to the number of input ports.

After the VR Sink block is associated with a virtual world, you can double-click it to open the Simulink 3D Animation viewer. Block parameters are available through the menu Simulation > Block Properties in the viewer.

VR Sink inputs take signals of the type corresponding to their VRML representation. Position inputs are of type SFVec3f, which is the position represented in [x y z] coordinates. Rotation inputs are of type SFRotation, the four-element vector defining rotation as [axis angle], using the coordinate system described in Coordinate System Used, where the angle value is in radians.

The user has to match the coordinate system used by the Simulink model to that of the virtual world. If the two systems are not identical, some kind of axes transformation is necessary.

While object positions are usually available in the form required by VRML (Cartesian coordinates), rotations usually have to be converted from some other representation. In many cases, object rotations are defined using the rotation matrix representation. For converting such rotations into the VRML format, use the Rotation Matrix to VRML Rotation block found in the Utilities sublibrary of vrlib.

The objects' positions and rotations are treated differently depending on the virtual world hierarchy:

  • When all parts in a Simulink model are defined in global coordinates, and the virtual world has a flat structure of independent objects, use the following positions and rotations.

    Object positionsSend to VR Sink all positions in global coordinates.
    Object rotationsSend to VR Sink all rotations in global coordinates, with center of rotation defined as the coordinate system origin. (As the default center of rotation of VRML Transform objects is [0 0 0], it is usually not necessary to define it for each part in the VRML file.

  • When all parts in Simulink model follow hierarchical relations, and the virtual world has a nested structure, use the following positions and rotations.

    Object positionsSend to VR Sink all positions in local coordinates (relative to their parents or predecessors in the object hierarchy). For example, send the robot's tool position relative to the robot's hand.
    Object rotations

    Send to VR Sink all rotations in local coordinates (relative to their parents or predecessors in the object hierarchy). For example, send the robot's tool rotation relative to the robot's hand.

    To visually match the positions of joints between objects, it is usually necessary to coincide the center of rotation defined in the virtual world with the center of rotation defined in the Simulink model, as joints between parts are usually positioned not in the origin, [0 0 0], of the parent's coordinate system.

    To define a center of rotation different from the default value, [0 0 0], define the center field of the child's Transform node in the VRML file. For example, define the robot's tool center of rotation to coincide with the joint connecting the hand and the tool in the hand's local coordinates.

In a hierarchical scene structure, when the parts are connected by revolving joints, it is easy to define the relative rotations between parts. The joint axis directly defines the VRML rotation axis, so constructing the [axis angle] four-element VRML rotation vector is trivial.

Initial Conditions

A Simulink model's initial conditions must correspond to the initial object's positions and rotations defined in the virtual world. Otherwise, the object controlled from Simulink would "jump" from the position defined in the VRML file to the position dictated by the Simulink software at the start of the simulation. You can compensate for this offset either in the VRML file (by defining an another level of nested Transform around the controlled object) or in the Simulink model by adding the object's initial position to the model calculations before sending to the VR Sink block.

You should align the Simulink model's initial conditions with the virtual world's object positions, while maintaining the correct position of the object relative to the surrounding scene. To do so, you may need to adjust the position of the object's surroundings (e.g., move the road position so that the car at position [0 0 0] stays on the road, with the wheels neither sinking nor floating above the road surface).

Use of VR Placeholder and VR Signal Expander

The VR Sink block accepts only inputs that define fully qualified VRML field values. Dynamic models that describe the system behavior in only one dimension still require full 3D positions for all controlled objects for their virtual reality visualization.

To simplify the modeling in such cases, you can use the VR Placeholder and VR Expander blocks of the Simulink 3D Animation library.

The VR Placeholder block sends out a special value that is interpreted as "unspecified" by the VR Sink block. When this placeholder value appears on a VR Sink input, whether as a single value or as an element of a vector, the appropriate value in the virtual world remains unchanged.

The VR Signal Expander block creates a vector of predefined length, using some values from the input ports and filling the rest with placeholder signal values.

To control the position of a virtual object in a one-dimensional dynamic model, use the VR Signal Expander block with the controlled dimension as its input. For its output use a three-component vector in the VR Sink block. The remaining vector elements are filled with placeholder signals.

Use of the VR Signal Expander block is also a possibility when defining rotations. When the axis of rotation (as a part of the initial rotation of an object Transform node) is defined in the VRML file, it is possible to send to the VR Sink block a VRML rotation value consisting of three placeholder signals and the computed angle, forming a valid four-element [axis angle] vector.

SimMechanics Models

You can use the Simulink 3D Animation product to view the behavior of a model created with the SimMechanics software. First, you build a model of a machine in the Simulink interface using SimMechanics blocks. Then, create a detailed picture of your machine in a virtual world, connect this world to the SimMechanics body sensor outputs, and view the behavior of the bodies in a VRML viewer.

The SimMechanics software is very well suited for 3D visualizations using the Simulink 3D Animation product. Apart from features that SimMechanics product offers for modeling mechanical assemblies, the following features simplify the visualization of SimMechanics models in virtual reality:

  • SimMechanics and VRML coordinate systems are identical.

  • In the SimMechanics software, you can work with both global and local object coordinates, so it is easy to adapt the model to the structure of the virtual world exported from the CAD tool.

The SimMechanics product also offers a convenient way of importing CAD assembly designs into SimMechanics machines through the SimMechanics Link interface. Alternatively, when you export a CAD assembly to the VRML format, the additional steps described in this section can add virtual reality visualization to such assemblies.

The Simulink 3D Animation software includes the following functions for working with SimMechanics files: vrcadcleanup, vrphysmod, and stl2vrml.

Link to a SimMechanics Model

Depending on the virtual world hierarchy, you can use one of two methods to help visualize SimMechanics machines:

  • When the virtual world has a flat structure of independent objects, you can obtain the positions and rotations of machine parts using Body Sensor blocks connected to appropriate coordinate systems attached to the bodies, with positions and rotations defined using global coordinates. In most cases, it is appropriate to connect the sensor to a body coordinate system with origin at [0 0 0] and with an initial rotation matrix defined as the identity matrix, [1 0 0; 0 1 0, 0 0 1], in the global coordinate.

  • When the virtual world has a hierarchical structure of nested objects, the body positions and rotations can be obtained using Body Sensor blocks with output set to use local body coordinates. In some special cases (e.g., when two bodies are connected through a revolving joint), it is possible to get the angle between the objects using a Joint Sensor block.

Linking the Virtual World to a MATLAB Model

For interacting with virtual worlds, the Simulink 3D Animation product also offers a set of MATLAB functions and constructs referred to collectively as its "MATLAB interface." Circumstances when this MATLAB functionality is appropriate for use with CAD-based designs may include:

  • Using customized GUIs to visualize static objects and their relations in a virtual environment, such as in interactive machine assembly instructions.

  • Visualizing 3D information based on an independent quantity (not necessarily time).

  • Using MATLAB interface functions in Simulink model callbacks.

  • Visualizing systems whose dynamic models are available as MATLAB code.

  • Visualizing systems where massive object changes, such as deformations, are taking place. In this case, you must send dynamically-sized matrix-type data from the dynamic models to virtual worlds, which is not possible using just Simulink signals.

For information on setting object properties using the MATLAB interface, see MATLAB Interaction.

Import VRML Models from CATIA Software

This topic describes how to use CAD designs created in the CATIA® product to create Simulink 3D Animation VRML scenes. CATIA models are hierarchical trees comprised of products that contain parts.

To export CATIA parts or products to the VRML format, in the CATIA dialog box, select File > Save as and select VRML in the Save as type list.

When exporting products, the CATIA software creates one compound VRML file that contains all the parts of the product.

Occasionally, you might need to export each part of the assembly hierarchy into a separate VRML file. You can do this in the CATIA environment as follows:

  1. Save each part individually to a separate VRML file.

  2. Create the main model VRML file manually, with Inline references to the part files.

CATIA Coordinate Systems

The CATIA software also exports background color and viewpoints. The software exports individual parts without these properties.

By default, the CATIA software uses right-handed Cartesian coordinate system identical to the MATLAB coordinate system (VRML Coordinate System). Account for the coordinate system when you export objects from the CATIA environment into VRML virtual worlds and/or manipulate them using the Simulink 3D Animation software.

You can also define a different coordinate system. To do this, create an axis system within the current geometrical set. Doing so sets this new system as a reference system that you can use to export the VRML virtual world. Consider creating such an axis system so that it corresponds to the VRML coordinate system. This makes all the coordinates and orientations of objects compatible with other objects you combine into VRML virtual worlds.

Settings that Affect the VRML Output

In the CATIA environment, the properties that affect the VRML output are available in two options dialog boxes:

  • Display Performances dialog box

  • VRML Compatibility dialog box

Level of Detail

The level of detail of the exported VRML file (accuracy of the tessellation mesh of objects) corresponds to the setting of CATIA general visualization mesh. In the CATIA menu, select Tools > Options > General > Display > Performances. In the resulting dialog, select the 3D Accuracy options to control the visualization mesh detail.

You can achieve best results by using the proportional method of tessellation (arcs are substituted by line segments based on their relative, not absolute, accuracy). This method works for models regardless their dimensions. For maximum accuracy of the exported VRML model, set the slider at the rightmost position. If the resulting file is too complex to be handled effectively with VRML rendering tools, experiment with this accuracy setting. You want to find the setting that gives you the smallest possible VRML model, but it must still be visually acceptable.

VRML Export Filter Settings

The CATIA software enables you to tune some VRML export options. These are available in the Tools > Options > General > Compatibility > VRML:

  • Select VRML97 as the export format

    The Simulink 3D Animation software uses VRML97 standard format.

  • Select the Save normals check box

    This option affects whether or not to export explicit face normals definitions.

  • Clear the Save edges check box

    Clear this check box for optimum performance. Selecting this check box directs the CATIA software to also export object edges (in the form of IndexedLineSets).

  • Select the appropriate Save textures check boxes to the desired settings

    In particular, if you want to save textures, select the Save textures in external files option. This option generates external JPG files for object textures.

  • Select the VRML model background color

    This option applies only to exporting products.

Structure of VRML Models Exported from the CATIA Environment

The CATIA software exports CATProducts and their CATParts as VRML transforms. The structure of these transforms corresponds to the CATIA model hierarchy. In addition to transforms that represent physical elements, the CATIA software creates several transforms and groups in the VRML file to represent relationships between objects and other model properties defined in the CATIA environment.

Some of these additional nodes can be empty. Many CATIA model properties do not have equivalents in the VRML language. Each part transform contains a hierarchy of nested transforms, groups and shapes that correspond to the part internal structure. Some of these elements have synthetic DEF names (for example, _0161DC70). For the most part, you will only need to work with the main transforms that represent each part.

The following contains the VRML model of a cylinder assembly consisting of four parts:

The left tree view illustrates the overall structure of the model.

  1. The CATIA software saves the general model information in the WorldInfo, NavigationInfo, and Background nodes.

  2. The software exports the default CATIA viewpoints (it does not export user-defined viewpoints).

Following this section, common to all products exported to VRML, is a top-level transform node representing the CATProduct.

In the CATIA software, Product CylinderAssembly1 consists of four parts:

  • CrankAssembly1

  • CylinderSleeve1

  • PistonAssembly1

  • CrankshaftAssembly1

The export does not preserve the CATProduct and CATPart names. You can identify these objects in the VRML file in the tree view and in the text mode. In the figure, the contents of the part transforms are collapsed so that only the top-level objects are visible for clarity. After four transforms representing CATParts, the export adds an empty Group node at the place where CATIA Constraints are defined. You can delete such empty nodes from the VRML model.

The contents of the CATProduct are scaled down by a factor of 1000 (conversion of units from millimeters to meters).

When you have VRML files created with the CATIA software, take into account the following known features for further use with the Simulink 3D Animation software:

  • Object - Exporting to VRML does not preserve CATProduct and CATPart names. The CATIA environment only creates synthetic VRML DEF names for sub-parts, materials, and object coordinate fields. These synthetic names change between two or more consecutive export operations.

    To work with the Simulink 3D Animation software, provide meaningful DEF names for the objects that you want to control from the MATLAB /Simulink environment.

  • The CATIA software saves all vertex coordinates for a part in one VRML coordinate field, which resides in the first exported IndexedFaceSet for the part. This field is referenced from several sub-parts throughout the file with the USE directive.

    Preserve this reference. Do not delete or rename the original Coordinate field DEF name.

  • The VRML file stores only one material per part. If the part consists of several sub-parts in VRML, their material also uses the USE reference to the material of the first sub-part.

  • Textures are supported

  • LOD (exporting parts in several levels of detail for more efficient visualization) is not supported

  • The CATIA software exports models in millimeters, VRML units are meters.

    Scale resulting objects to visualize them effectively.

  • The VRML file does not save user-defined CATIA viewpoints.

  • The main Transform representing the CATIA product is always scaled by a factor of 0.001 (conversion from millimeters to meters), regardless of the units used in the CATIA document

Adjusting Resulting VRML files

Adjust exported VRML files to use the exported VRML models with the Simulink 3D Animation software. You can perform these adjustments manually, as described in this topic, or use the vrcadcleanup and vrphysmod functions to perform some of these tasks.

  • Adding DEF Names to Part Transforms

    In the VRML file, assign a unique name for each VRML object. To do this, add the DEF Object_Name statement to each part Transform line.

    The following is an example of a VRML file that has DEF names added to the cylinder assembly.

    Do not adjust parts in the scene that you do not want to control from the MATLAB environment.

  • Scaling of VRML Objects

    To convert CATProduct size from millimeters to meters (VRML default units), the CATIA software wraps the transform corresponding to the CATProduct with an additional transform. In this transform, the scale field is defined. The preceding example illustrates this.

    If you have a small object, or an object that you must place into an overall virtual world, adjust this scale.

    If you leave the VRML object scale in the default state, the local part coordinates are still in millimeters. Remember this fact when controlling these parts from the MATLAB or Simulink environment. If your MATLAB or Simulink model units are meters, scale each part individually to achieve correct results. You can do this by deleting the scale field from the top level transform, and adding it to each individual part transform. For example,

    Transform {
      children [
        DEF CylinderAssembly1 Transform {
          children [
            DEF CrankAssembly1 Transform {
              scale  0.001 0.001 0.001
Was this topic helpful?