主要内容

vrimport

将3D文件导入虚拟世界或节点

Description

node= vrimport(source)创建一个空的VRML虚拟世界,并导入source3D 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)

  • STL (STereoLithography)

  • URDF (unified robot description file)

  • XML (Physical Modeling XML files)

这function returns a handle to the newly created node.

node= vrimport(,source)指定现有的虚拟世界或节点将3D源文件导入到。

node= vrimport(___,格式)explicitly specifies the file format of the 3D source file (for example,'urdf'). If the format of the source file does not match the format specified in the格式argument, the function returns an error.

example

[node,virtualWorld] = vrimport(___)returns the handle of the new node and the handle of the virtual world that contains that node.

Examples

collapse all

This example imports an STL fileRover_1.stl, 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 virtual world.

Create a virtual world with the imported model.

[n,w] = vrimport(which('Rover_1.stl'));

以进口形状查看虚拟世界。

view(w)

Scale the imported model from mm to dm to see it in the view.

n.scale = [0.01 0.01 0.01]

将漫游者旋转在X轴周围。

w.Rover_Transform.rotation = [1 0 0 -pi/2]

探索虚拟世界结构。

get(w,'Nodes')

STL导入的形状没有视觉属性。添加一个AppearanceMaterialsnode to the shape. TheAppearancenode is created in theappearancefield of theShape。这Material节点是在materialfield of theAppearancenode.

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.

save(w,'Rover_1.x3d')

This example imports a。dae将文件格式化为虚拟世界。

Import thefox.daefile 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.

view(w)

Save the virtual world.

save(w,'fox.x3d')

Input Arguments

collapse all

3D源文件路径,指定为字符向量。3D文件可以以DAE,SDF,STL或URDF格式为单位。

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.

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 theROOTnode of the parent.

  • 如果父母是虚拟世界中的节点,则将导入的节点放在childrenfield of the node.

Output Arguments

collapse all

New node, returned as avrnode目的。

Virtual world containing new node, returned as avrworld目的。

Version History

Introduced in R2016b