main content

import 3d file into virtual world or node -凯发k8网页登录

import 3d file into virtual world or node

description

node = vrimport(source) creates an empty vrml virtual world and imports the source 3d 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)

the function returns a handle to the newly created node.

node = vrimport(parent,source) specifies the existing virtual world or node to import the 3d source file into.

node = vrimport(___,format) 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 format 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

this example imports an stl file rover_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 the virtual world with the imported shape.

view(w)

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.

get(w,'nodes')

stl imported shapes have no visual properties. add an appearance and a materials node to the shape. the appearance node is created in the appearance field of the shape. the material node is create in the material field of the appearance node.

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 format file into a virtual world.

import the 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.

view(w)

save the virtual world.

save(w,'fox.x3d')

input arguments

3d source file path, specified as a character vector. the 3d file can be in dae, sdf, stl, or urdf format.

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

  • if the parent is a node in a virtual world, the imported node is placed in the children field of the node.

output arguments

new node, returned as a vrnode object.

virtual world containing new node, returned as a vrworld object.

version history

introduced in r2016b

see also

|

topics

    网站地图