分享

DelphiXE2 FireMonkey3D 光源的3种类型

 老魏的书架 2012-02-24

DelphiXE2 FireMonkey3D 光源的3种类型

117人阅读 评论(0) 收藏 举报
  1. </pre><pre class="delphi" name="code"> Tlight 的 Light Type 有三种属性.   
  2.   
  3. ltDirectional     
  4. ltPoint  
  5. ltSpot  



在ltDriectional下, 无论光源的位置如何改变,  场景内的图形都不变

 

 

ltPoint 下,光源就像个电灯泡,改变光源位置会造成阴影的改变.

 

 

ltSpot 就像个手电筒, 指到哪里,哪里才亮. 

 

 窗体代码 :

  1. object Form1: TForm1  
  2.   Left = 0  
  3.   Top = 0  
  4.   BiDiMode = bdLeftToRight  
  5.   Caption = 'Form1'  
  6.   ClientHeight = 400  
  7.   ClientWidth = 600  
  8.   Transparency = False  
  9.   Visible = False  
  10.   object Light1: TLight  
  11.     Position.Point = '(-2.91962718963623,-2.18277525901794,-5.00000905990601)'  
  12.     Width = 1.000000000000000000  
  13.     Height = 1.000000000000000000  
  14.     Depth = 1.000000000000000000  
  15.     Opacity = 1.000000000000000000  
  16.     LightType = ltPoint  
  17.     Quanternion = '(0,0,0,1)'  
  18.     object FloatAnimation3: TFloatAnimation  
  19.       Duration = 5.000000000000000000  
  20.       Loop = True  
  21.       StartValue = -5.000000000000000000  
  22.       StartFromCurrent = True  
  23.       StopValue = 5.000000000000000000  
  24.       PropertyName = 'Position.X'  
  25.     end  
  26.   end  
  27.   object Cube1: TCube  
  28.     Position.Point = '(-3.13717293739319,-2.5406289100647,-3.68232804248692E-7)'  
  29.     RotationAngle.Point = '(10,5,5)'  
  30.     Width = 2.000000000000000000  
  31.     Height = 2.000000000000000000  
  32.     Depth = 2.000000000000000000  
  33.     Opacity = 1.000000000000000000  
  34.     Material.Diffuse = xFFB41B1B  
  35.     Quanternion =   
  36.       '(0.0888853296637535,0.0472101084887981,0.039613988250494,0.99413' +  
  37.       '3472442627)'  
  38.     object FloatAnimation1: TFloatAnimation  
  39.       Enabled = True  
  40.       Duration = 100.000000000000000000  
  41.       StopValue = 360.000000000000000000  
  42.       PropertyName = 'RotationAngle.X'  
  43.     end  
  44.   end  
  45.   object Cone1: TCone  
  46.     Position.Point = '(3.08346128463745,-2.22207975387573,-1.62784465373989E-6)'  
  47.     Width = 2.500000000000000000  
  48.     Height = 2.000000000000000000  
  49.     Depth = 2.000000000000000000  
  50.     Opacity = 1.000000000000000000  
  51.     Material.Diffuse = xFF426CC9  
  52.     Quanternion = '(0,0,0,1)'  
  53.     object FloatAnimation2: TFloatAnimation  
  54.       Enabled = True  
  55.       Duration = 100.000000000000000000  
  56.       Loop = True  
  57.       StopValue = 360.000000000000000000  
  58.       PropertyName = 'RotationAngle.Y'  
  59.     end  
  60.   end  
  61.   object Layer3D1: TLayer3D  
  62.     Position.Point = '(-0.700324535369873,2.73746109008789,9.99998569488525)'  
  63.     RotationAngle.Point = '(-20,0,0)'  
  64.     Width = 45.193157196044920000  
  65.     Height = 29.603034973144530000  
  66.     Depth = 0.009999999776482582  
  67.     Opacity = 1.000000000000000000  
  68.     OnMouseMove = Layer3D1MouseMove  
  69.     StyleLookup = 'backgroundstyle'  
  70.     Quanternion = '(-0.173648178577423,0,0,0.984807729721069)'  
  71.     object SpeedButton1: TSpeedButton  
  72.       Position.Point = '(280,1136)'  
  73.       Width = 80.000000000000000000  
  74.       Height = 22.000000000000000000  
  75.       Scale.Point = '(10,10)'  
  76.       OnClick = SpeedButton1Click  
  77.       TabOrder = 0  
  78.       StaysPressed = False  
  79.       IsPressed = False  
  80.       Text = #28857#20809#28304  
  81.     end  
  82.     object SpeedButton2: TSpeedButton  
  83.       Position.Point = '(1056,1136)'  
  84.       Width = 80.000000000000000000  
  85.       Height = 22.000000000000000000  
  86.       Scale.Point = '(10,10)'  
  87.       OnClick = SpeedButton2Click  
  88.       TabOrder = 1  
  89.       StaysPressed = False  
  90.       IsPressed = False  
  91.       Text = #23556#32447#20809#28304  
  92.     end  
  93.   end  
  94. end  


代码

  1. unit Unit1;  
  2.   
  3. interface  
  4.   
  5. uses  
  6.   System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,  
  7.   FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Ani, FMX.Objects3D,  
  8.   FMX.Types3D, FMX.Layers3D, FMX.Layouts, FMX.Memo;  
  9.   
  10. type  
  11.   TForm1 = class(TForm3D)  
  12.     Light1: TLight;  
  13.     Cube1: TCube;  
  14.     Cone1: TCone;  
  15.     FloatAnimation1: TFloatAnimation;  
  16.     FloatAnimation2: TFloatAnimation;  
  17.     Layer3D1: TLayer3D;  
  18.     FloatAnimation3: TFloatAnimation;  
  19.     SpeedButton1: TSpeedButton;  
  20.     SpeedButton2: TSpeedButton;  
  21.     procedure Layer3D1MouseMove(Sender: TObject; Shift: TShiftState; X,  
  22.       Y: Single; RayPos, RayDir: TVector3D);  
  23.     procedure SpeedButton1Click(Sender: TObject);  
  24.     procedure SpeedButton2Click(Sender: TObject);  
  25.   private  
  26.     { Private declarations }  
  27.   public  
  28.     { Public declarations }  
  29.   end;  
  30.   
  31. var  
  32.   Form1: TForm1;  
  33.   
  34. implementation  
  35.   
  36. {$R *.fmx}  
  37.   
  38. procedure TForm1.Layer3D1MouseMove(Sender: TObject; Shift: TShiftState; X,  
  39.   Y: Single; RayPos, RayDir: TVector3D);  
  40. begin  
  41.   light1.Position.X := raydir.X * 15;  
  42.   light1.Position.y := raydir.y * 15;  
  43. end;  
  44.   
  45. procedure TForm1.SpeedButton1Click(Sender: TObject);  
  46. begin  
  47.   light1.LightType := FMX.Types3D.TLightType.ltPoint;  
  48. end;  
  49.   
  50. procedure TForm1.SpeedButton2Click(Sender: TObject);  
  51. begin  
  52.   light1.LightType := FMX.Types3D.TLightType.ltSpot;  
  53. end;  
  54.   
  55. end.  

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多