我真的对 WPF 中的透视相机感到沮丧,它会做各种奇怪的事情,而且我在互联网上可以找到的所有解决方案都不适合我。
目前我有这个代码:
<Window x:Class="projectv1.Views.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" Name="MainWin">
<Grid HorizontalAlignment="Stretch" >
<Viewport3D Name="viewport3D1" >
<Viewport3D.Camera>
<PerspectiveCamera x:Name="camMain" Position="-500 -10 300" LookDirection="0 -0.2 -1" UpDirection="0 1 0" FarPlaneDistance="10000" NearPlaneDistance="1" />
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight x:Name="dirLightMain" Direction="-1,-1,-1">
</DirectionalLight>
</ModelVisual3D.Content>
</ModelVisual3D>
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D x:Name="meshMain"
Positions="-800,0,-1000 -200,0,-1000 -500,0,-100"
TriangleIndices="0,1,2" >
</MeshGeometry3D>
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial x:Name="matDiffuseMain">
<DiffuseMaterial.Brush>
<SolidColorBrush Color="Red"/>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
</GeometryModel3D>
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D>
</Grid>
所以我有一个三角形,我从下面看它......但现在我想从顶部看它所以我将相机的 Y 参数的位置更改为任何大于 0 的值,但突然间我不能看到任何东西。例如 Position ="-500 -1 300" 有效,但 Position="-500 1 300" 不再有效。我用 updirection 变量玩了很多,但我无法解决这个问题....