wpf 3D动画

 PerspectiveCamera:透视相机  指定3-D模型到2-D可视图面的投影。

PerspectiveCamera 有很多属性,常用的有以下几个:

Position获取或设置以世界坐标表示的摄像机位置。 (继承自 ProjectionCamera。)

FieldOfView获取或设置一个值,该值表示摄像机的水平视角。

LookDirection获取或设置定义摄像机在世界坐标中的拍摄方向的 Vector3D。 (继承自 ProjectionCamera。)

NearPlaneDistance获取或设置一个值,该值指定到摄像机近端剪裁平面的摄像机的距离。 (继承自 ProjectionCamera。)

FarPlaneDistance获取或设置一个值,该值指定到摄像机远端剪裁平面的摄像机的距离。 (继承自 ProjectionCamera。)

UpDirection获取或设置定义摄像机向上方向的 Vector3D。 (继承自 ProjectionCamera。)

 在建立三角形时,如果是逆时针连接顶点,那么建立的三角形就是面向视野的,如果是顺时针连接,就是背向视野的(向外)

 AmbientLight:它所提供的环境光以一致的方式照亮所有的对象,而与对象的位置或方向无关。

  DirectionalLight:像远处的光源那样照亮。 将方向光的 Direction 指定为 Vector3D,但是没有为方向光指定位置。

  PointLight:像近处的光源那样照亮。 PointLight 具有一个位置并从该位置投射光。 场景中的对象是根据对象相对于光源的位置和距离而被照亮的。 PointLightBase 公开Range 属性,该属性确定一个距离,超过该距离后模型将无法由光源照亮。 PointLight 还公开了多个衰减属性,这些属性确定光源的亮度如何随距离的增加而减小。 您可以为光源的衰减指定恒定、线性或二次内插算法。

例:

 <Viewport3D>
            <Viewport3D.Camera>
                <PerspectiveCamera Position="0,0,8" x:Name="camera"></PerspectiveCamera>
            </Viewport3D.Camera>
            <Viewport3D.Children>
                <ModelVisual3D>
                    <ModelVisual3D.Content>
                        <Model3DGroup >
                            <GeometryModel3D>
                                <GeometryModel3D.Material>
                                    <DiffuseMaterial Brush="Green"/>
                                </GeometryModel3D.Material>
                                <GeometryModel3D.Geometry>
                                    <MeshGeometry3D Positions="0,0,0 2,0,0 2,2,0 0,2,0" 
TriangleIndices=
"0,1,2 0,2,3">
                                    </MeshGeometry3D>
                                </GeometryModel3D.Geometry>
                            </GeometryModel3D>
                        </Model3DGroup>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
               <span style="color:#ff0000;"> <ModelVisual3D x:Name="light">
                    <ModelVisual3D.Content>
                        <AmbientLight></AmbientLight>
                    </ModelVisual3D.Content>
                </ModelVisual3D>
</span>            </Viewport3D.Children>
        </Viewport3D>

 

 

原文地址:https://www.cnblogs.com/aggierwyp/p/Viewport3D.html