www.gusucode.com > sl3d 案例源码程序 matlab代码 > sl3d/ConvertIndexedFaceSetNodestoMATLABPatchesExample.m

    %% Convert IndexedFaceSet Nodes to MATLAB Patches  
% This command converts three |IndexedFaceSet| nodes to MATLAB(R) patch
% objects.   

%% 
% Open virtual world containing an |IndexedFaceSet| node. 
w1 = vrworld('*sl3dlib/objects/Components/Shapes/Torus_High.wrl');
open(w1);  

%% 
% View the virtual world as a virtual figure. 
vrfig1 = vrfigure(w1,'Name',...
         'Virtual world containing source IndexedFaceSet node');
set(vrfig1,'CameraBound','off');
set(vrfig1,'CameraPosition',[0 40 0]);
set(vrfig1,'CameraDirection',[0 -1 0]);     
set(vrfig1,'CameraUpVector',[0 0 -1]);
%% 
% Convert the |IndexedFaceSet| a MATLAB patch and show it. 
figure('Name',...
    'Resulting patch');
tp = vrifs2patch(w1.torushi.children.geometry);     

%% 
% Change the patch color, show the axes grid, rotate the camera, and enable
% mouse rotation. 
tp.FaceColor = 'red';   

axs = gca;
axs.XGrid = 'on';
axs.YGrid = 'on';
axs.ZGrid = 'on';

camorbit(45, -20);

rotate3d on