Strange patch behaviour when hgtransform applied to object

조회 수: 6 (최근 30일)
Andrew
Andrew 2011년 8월 1일
Hi,
I have a patch surface consisting of triangular facets. I have a scalar field for with data for each node in the patch. This is used to generate a fringe plot. This has been working well.
p = patch(surf, ...
'cdata', field_values, ...
'facecolor','interp', ...
'facelighting', 'phong', ...
'edgecolor', 'none',...
'specularstrength', 0.1);
axis equal;
set(gca, 'visible', 'off');
caxis(color_scale)
colorbar('location', 'eastoutside');
light
I require orthogonal views of this patch surface. I tried to use hgtransform to re-orient the patch as follows:
% hg=hgtransform;
% set(p,'parent', hg);
% M = makehgtform('yrotate',-pi/2);
% set(hg, 'matrix', M);
The patch surface orients correctly, however the face shading is now distorted, which I guess is due to the vertex normals not updating to the new orientation.
Have I missed something, or is this an inappropriate use of this command, and I would be better off using the camera toolbar.
Thanks for any comments.
Regards Andrew Sims UNSW, Australia.

채택된 답변

Patrick Kalita
Patrick Kalita 2011년 8월 1일
I think this is probably a bug in how the ZBuffer renderer does its lighting computations. If you change the figure's renderer to OpenGL, it should look fine:
set(gcf, 'Renderer', 'OpenGL')
One caveat: the OpenGL renderer does not support Phong lighting. So you will notice that even though the patch's FaceLighting property is set to 'phong' it will fall back to Gouraud-style shading when you change renderers.
  댓글 수: 1
Andrew
Andrew 2011년 8월 2일
Thank you Patrick. That is very helpful.
Regards
Andrew Sims

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by