【问题标题】:Helix Toolkit view cube not showingHelix Toolkit 视图立方体未显示
【发布时间】:2020-12-22 00:15:09
【问题描述】:

我在基于 HelixToolkit 包的 WPF 应用程序中遇到问题。

即使我将 ShowViewCube 参数设置为“true”,视图立方体也没有显示。 有趣的是我可以启用并显示视图立方体边缘,但立方体的其余部分仍然不可见。

这是视口代码:

<hx:Viewport3DX
            x:Name="view1"
            Title="{Binding Title}"
            BackgroundColor="Black"
            Camera="{Binding Camera}"
            CoordinateSystemLabelForeground="#434343"
            UseDefaultGestures="True"
            EffectsManager="{Binding EffectsManager}"
            ModelUpDirection="{Binding UpDirection}"
            ShowViewCube="True"
            IsViewCubeEdgeClicksEnabled="True"
            ShowCoordinateSystem="True"
            SubTitle="{Binding SubTitle}"
            TextBrush="#FFFEFFF6"
            EnableSwapChainRendering="True" 
            EnableD2DRendering="False"
            FXAALevel="Low"
            EnableDeferredRendering="False"   
            ClipToBounds="False" Margin="0,0,0,0" 
            CameraRotationMode="Turnball"
            CoordinateSystemHorizontalPosition="0" 
            IsThreeFingerPanningEnabled="False"
            IsTouchRotateEnabled="False" 
            IsViewCubeMoverEnabled="False" 
            IsCoordinateSystemMoverEnabled="False"
            OITWeightMode="NonLinear" 
            Grid.ColumnSpan="1"
            Grid.Column="1" 
            Grid.RowSpan="2">

            
            <hx:Viewport3DX.InputBindings>

                <KeyBinding Key="B" Command="hx:ViewportCommands.BackView" />
                <KeyBinding Key="G" Command="hx:ViewportCommands.FrontView" />
                <KeyBinding Key="T" Command="hx:ViewportCommands.TopView" />
                <KeyBinding Key="V" Command="hx:ViewportCommands.BottomView" />
                <KeyBinding Key="G" Command="hx:ViewportCommands.LeftView" />
                <KeyBinding Key="H" Command="hx:ViewportCommands.RightView" />
                <KeyBinding Command="hx:ViewportCommands.ZoomExtents" Gesture="Control+E" />
                <MouseBinding Command="hx:ViewportCommands.Rotate" Gesture="RightClick" />
                <MouseBinding Command="hx:ViewportCommands.Zoom" Gesture="MiddleClick" />
                <MouseBinding Command="hx:ViewportCommands.Pan" Gesture="LeftClick" />
            </hx:Viewport3DX.InputBindings>

            <hx:AmbientLight3D Color="{Binding AmbientLightColor}" />
            <hx:DirectionalLight3D Direction="{Binding Camera.LookDirection}" 
                                   Color="{Binding DirectionalLightColor}" />
            <hx:ScreenQuadModel3D Texture="{Binding BackgroundTexture}" />

            <hx:LineGeometryModel3D
                x:Name="pointlines"
                Thickness="0.5"
                Geometry="{Binding PointGrid.GridGeometry}"
                Transform="{Binding Points.PointsTransform}"
                Color="{Binding Grid.GridColor}" IsHitTestVisible="False" IsEnabled="False" 
                IsDepthClipEnabled="False" IsMultisampleEnabled="False" IsScissorEnabled="False"/>

            <hx:LineGeometryModel3D
                x:Name="grid"
                Thickness="0.2"
                Geometry="{Binding Grid.GridGeometry}"
                Transform="{Binding Grid.GridTransform}"
                Color="{Binding Grid.GridColor}" 
                IsHitTestVisible="False" 
                IsEnabled="False" 
                IsDepthClipEnabled="False" 
                IsMultisampleEnabled="False" 
                IsScissorEnabled="False"/>

            <hx:LineGeometryModel3D
                x:Name="arrows"                
                Thickness="1"
                Geometry="{Binding Axis.AxisGeometry}"
                Transform="{Binding Axis.AxisTransform}"
                Color="{Binding Axis.AxisColor}" 
                IsHitTestVisible="False" 
                IsEnabled="False" 
                IsDepthClipEnabled="False" 
                IsMultisampleEnabled="False" 
                IsScissorEnabled="False"/>

            <hx:PointGeometryModel3D
                x:Name="points"
                Geometry="{Binding Points.PointsGeometry}"
                Transform="{Binding Points.PointsTransform}"
                Color="{Binding Points.PointsColor}" 
                IsDepthClipEnabled="False" IsEnabled="False" IsHitTestVisible="False" IsMultisampleEnabled="True" 
                IsScissorEnabled="False"  FixedSize="True" Size="2,2"/>

            <hx:MeshGeometryModel3D
                x:Name="MeshModel"
                ></hx:MeshGeometryModel3D>

        </hx:Viewport3DX>

还有代码隐藏:

public MainViewModel()
        {
            EffectsManager = new DefaultEffectsManager();            

            // camera setup
            Camera = new HelixToolkit.Wpf.SharpDX.PerspectiveCamera
            {
                Position = new Point3D(0, 0, 0),
                LookDirection = new Vector3D(0, 0, 0),
                UpDirection = new Vector3D(0, 0, 0),
                FarPlaneDistance = 0
            };
            // setup lighting            
            AmbientLightColor = Colors.DimGray;
            DirectionalLightColor = Colors.White; 

            DirectionalLightDirection = Camera.LookDirection;
        }

这就是 View Cube 现在的样子:

【问题讨论】:

    标签: c# wpf helix-3d-toolkit


    【解决方案1】:

    我终于找到了答案。视图立方体绑定到视图中的“ModelUpDirection”属性。自定义它会导致立方体显示出现问题。

    【讨论】:

      猜你喜欢
      • 2021-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多