cooldog123pp 发表于 2024-2-24 21:07

添加环境效果

h0=figure('toolbar','none',...
    'position',,...
    'name','实例43');
h1=axes('parent',h0,...
    'position',,...
    'visible','off');
sphere
h=findobj('type','surface');
shading interp
axis equal
l=light('position',);
k(1)=get(h,'specularstrength');
k(2)=get(h,'diffusestrength');
k(3)=get(h,'specularexponent');
k(4)=get(h,'specularcolorreflectance');
u1=uimenu('parent',h0,...
    'label','灯光效果',...
    'tag','u1',...
    'backgroundcolor',);
u11=uimenu('parent',u1,...
    'label','gouraud',...
    'tag','u11',...
    'backgroundcolor',,...
    'callback',[...
      'set(u11,''checked'',''on'');,',...
      'set(u12,''checked'',''off'');,',...
      'set(h,''facelighting'',''gouraud'')']);
u12=uimenu('parent',u1,...
    'label','phong',...
    'tag','u12',...
    'backgroundcolor',,...
    'callback',[...
      'set(u11,''checked'',''off'');,',...
      'set(u12,''checked'',''on'');,',...
      'set(h,''facelighting'',''gouraud'')']);
u2=uimenu('parent',h0,...
    'label','背面灯光',...
    'tag','u2',...
    'backgroundcolor',);
u21=uimenu('parent',u2,...
    'label','reverselit',...
    'tag','u21',...
    'checked','on',...
    'backgroundcolor',,...
    'callback',[...
      'set(u21,''checked'',''on'');,',...
      'set(u22,''checked'',''off'');,',...
      'set(h,''backfacelighting'',''reverselit'')']);
u22=uimenu('parent',u2,...
    'label','reverselit',...
    'tag','u22',...
    'backgroundcolor',,...
    'callback',[...
      'set(u21,''checked'',''off'');,',...
      'set(u22,''checked'',''on'');,',...
      'set(h,''backfacelighting'',''reverselit'')']);
s1=uicontrol('parent',h0,...
    'units','points',...
    'style','slider',...
    'tag','s1',...
    'min',0,...
    'max',1,...
    'value',k(1),...
    'position',,...
    'callback',[...
      's1value=get(s1,''value'');,',...
      'set(h,''specularstrength'',s1value)']);
t1=uicontrol('parent',h0,...
    'units','points',...
    'style','text',...
    'tag','t1',...
    'string','镜面反射强度',...
    'position',);
s2=uicontrol('parent',h0,...
    'units','points',...
    'style','slider',...
    'tag','s2',...
    'min',0,...
    'max',1,...
    'value',k(2),...
    'position',,...
    'callback',[...
      's2value=get(s2,''value'');,',...
      'set(h,''diffusestrength'',s2value)']);
t2=uicontrol('parent',h0,...
    'units','points',...
    'style','text',...
    'tag','t2',...
    'string','漫反射强度',...
    'position',);
s3=uicontrol('parent',h0,...
    'units','points',...
    'style','slider',...
    'tag','s3',...
    'min',0.1,...
    'max',1,...
    'value',k(3)/20,...
    'position',,...
    'callback',[...
      's3value=get(s3,''value'')+eps;,',...
      'set(h,''specularexponent'',20*s3value)']);
t3=uicontrol('parent',h0,...
    'units','points',...
    'style','text',...
    'tag','t3',...
    'string','镜面指数',...
    'position',);
s4=uicontrol('parent',h0,...
    'units','points',...
    'style','slider',...
    'tag','s4',...
    'min',0,...
    'max',1,...
    'value',k(4),...
    'position',,...
    'callback',[...
      's4value=get(s4,''value'');,',...
      'set(h,''specularcolorreflectance'',s4value)']);
t4=uicontrol('parent',h0,...
    'units','points',...
    'style','text',...
    'tag','t1',...
    'string','镜面颜色反射比',...
    'position',);
b1=uicontrol('parent',h0,...
    'units','points',...
    'style','pushbutton',...
    'tag','b1',...
    'string','关闭',...
    'position',,...
    'callback','close');

页: [1]
查看完整版本: 添加环境效果