Main Content

vrpatch2ifs

(To be removed) Convert MATLAB patches to IndexedFaceSet nodes

vrpatch2ifs will be removed in a future release. For more information, see Version History.

Description

node = vrpatch2ifs(patches,world) converts the patches array and saves the result into the vrnode array node. Each resulting IndexedFaceSet node in node is wrapped by the created Shape node residing in a root level of the world virtual world.

node = vrpatch2ifs(patches,shape) converts the patches array and saves the result into the vrnode array node. Each resulting IndexedFaceSet node in node is a child of the respective Shape node in the shape array. If the Shape node already contains an IndexedFaceSet node, that IndexedFaceSet is overwritten. The number of patches must equal the number of Shape nodes.

Note

This function converts only geometry and color data of the patch.

example

node = vrpatch2ifs(patches,parent) converts the patches array and saves the result into the vrnode array node. Each resulting IndexedFaceSet node in node is wrapped by the created Shape node that is a child of the parent node.

vrpatch2ifs(patches,ifs) converts the patches array and saves the result into ifs array of existing IndexedFaceSet nodes, overwriting the IndexedFaceSet nodes. The number of patches must equal the number of IndexedFaceSet nodes.

Examples

collapse all

This command converts three MATLAB® patches to IndexedFaceSet nodes.

Create surface using MATLAB peaks function.

fig = figure('Name','Source peaks surface');
s = surf(peaks);

Figure Source peaks surface contains an axes object. The axes object contains an object of type surface.

Convert the peaks surface to a patch.

peaksPatch = patch(surf2patch(s));
delete(s);
shading interp;

Figure Source peaks surface contains an axes object. The axes object contains an object of type patch.

Create and open an empty virtual world.

w2 = vrworld('');
open(w2);

Create and bind viewpoint

dv = vrnode(w2, 'DefaultViewpoint','Viewpoint');
dv.position  = [-1 15 30];
dv.orientation = [-0.38 -0.93 0 0.55];
setfield(dv,'set_bind',true); %#ok<STFLD,SFLD>

Convert the patch to an IndexedFaceSet nodes. The resulting nodes are created in the root level of supplied vrworld object.

vrpatch2ifs(peaksPatch,w2);

Figure Source peaks surface contains an axes object. The axes object contains an object of type patch.

Show the result.

vrfig2 = vrfigure(w2,'Name',...
         'Virtual world containing resulting IndexedFaceSet node');

Figure Virtual world containing resulting IndexedFaceSet node contains objects of type hgjavacomponent, uimenu, uipanel, uitoolbar.

Input Arguments

collapse all

MATLAB patches, specified as an array.

Virtual world that contains Shape nodes, specified as a vrworld object.

Parent grouping node, specified as a vrnode object.

Shape array, specified as an array of Shape nodes.

IndexedFaceSet nodes, specified as an array.

Output Arguments

collapse all

Conversion result, returned as a vrnode array.

Version History

Introduced in R2015a

collapse all

R2023b: To be removed

The vrpatch2ifs will be removed in a future release. Instead, use sim3d classes and Simulation 3D blocks to interface MATLAB and Simulink® with the Unreal Engine® 3D simulation environment. To get started, see Create 3D Simulations in Unreal Engine Environment.