WPF 3D 点光源学习

先画一个平面,物体具有黄色的材质;不添加灯光,显示如下,

 加入一个点光源,位置(1,1,1)、颜色白色,如下,照亮了物体,看到物体的材质;

点光源是从斜上方照过来的,

 如果光源为绿色,则如下,

 点光源具有Range属性,Range为1如下,

 不同的Range,

点光源具有衰减属性;

光线强度在距离上逐渐减弱的速率称为其衰减,可以通过设置 ConstantAttenuation、 LinearAttenuation或 QuadraticAttenuation 属性来控制。

 点光源没有Direction属性;

MSDN参考,
https://learn.microsoft.com/zh-cn/dotnet/api/system.windows.media.media3d.pointlight?redirectedfrom=MSDN&view=windowsdesktop-7.0
PointLight 类
    表示在空间中具有指定位置并向所有方向上投射光线的光源。

    Range获取或设置光产生效果的最大距离。

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid>  
  
  <Viewport3D>
        <Viewport3D.Camera>
            <PerspectiveCamera Position="0,0,10" LookDirection="0,0,-2" UpDirection="0,1,0"/>
        </Viewport3D.Camera>
        <Viewport3D.Children>                                          
            <ModelVisual3D x:Name="Light">
                <ModelVisual3D.Content>
                    <PointLight Position="1 1 1" Color="Green" Range="2" ConstantAttenuation="1"/>
                </ModelVisual3D.Content>
            </ModelVisual3D>
 
        <ModelVisual3D> 
          <ModelVisual3D.Content> 
            <GeometryModel3D> 
                <GeometryModel3D.Geometry>
                  <MeshGeometry3D Positions="0,0,0,1,0,0,1,1,0,0,1,0" TriangleIndices="0,1,2 2,3,0"/> 
                </GeometryModel3D.Geometry> 
                <GeometryModel3D.Material> 
                  <DiffuseMaterial Brush="Yellow" /> 
                </GeometryModel3D.Material> 
              </GeometryModel3D>
            </ModelVisual3D.Content>
        </ModelVisual3D>
       </Viewport3D.Children> 
</Viewport3D>
 
  </Grid>
</Page>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值