Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

3d object not rendered

Tags:

c#

wpf

3d

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 : True Image

Not Rendered : enter image description here

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>
like image 307
Mamad R Avatar asked Oct 07 '12 20:10

Mamad R


People also ask

Why My object is not showing in render?

Objects may be disabled for rendering in the Outliner If disabled, an object can't be selected in the viewport. The Eye icon is to toggle object visibility on the 3D viewport. The Camera Icon toggles Rendering. If disabled on an object, that object will not appear on your renders.

Why is my object not showing up in Blender?

If you're sure that nothing is hidden, next try to make all layers visible and check to be sure that you didn't inadvertently move your object to a different layer. You do so by pressing the Tilde (~) key. You may also want to press Home in the 3D View to bring all objects into view.

Why is my render image black?

Sometimes you find yourself trying to do a nice-looking render and when the rendering time has finished it turns out that the image is completely black! Here are some possible reasons why your render is black: The compositor node is not connected to the output. The objects are hidden or disabled for rendering.


1 Answers

If you are using OPENGL or DirectX3D, then see that the laptop which is not rendering, will have some missing plugins like DirectX 3D wouldn't be installed or OpenGL you can try this two 3D Rendering tools for the same.. i had tried this in past i had made a Graph program it was having the same problem, but when i installed OPENGL & DirectX3D it was working fine!

like image 91
Ashwani Pathak Avatar answered Oct 15 '22 00:10

Ashwani Pathak