简体   繁体   中英

3d object not rendered

I have a WPF application that has a main window. In that I have a frame, the frame content is a page.

Now in page is 4 viewport3D that contain Viewport2DVisual3D and in that I have image element.

Problem : on some PCs my application runs well but on some PCs my application doesn't render viewport3d or it doesn't render the frame. Dunno but it doesn't show anything in main window.

The problem occurs on an Acer laptop Model .

Rendered : 真实的形象

Not Rendered : 在此输入图像描述

EDIT: This issue occurred again when I placed the frame in a grid. (I show this page in a frame, that frame is the main content of my window: when I place the frame in a grid it didn't show objects) Seems This Occure on laptop with shared graphics

EDIT 2:

<Page x:Class="MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              Loaded="Page_Loaded_1"
        x:Name="myMainPage" FlowDirection="RightToLeft"  >

    <Page.Resources>

        <Style  TargetType="ContentControl" x:Key="MenuItemsStyle">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate>

                        <Viewport3D VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ClipToBounds="False">
                            <Viewport3D.Camera>
                                <PerspectiveCamera x:Name="myCam" FieldOfView="90" Position="{Binding ElementName=myMainWindow, Path=CameraHeight}" NearPlaneDistance="1" FarPlaneDistance="10"/>
                            </Viewport3D.Camera>

                            <ModelVisual3D>
                                <ModelVisual3D.Content>
                                    <Model3DGroup>
                                        <DirectionalLight Color="#FFFFFFFF" Direction="0,0,-1"/>
                                    </Model3DGroup>
                                </ModelVisual3D.Content>
                            </ModelVisual3D>

                            <Viewport2DVisual3D x:Name="V2d3d">

                                <Viewport2DVisual3D.Transform>
                                    <Transform3DGroup>
                                        <RotateTransform3D >
                                            <RotateTransform3D.Rotation>
                                                <AxisAngleRotation3D Axis="0,1,0" Angle="0" x:Name="aar3D"/>
                                            </RotateTransform3D.Rotation>
                                        </RotateTransform3D>
                                    </Transform3DGroup>
                                </Viewport2DVisual3D.Transform>

                                <Viewport2DVisual3D.Material>
                                    <DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" Brush="White"/>
                                </Viewport2DVisual3D.Material>
                                                              <Viewport2DVisual3D.Geometry>
                                    <MeshGeometry3D Positions="{Binding   ElementName=myMainWindow, Path=MeshPosions}"
                            TextureCoordinates="0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3"/>
                                </Viewport2DVisual3D.Geometry>
                                <Border Name="mainBorder" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                                    <Border.Style>
                                        <Style TargetType="Border">
                                            <Setter Property="BorderThickness" Value="1.2"/>
                                            <Setter Property="Background" >
                                                <Setter.Value>
                                                    <SolidColorBrush Color="Transparent"/>
                                                </Setter.Value>
                                            </Setter>
                                            <Setter Property="BorderBrush" >
                                                <Setter.Value>
                                                    <SolidColorBrush Color="Transparent"/>
                                                </Setter.Value>
                                            </Setter>
                                                                              </Style>
                                    </Border.Style>
                                    <ContentPresenter VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                                                      Content="{TemplateBinding ContentControl.Content}">
                                        <ContentPresenter.Triggers>
                                            <EventTrigger RoutedEvent="ContentPresenter.MouseLeftButtonDown">
                                              // Axis Animation
                                            </EventTrigger>
                                        </ContentPresenter.Triggers>
                                    </ContentPresenter>
                                </Border>
                            </Viewport2DVisual3D>
                        </Viewport3D>

                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <EventTrigger RoutedEvent="ContentControl.MouseLeftButtonDown" >
                  //Axis Animation
                </EventTrigger>
                <EventTrigger RoutedEvent="ContentControl.MouseEnter">
                   //ScaleAnimation
                               </EventTrigger>
                <EventTrigger RoutedEvent="ContentControl.MouseLeave">
                   //ScaleAnimation
                </EventTrigger>
            </Style.Triggers>
        </Style>

    </Page.Resources>

    <Page.Triggers>
        <EventTrigger RoutedEvent="Loaded">
            //Load Object Scale And Fade In
        </EventTrigger>
    </Page.Triggers>

    <Grid Name="MainGrid">


                 <Canvas Name="MainCanvas" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" FlowDirection="LeftToRight">
            <ContentControl Opacity="0" Name="MenuItem1" Style="{StaticResource MenuItemsStyle}" 
                            MouseDown="MenuItem1_MouseDown" Panel.ZIndex="1" >
                <Image Source="/IsargaranProject;component/Images/isargari.jpg"/>
                <ContentControl.RenderTransform>
                    <ScaleTransform ScaleX="0.7" ScaleY="0.7"  x:Name="MenuItem1ST"/>
                </ContentControl.RenderTransform>
            </ContentControl>
        </Canvas>

    </Grid>
</Page>

如果您正在使用OPENGL或DirectX3D,那么看到没有渲染的笔记本电脑,将会有一些像DirectX 3D一样的缺失插件,或者OpenGL你可以试试这两个3D渲染工具。我试过这个在过去我做了一个Graph程序它有同样的问题,但当我安装OPENGL和DirectX3D它工作正常!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM