Click here to Skip to main content
15,943,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have created a 3D object in wpf 3d and used prospective camera the positions are changed by mouse move event.

below are the xaml code

  d:DesignHeight="300" d:DesignWidth="600">
<Grid Name="objGrid" MouseDown="Grid_MouseDown" MouseUp="Grid_MouseUp" MouseMove="Grid_MouseMove"  Focusable="True">

    <Border Name="border" Background="White" MouseDown="border_MouseDown"
    Padding="25"  Margin="0,-21,0,10">

        <Viewport3D Name="mainViewPort"  ClipToBounds="True" Opacity="10">
            <Viewport3D.Camera >
                <PerspectiveCamera x:Name="camera"
      LookDirection="0, 0, -5"
      Position="0, 0, 5"
      FieldOfView="50" />
                    <AmbientLight x:Name="directionLightOfMainViewPort" Color="White"/>

i want to manually set the camera position in a button click event.
i.e, i want that faces of the object appear in button click event .

What I have tried:

i want to do it on cs file not in xaml...

i had tried following code..

TranslateTransform3D obj = new TranslateTransform3D();
            //solidCubeMV3D.Transform.Value.OffsetX = 0;

            //Vector3D lookDirection = new Vector3D(0, 0, -5);
            Vector3D updirection = new Vector3D(0, 1, 0);
            Point3D position = new Point3D(0, 0, 5);
            //camera.LookDirection = lookDirection;
            camera.UpDirection = updirection;
            camera.Position = position;           
                //camera.ChangeDirection(new Vector3D(0, 0, -5),new Vector3D(0,1,0),0.5);           
             mainViewPort.Camera =;
              // camera.Transform = new Transform3DGroup();
             //camera.Transform = trackball.Transform;           
            //solidCubeMV3D.Transform = camera.Transform;   
           //  trackball.EventSource = objGrid;
          //  camera.Transform = trackball.Transform;
         // objGrid.MouseWheel += new System.Windows.Input.MouseWheelEventHandler(objGrid_MouseWheel);      

please help me how to do as i am new to wpf
Updated 15-Dec-16 20:35pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900