how to make color and lighting continuouse using patch

2 views (last 30 days)
Hi, im trying to visualize 3d objects in MATLAB. when i used the following script i wrote
clear all;
close all
clc
vertices=[0 0 0; 1 0 0; 1 1 0 ;0 1 0; 0 0 1; 1 0 1; 1 1 1; 0 1 1];
faces=[1 2 6 5; 2 3 7 6; 3 4 8 7;4 1 5 8; 1 2 3 4;5 6 7 8];
FV.vertices = [vertices;vertices+[ones(8,1) zeros(8,2)]];
FV.faces = [ faces ; faces+8*ones(6,4)];
FV.FaceVertexCData=0.5*ones(size(FV.vertices,1),3);
figure;
patch_handle=patch('Vertices',FV.vertices,'faces',FV.faces,'FaceVertexCData',FV.FaceVertexCData,'facecolor','interp','facelighting','phong',...
'edgecolor','none','edgelighting','phong');
set(patch_handle,'AmbientStrength',0.8,'DiffuseStrength',0.5,'SpecularStrength',0.5);%,'FaceAlpha',0.5);
light('Position',[1 1 1]);
view(45 ,45);
axis equal
i get that the lighting is not continuous (instead of one continuouse cuboidi can see 2 separate cubs. how do i avoid this ? In the writing of this code i used the following help docs Multiple Patches Specifyingpatch clor thank you

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by