views:

22

answers:

2

Hi

I am having problem in displaying th Image in viewport3d of wpf.

    <Grid>
    <Image Source="G:\Demo\virtualization\virtualization\2.jpg"/>
    <Viewport3D Name="mainViewport" ClipToBounds="True" HorizontalAlignment="Stretch" Height="300">
        <Viewport3D.Camera>
            <PerspectiveCamera 
              LookDirection="0,0,-20"
              UpDirection="0,1,0"
              Position="-40,40,40" 
              />
        </Viewport3D.Camera>
        <Viewport2DVisual3D>
            <Image Source="G:\Demo\virtualization\virtualization\img3.bmp"/>
        </Viewport2DVisual3D>
    </Viewport3D>
</Grid>

Above is the code I am using. The first image that is behind the viewport3d is displayed but the image which is inside the viewport3d is not displayed.

Where I am doing wrong?

Please help!

Thanks

A: 

You need a material. See if inserting this just above the image tag helps:

    <Viewport2DVisual3D.Material>
        <DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" Brush="White"/>
    </Viewport2DVisual3D.Material>  

Edit: taken from MSDN documentation. Can't try it right now, but you might also need other tags as specified in the example here: http://msdn.microsoft.com/de-de/library/system.windows.media.media3d.viewport2dvisual3d.aspx

Botz3000
thanks... i will try and will post if it works!!!
Vinod Maurya
it worked... I have added material, geometry and light to make it work.
Vinod Maurya
A: 

You need

  • Material
  • Geometery
  • Light

In order to correctly display your element

Hasan Khan