QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 585|回复: 0
打印 上一主题 下一主题

【奠基经典】MATLAB实用程序案例之添加环境效果

[复制链接]
字体大小: 正常 放大

398

主题

13

听众

1339

积分

  • TA的每日心情
    慵懒
    2015-12-12 14:33
  • 签到天数: 81 天

    [LV.6]常住居民II

    跳转到指定楼层
    1#
    发表于 2015-7-28 22:57 |只看该作者 |倒序浏览
    |招呼Ta 关注Ta






    添加环境效果
    实例:

    h0=figure('toolbar','none',...

    'position',[198 56 450 468],...

    'name','实例43');

    h1=axes('parent',h0,...

    'position',[0.15 0.45 0.7 0.5],...

    'visible','off');

    sphere

    h=findobj('type','surface');

    shading interp

    axis equal

    l=light('position',[0 -2 1]);

    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',[0.75 0.75 0.75]);

    u11=uimenu('parent',u1,...

    'label','gouraud',...

    'tag','u11',...

    'backgroundcolor',[0.75 0.75 0.75],...

    'callback',[...

    'set(u11,''checked'',''on'');,',...

    'set(u12,''checked'',''off'');,',...

    'set(h,''facelighting'',''gouraud'')']);

    u12=uimenu('parent',u1,...

    'label','phong',...

    'tag','u12',...

    'backgroundcolor',[0.75 0.75 0.75],...

    'callback',[...

    'set(u11,''checked'',''off'');,',...

    'set(u12,''checked'',''on'');,',...

    'set(h,''facelighting'',''gouraud'')']);

    u2=uimenu('parent',h0,...

    'label','背面灯光',...

    'tag','u2',...

    'backgroundcolor',[0.75 0.75 0.75]);

    u21=uimenu('parent',u2,...

    'label','reverselit',...

    'tag','u21',...

    'checked','on',...

    'backgroundcolor',[0.75 0.75 0.75],...

    'callback',[...

    'set(u21,''checked'',''on'');,',...

    'set(u22,''checked'',''off'');,',...

    'set(h,''backfacelighting'',''reverselit'')']);

    u22=uimenu('parent',u2,...

    'label','reverselit',...

    'tag','u22',...

    'backgroundcolor',[0.75 0.75 0.75],...

    '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',[20 80 100 15],...

    'callback',[...

    's1value=get(s1,''value'');,',...

    'set(h,''specularstrength'',s1value)']);

    t1=uicontrol('parent',h0,...

    'units','points',...

    'style','text',...

    'tag','t1',...

    'string','镜面反射强度',...

    'position',[20 97 100 15]);

    s2=uicontrol('parent',h0,...

    'units','points',...

    'style','slider',...

    'tag','s2',...

    'min',0,...

    'max',1,...

    'value',k(2),...

    'position',[20 30 100 15],...

    'callback',[...

    's2value=get(s2,''value'');,',...

    'set(h,''diffusestrength'',s2value)']);

    t2=uicontrol('parent',h0,...

    'units','points',...

    'style','text',...

    'tag','t2',...

    'string','漫反射强度',...

    'position',[20 47 100 15]);

    s3=uicontrol('parent',h0,...

    'units','points',...

    'style','slider',...

    'tag','s3',...

    'min',0.1,...

    'max',1,...

    'value',k(3)/20,...

    'position',[220 80 100 15],...

    'callback',[...

    's3value=get(s3,''value'')+eps;,',...

    'set(h,''specularexponent'',20*s3value)']);

    t3=uicontrol('parent',h0,...

    'units','points',...

    'style','text',...

    'tag','t3',...

    'string','镜面指数',...

    'position',[220 97 100 15]);

    s4=uicontrol('parent',h0,...

    'units','points',...

    'style','slider',...

    'tag','s4',...

    'min',0,...

    'max',1,...

    'value',k(4),...

    'position',[220 30 100 15],...

    'callback',[...

    's4value=get(s4,''value'');,',...

    'set(h,''specularcolorreflectance'',s4value)']);

    t4=uicontrol('parent',h0,...

    'units','points',...

    'style','text',...

    'tag','t1',...

    'string','镜面颜色反射比',...

    'position',[220 47 100 15]);

    b1=uicontrol('parent',h0,...

    'units','points',...

    'style','pushbutton',...

    'tag','b1',...

    'string','关闭',...

    'position',[145 45 50 30],...

    'callback','close');



    关于本帖内容欢迎大家踊跃讨论,与在下交流!

    zan
    转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
    您需要登录后才可以回帖 登录 | 注册地址

    qq
    收缩
    • 电话咨询

    • 04714969085
    fastpost

    关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

    手机版|Archiver| |繁體中文 手机客户端  

    蒙公网安备 15010502000194号

    Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

    GMT+8, 2025-5-21 18:16 , Processed in 0.408481 second(s), 53 queries .

    回顶部