认识wpf的2种3D相机
Posted bcbobo21cn
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了认识wpf的2种3D相机相关的知识,希望对你有一定的参考价值。
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Viewport3D>
<Viewport3D.Camera>
<OrthographicCamera Position="16,2,18" LookDirection="-1,0,-1" Width="10" />
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="-2,4,0 -2,0,0 -2,0,4 -2,4,4" TriangleIndices="0,1,2 0,2,3"/>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Green"/>
</GeometryModel3D.Material>
</GeometryModel3D>
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="-2,4,4 -2,0,4 2,0,4 2,4,4" TriangleIndices="0,1,2 0,2,3"/>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Blue"/>
</GeometryModel3D.Material>
</GeometryModel3D>
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D Positions="2,4,4 2,0,4 2,0,0 2,4,0" TriangleIndices="0,1,2 0,2,3"/>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial Brush="Red"/>
</GeometryModel3D.Material>
</GeometryModel3D>
</ModelVisual3D.Content>
</ModelVisual3D>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<AmbientLight Color="Purple" />
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D>
</Grid>
</Page>
绘制正方体的三个面;正方体一个棱边朝向我们;先用正交相机看,看到如下,不符合我们日常视觉;没看到近大远小;
改用透视相机,
<Viewport3D.Camera>
<PerspectiveCamera Position="10,5,10" LookDirection="-2.5,-1,-2" />
</Viewport3D.Camera>
看到如下,
<MeshGeometry3D Positions="-2,4,0 -2,0,0 -2,0,4 -2,4,4" TriangleIndices="0,1,2 0,2,3"/>
"-2,4,0 -2,0,0 -2,0,4 -2,4,4",这是4个顶点;连接0、1、2做一个三角形,再连接0、2、3做一个三角形,两个三角形构成一个面;
以上是关于认识wpf的2种3D相机的主要内容,如果未能解决你的问题,请参考以下文章