我有一个阴影三维物体的三维图。当用户旋转绘图时,如何使光源不断更新为从用户看的方向?
答案 0 :(得分:0)
查看MATLAB的camlight
命令(online documentation)。
这是一个可以帮助您入门的最小演示:
function camlight_demo
% some example data to plot
surf(peaks);
h = rotate3d;
set(h,'Enable','on');
% add a light
LightSource = camlight('headlight');
% add a callback which will be executed after each rotation
set(h,'ActionPostCallback',{@move_light_source, LightSource});
end
% This function will move the light after each rotation
function move_light_source(src, evt, LightSource)
camlight(LightSource, 'headlight');
end