Changing 2D to 3D

Now i've just take a look at this 3d WPF HOL

to make everything inside a grid, which is just ordinary 2d . To become a 3D

just download the 3d Tools on code plex, reference it on your WPF project

add a reference for the namespace in your xaml xmlns:tools="clr-namespace:_3DTools;assembly=3DTools"

<Grid>
       
        <tools:TrackballDecorator>
            <tools:Interactive3DDecorator>
                <Viewport3D>
                    <Viewport3D.Camera>
                        <PerspectiveCamera Position="0,0,-10" LookDirection="0,0,1"
                               UpDirection="0,1,0" FieldOfView="45" />
                    </Viewport3D.Camera>

                    <tools:InteractiveVisual3D>
                        <tools:InteractiveVisual3D.Geometry>
                            <MeshGeometry3D Positions="-3,-1,1.5 3,-1,1.5 -3,-1,0 3,-1,0 -3,1,0 3,1,0 -3,1,1.5 3,1,1.5"
                              TextureCoordinates="1,1 0,1 0.75,1 0.25,1 0.75,0 0.25,0 1,0 0,0"

                              TriangleIndices="0,6,4 0,4,2 2,4,5 2,5,3 3,5,1 1,5,7" />
                        </tools:InteractiveVisual3D.Geometry>

                        <tools:InteractiveVisual3D.Visual>

     --------------------BELOW IS YOUR CONTENT---------------------------------------------

    ---------------------Till here----------------------------------------------------------------------------

        </tools:InteractiveVisual3D.Visual>
                    </tools:InteractiveVisual3D>

                    <ModelVisual3D>
                        <ModelVisual3D.Content>
                            <Model3DGroup>

                                <!-- All 3D models require a light source to look right -->
                                <AmbientLight Color="White" />

                            </Model3DGroup>
                        </ModelVisual3D.Content>
                    </ModelVisual3D>
                </Viewport3D>
            </tools:Interactive3DDecorator>
        </tools:TrackballDecorator>
        
    </Grid>

</Window>
 

When you take a look Whoalah, it's 3d, very nice tool and wpf right?

Cool

Share this post: | | | |
Published Wednesday, October 29, 2008 3:20 PM by cipto
Filed under:

Comments

No Comments