3d渲染的对象

时间:2012-10-07 20:58:41

标签: c# wpf 3d

我有一个有主窗口的WPF应用程序。我有一个框架,框架内容是一个页面。

现在页面中有4个包含Viewport2DVisual3D的viewport3D,并且我有图像元素。

问题:在某些PC上我的应用程序运行良好但在某些PC上我的应用程序不呈现viewport3d或它不呈现帧。 Dunno但它在主窗口中没有显示任何内容。

问题出现在Acer笔记本电脑Model上。

呈现: True Image

未呈现: enter image description here

编辑: 当我将框架放在网格中时,会再次出现此问题。 (我在一个框架中显示此页面,该框架是我窗口的主要内容:当我将框架放在网格中时,它没有显示对象) 在具有共享图形的笔记本电脑上看似这个Occure

编辑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>

1 个答案:

答案 0 :(得分:1)

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