Import 3D file into virtual world or node
an empty VRML virtual world and imports the
node = vrimport(
file into it. The format of the 3D file is detected automatically.
You can import these file formats:
FBX (Autodesk® FilmBoX format)
DAE (Collada digital asset exchange)
SDF (simulation description format)
URDF (unified robot description file)
XML (Physical Modeling XML files)
The function returns a handle to the newly created node.
[ returns the handle of the new
node and the handle of the virtual world that contains that node.
Import STL File Into an Empty Virtual World
This example imports an STL file
a model of a simple wheeled robot. The example also shows how to add
visual appearance and material nodes to the imported model in the
Create a virtual world with the imported model.
[n,w] = vrimport(which('Rover_1.stl'));
View the virtual world with the imported shape.
Scale the imported model from mm to dm to see it in the view.
n.scale = [0.01 0.01 0.01]
Rotate the rover around the x-axis.
w.Rover_Transform.rotation = [1 0 0 -pi/2]
Explore the virtual world structure.
STL imported shapes have no visual properties. Add an
Materials node to the shape. The
is created in the
appearance field of the
Material node is create in the
app = vrnode(w.Rover_Shape,'appearance','Rover_App','Appearance'); mat = vrnode(w.Rover_App,'material','Rover_Mat','Material');
Set the diffuse color to a shade of blue.
w.Rover_Mat.diffuseColor = [0 0.5 1]
Save the virtual world.
Import a DAE file
This example imports a
file into a virtual world.
fox.dae file to a node in
a virtual world.
[n,w] = vrimport(which('fox.dae'))
n = vrnode object: 1-by-1 COLLADA_fox_Transform_0001 (Transform)  w = vrworld object: 1-by-1 (No Virtual Reality 3D File Associated)
View the imported visual representation.
Save the virtual world.
source — 3D source file
3D source file path, specified as a character vector. The 3D file can be in DAE, SDF, STL, or URDF format.
format — File format of source 3D file
File format of source 3D file, specified as a character vector. Use this argument to specify explicitly the required format for the source 3D file.
parent — Virtual world or node to import 3D source file to
vrworld object |
Virtual world or node to import 3D source file into, specified as a virtual world handle or node handle.
If the parent is a virtual world, the imported node is placed at the
ROOTnode of the parent.
If the parent is a node in a virtual world, the imported node is placed in the
childrenfield of the node.
node — New node
New node, returned as a
virtualWorld — Virtual world containing new node
Virtual world containing new node, returned as a
Introduced in R2016b