Viewport3D с отсечкой для орфографической камеры

При использовании ViewPort3D с ортогональной камерой трехмерная модель обрезается, как вы можете видеть на 2-й ссылке ниже. Это похоже на то, что вид основан на перспективной камере и не показывает, что находится за ней, даже если он использует орфографическую камеру.

Просмотр всей 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>

1 ответ

У меня была такая же проблема, как и у вас. Испытывая несколько решений, наконец, я смог найти решение.

Вы должны увеличить или определить свойство FarPlaneDistance PerspectiveCamera.

Удачи

Другие вопросы по тегам