将 ViewPort3D 与正交相机一起使用时,3D 模型正在裁剪,如下面的第二个链接所示。就像视图基于透视相机并且不显示其背后的内容,即使它使用正交相机也是如此。
使用代码生成上面的图片
Used code to generate pictures above (toggling Orthographic to True/False)
<Window x:Class="HelixToolkitTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:helix="http://helix-toolkit.org/wpf"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<GeometryModel3D x:Key="GeometryModel">
<GeometryModel3D.Geometry>
<MeshGeometry3D
TriangleIndices="0,1,2 3,4,5 "
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<MaterialGroup>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Yellow" Offset="0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</GeometryModel3D.Material>
<GeometryModel3D.Transform>
<ScaleTransform3D ScaleX="50" ScaleY="1" ScaleZ="1"/>
</GeometryModel3D.Transform>
</GeometryModel3D>
<DirectionalLight x:Key="DirectionalLight" Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
</Window.Resources>
<UniformGrid Columns="3">
<GroupBox Header="Perspective camera">
<Viewport3D>
<Viewport3D.Camera>
<PerspectiveCamera FarPlaneDistance="Infinity" NearPlaneDistance="0.1" LookDirection="12.064,-1.167,-0.831" UpDirection="-0.73,0.071,0.679"
Position="-12.064,1.167,0.831"/>
</Viewport3D.Camera>
<ModelVisual3D Content="{StaticResource DirectionalLight}"/>
<ModelVisual3D Content="{StaticResource GeometryModel}"/>
</Viewport3D>
</GroupBox>
<GroupBox Header="Orthographic camera">
<Viewport3D>
<Viewport3D.Camera>
<OrthographicCamera FarPlaneDistance="Infinity" NearPlaneDistance="0.1" LookDirection="12.064,-1.167,-0.831" UpDirection="-0.73,0.071,0.679"
Position="-12.064,1.167,0.831" Width="9.313"/>
</Viewport3D.Camera>
<ModelVisual3D Content="{StaticResource DirectionalLight}"/>
<ModelVisual3D Content="{StaticResource GeometryModel}"/>
</Viewport3D>
</GroupBox>
关于如何解决这个问题的任何想法?
谢谢,
编辑:我实际上找到了解决方案,您只需将正交相机的 NearPlaneDistance 设置为 -Infinity,请参见下面的代码:
<Window x:Class="HelixToolkitTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:helix="http://helix-toolkit.org/wpf"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<GeometryModel3D x:Key="GeometryModel">
<GeometryModel3D.Geometry>
<MeshGeometry3D
TriangleIndices="0,1,2 3,4,5 "
Normals="0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 0,0,1 "
TextureCoordinates="0,0 1,0 1,1 1,1 0,1 0,0 "
Positions="-0.5,-0.5,0.5 0.5,-0.5,0.5 0.5,0.5,0.5 0.5,0.5,0.5 -0.5,0.5,0.5 -0.5,-0.5,0.5 " />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<MaterialGroup>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Yellow" Offset="0" />
<GradientStop Color="Red" Offset="0.25" />
<GradientStop Color="Blue" Offset="0.75" />
<GradientStop Color="LimeGreen" Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</MaterialGroup>
</GeometryModel3D.Material>
<GeometryModel3D.Transform>
<ScaleTransform3D ScaleX="50" ScaleY="1" ScaleZ="1"/>
</GeometryModel3D.Transform>
</GeometryModel3D>
<DirectionalLight x:Key="DirectionalLight" Color="#FFFFFF" Direction="-0.612372,-0.5,-0.612372" />
</Window.Resources>
<UniformGrid Columns="3">
<GroupBox Header="Perspective camera">
<Viewport3D>
<Viewport3D.Camera>
<PerspectiveCamera FarPlaneDistance="Infinity" NearPlaneDistance="0.1" LookDirection="12.064,-1.167,-0.831" UpDirection="-0.73,0.071,0.679"
Position="-12.064,1.167,0.831"/>
</Viewport3D.Camera>
<ModelVisual3D Content="{StaticResource DirectionalLight}"/>
<ModelVisual3D Content="{StaticResource GeometryModel}"/>
</Viewport3D>
</GroupBox>
<GroupBox Header="Orthographic camera">
<Viewport3D>
<Viewport3D.Camera>
<OrthographicCamera FarPlaneDistance="Infinity" NearPlaneDistance="-Infinity" LookDirection="12.064,-1.167,-0.831" UpDirection="-0.73,0.071,0.679"
Position="-12.064,1.167,0.831" Width="9.313"/>
</Viewport3D.Camera>
<ModelVisual3D Content="{StaticResource DirectionalLight}"/>
<ModelVisual3D Content="{StaticResource GeometryModel}"/>
</Viewport3D>
</GroupBox>