Modify the CAD Model Virtual World
To modify the results of CAD tool export filters manually, you can use the 3D World Editor or other editor. For example, you can compose the converted model into an urban or manufacturing environment, or add objects such as viewpoints, backgrounds, and lights before using them in Simulink® 3D Animation™ virtual worlds. Typically, adjusting exported files manually in an editor involves several modifications.
Wrap Shape Objects with Transforms
CAD tools export parts into VRML or X3D as individual shapes using various object types
such as Shape
or Inline
nodes. To control part
positions and orientations, 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, which transforms
the coordinates of its children. For instance, after wrapping with a
Transform
node, an Inline
node has syntax similar to
this syntax:
Transform { children [ Inline { url ["robot_arm1.x3d"] } ] }
To set the initial location of the entire assembly in the virtual world, consider
wrapping 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 make export objects accessible in MATLAB®, give each virtual world object a unique name in the virtual world 3D file.
For example, 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 virtual world 3D file has the
syntax similar to this syntax:
DEF Robot_Arm1 Transform { children [ Inline { url ["robot_arm1.x3d"] } ] }
The Simulink 3D Animation functions and in the user interface (such as the descriptions of inputs to the VR Sink block) use these object names. To help with managing the orientation in the object hierarchy, give the parts descriptive names.
Note
Sometimes it is necessary to correct bugs introduced in the file by the CAD tool export filter. As the VRML and X3D format is a text-based format codified by an ISO® standard, these bugs are relatively easy to identify and correct.
Additional Virtual World Modifications
To work with the virtual world effectively, you can make additional modifications to the scene file using a virtual world editor. Make these changes on an ongoing basis, in parallel with developing and using the dynamic model.
Add a scene title by adding a
WorldInfo
node with a scene title. Simulink 3D Animation software uses the title as the virtual world description.Enhance the scene.
Add the
Background
node defining a color backdrop that simulates the ground and sky, and optional background textures, such as panoramas for the scene.Add scene surroundings. This step is not crucial for the visualization of interactions between parts in a machine assembly, but is important for the visualization of simulations. For example, for aircraft and vehicle dynamics the position of one object relative to the scene in which it operates is important. Adding scene surroundings provides context.
For example, to visualize vehicle dynamics, place a virtual car on a virtual road. Make both objects to scale (the length units in the car and road models must match). Place the car in an appropriate position relative to the road. Set proper car scaling, placement, and orientation in the scene by defining corresponding fields of the
Transform
node main object (see Wrap Shape Objects with Transforms).
Configure scene display and navigation.
Add several viewpoints to be able to observe the object conveniently from different positions. The viewpoints can be static or moving. Define a static viewpoint as an independent object at the top level of the scene hierarchy. To create a moving viewpoint, attached a viewpoint to objects that move in the scene 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 Animationvrtkoff.x3d
example.Illuminate a scene by adding lights to it. Although virtual world viewers always have a headlight available, consider defining lights in the scene so that it looks the same for everyone. The most useful type of light to illuminate a whole scene is the
DirectionalLight
node. To illuminate objects from several directions, consider using a combination of several such lights.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.