Example #1
0
        private void SetupStereoCamera()
        {
            StereoCamera camera = new StereoCamera();
            camera.Translation = new Vector3(0, 0, 0);
            camera.FieldOfViewY = (float)Math.PI / 4;
            // For stereo camera, you need to setup the interpupillary distance which is the distance
            // between the left and right eyes
            camera.InterpupillaryDistance = 19.31f;
            CameraNode cameraNode = new CameraNode(camera);

            scene.RootNode.AddChild(cameraNode);
            scene.CameraNode = cameraNode;

            // The stereo mode only works correctly when it's in full screen mode when iWear VR920
            // is used
            if (iTracker.ProductID == iWearDllBridge.IWRProductID.IWR_PROD_VR920)
            {
                graphics.IsFullScreen = true;
                graphics.ApplyChanges();
            }
        }
Example #2
0
        private void CreateCamera()
        {
            // Set up the camera of the scene graph
            Camera camera = new Camera();
            // Put the camera at (0, 0, 0)
            camera.Translation = new Vector3(0, 50, 120);
            // Rotate the camera -45 degrees along the X axis
            camera.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX,
                MathHelper.ToRadians(-30));
            // Set the vertical field of view to be 45 degrees
            camera.FieldOfViewY = MathHelper.ToRadians(45);
            // Set the near clipping plane to be 0.1f unit away from the camera
            camera.ZNearPlane = 0.1f;
            // Set the far clipping plane to be 1000 units away from the camera
            camera.ZFarPlane = 1000;

            // Now assign this camera to a camera node, and add this camera node to our scene graph
            CameraNode cameraNode = new CameraNode(camera);
            scene.RootNode.AddChild(cameraNode);

            // Assign the camera node to be our scene graph's current camera node
            scene.CameraNode = cameraNode;
        }
Example #3
0
        private void CreateCamera()
        {
            // Create a camera
            Camera camera = new Camera();
            // Put the camera at (0, 0, 10)
            camera.Translation = new Vector3(0, 0, 10);
            // Set the vertical field of view to be 60 degrees
            camera.FieldOfViewY = MathHelper.ToRadians(60);
            // Set the near clipping plane to be 0.1f unit away from the camera
            camera.ZNearPlane = 0.1f;
            // Set the far clipping plane to be 1000 units away from the camera
            camera.ZFarPlane = 1000;

            // Now assign this camera to a camera node, and add this camera node to our scene graph
            CameraNode cameraNode = new CameraNode(camera);
            scene.RootNode.AddChild(cameraNode);

            // Assign the camera node to be our scene graph's current camera node
            scene.CameraNode = cameraNode;
        }
 /// <summary>
 /// This shader does not support special camera effect.
 /// </summary>
 /// <param name="camera"></param>
 public virtual void SetParameters(CameraNode camera)
 {
     cameraPosition.SetValue(camera.WorldTransformation.Translation);
 }
Example #5
0
        private void CreateCamera()
        {
            // Set up the camera of the scene graph
            Camera camera = new Camera();
            // Put the camera at (0, 3, 7)
            camera.Translation = new Vector3(0, 3, 7);
            // Rotate the camera -15 degrees along the X axis
            camera.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX,
                MathHelper.ToRadians(-15));
            // Set the vertical field of view to be 45 degrees
            camera.FieldOfViewY = MathHelper.ToRadians(45); 
            // Set the near clipping plane to be 0.1f unit away from the camera
            camera.ZNearPlane = 0.1f;
            // Set the far clipping plane to be 1000 units away from the camera
            camera.ZFarPlane = 1000;

            // Set the initial translation and rotation of the generic input which controls 
            // the camera transform in this application
            GenericInput.Instance.InitialTranslation = camera.Translation;
            GenericInput.Instance.InitialRotation = camera.Rotation;

            // Adjust the speed of the camera control
            GenericInput.Instance.PanSpeed = 0.05f;
            GenericInput.Instance.ZoomSpeed = 0.5f;
            GenericInput.Instance.RotateSpeed = 0.02f;

            // Now assign this camera to a camera node
            CameraNode cameraNode = new CameraNode(camera);

            // Add a transform node which will be updated based on GenericInput class
            // which implements simple camera rotation and translation based on mouse
            // drag and key presses.
            // To rotate the camera, hold right mouse button and drag around
            genericInputNode = new TransformNode();

            scene.RootNode.AddChild(genericInputNode);
            genericInputNode.AddChild(cameraNode);

            // Assign the camera node to be our scene graph's current camera node
            scene.CameraNode = cameraNode;
        }
Example #6
0
        private void SetupStereoCamera()
        {
            StereoCamera camera = new StereoCamera();

            // Load the right eye view matrix from a calibration file created in StereoCameraCalibration tool
            Matrix cameraRightView = Matrix.Identity;
            MatrixHelper.LoadMatrixFromXML("Wrap920_1_Stereo_Millimeter.xml", ref cameraRightView);

            camera.LeftView = Matrix.CreateLookAt(Vector3.Zero, -Vector3.UnitZ, Vector3.UnitY);
            camera.RightView = Matrix.Invert(cameraRightView);

            CameraNode cameraNode = new CameraNode(camera);

            scene.RootNode.AddChild(cameraNode);
            scene.CameraNode = cameraNode;
        }
        private void CreateCamera()
        {
            // Create a camera for 2D visualization 
            staticCamera = new Camera();
            staticCamera.Translation = new Vector3(0, 0, 0);
            staticCamera.FieldOfViewY = MathHelper.ToRadians(45);
            staticCamera.ZNearPlane = 1.0f;
            staticCamera.ZFarPlane = 1000;
            staticCamera.AspectRatio = (float)(graphics.PreferredBackBufferWidth / graphics.PreferredBackBufferHeight);

            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(staticCamera.FieldOfViewY, staticCamera.AspectRatio,
                                                        staticCamera.ZNearPlane, staticCamera.ZFarPlane);
            viewMatrix = Matrix.CreateLookAt(new Vector3(0,0,-10),Vector3.Zero, Vector3.Up);
            staticCamera.View = viewMatrix;
            staticCamera.Projection = projectionMatrix;
          
            // Now assign camera to a camera node, and add this camera node to our scene graph
            staticCameraNode = new CameraNode(staticCamera);
            scene.RootNode.AddChild(staticCameraNode);

            scene.CameraNode = staticCameraNode;

        }
        private void CreateCamera()
        {
            // Create a camera
            Camera camera = new Camera();
            // Put the camera at (0,0,5)
            camera.Translation = new Vector3(0, 0, 5);
            // Set the vertical field of view to be 60 degrees
            camera.FieldOfViewY = MathHelper.ToRadians(60);
            // Set the near clipping plane to be 0.1f unit away from the camera
            camera.ZNearPlane = 0.1f;
            // Set the far clipping plane to be 1000 units away from the camera
            camera.ZFarPlane = 1000;

            myCameraNode = new TransformNode();
            myCameraNode.Translation = Vector3.Zero;
            myCameraNode1 = new TransformNode();
            myCameraNode1.Translation = Vector3.Zero;
            myCameraNode2 = new TransformNode();
            myCameraNode2.Translation = Vector3.Zero;

            cameraNode = new CameraNode(camera);

            scene.RootNode.AddChild(myCameraNode);
            myCameraNode.AddChild(myCameraNode1);
            myCameraNode1.AddChild(myCameraNode2);
            myCameraNode2.AddChild(cameraNode);

            // Assign the camera node to be our scene graph's current camera node
            scene.CameraNode = cameraNode;
        }
        private void CreateCameras()
        {
            // Create the main camera
            mainCamera = new Camera();
            mainCamera.Translation = new Vector3(0, -30, -100);
            mainCamera.ZNearPlane = 1;
            mainCamera.ZFarPlane = 2000;

            mainCameraNode = new CameraNode(mainCamera);
            scene.RootNode.AddChild(mainCameraNode);

            // Create the flying camera
            flyingCamera = new Camera();
            flyingCamera.Translation = new Vector3(0, 0, 200);
            flyingCamera.ZNearPlane = 1;
            flyingCamera.ZFarPlane = 2000;

            cameraTrans = new TransformNode();

            flyingCameraNode = new CameraNode(flyingCamera);
            groundMarkerNode.AddChild(cameraTrans);
            cameraTrans.AddChild(flyingCameraNode);

            scene.CameraNode = mainCameraNode;
        }
Example #10
0
        private void SetupStereoCamera()
        {
            StereoCamera camera = new StereoCamera();
            camera.Translation = new Vector3(0, 0, 0);

            CameraNode cameraNode = new CameraNode(camera);

            scene.RootNode.AddChild(cameraNode);
            scene.CameraNode = cameraNode;
        }
Example #11
0
        private void CreateCameras()
        {
            // Create a camera for VR scene 
            Camera vrCamera = new Camera();
            vrCamera.Translation = new Vector3(0, -280, 480);
            vrCamera.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(45));
            vrCamera.FieldOfViewY = MathHelper.ToRadians(60);
            vrCamera.ZNearPlane = 1;
            vrCamera.ZFarPlane = 2000;

            vrCameraNode = new CameraNode(vrCamera);
            scene.RootNode.AddChild(vrCameraNode);

            // Create a camera for AR scene
            Camera arCamera = new Camera();
            arCamera.ZNearPlane = 1;
            arCamera.ZFarPlane = 2000;

            arCameraNode = new CameraNode(arCamera);
            scene.RootNode.AddChild(arCameraNode);

            // Set the AR camera to be the main camera so that at the time of setting up the marker tracker,
            // the marker tracker will assign the right projection matrix to this camera
            scene.CameraNode = arCameraNode;
        }
Example #12
0
        /// <summary>
        /// Creates a camera that chases a given object.
        /// </summary>
        /// <param name="chasedObject"></param>
        private void CreateChasingCamera(GeometryNode chasedObject)
        {
            // Set up the camera of the scene graph
            Camera camera = new Camera();

            camera.Translation = new Vector3(5, 3, 0);
            // Rotate the camera -20 degrees along the X axis
            camera.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, 
                MathHelper.ToRadians(90)) * Quaternion.CreateFromAxisAngle(Vector3.UnitX,
                MathHelper.ToRadians(-20));
            // Set the vertical field of view to be 60 degrees
            camera.FieldOfViewY = MathHelper.ToRadians(45);
            // Set the near clipping plane to be 0.1f unit away from the camera
            camera.ZNearPlane = 0.1f;
            // Set the far clipping plane to be 1000 units away from the camera
            camera.ZFarPlane = 1000;

            // Add this camera node to a geometry node we want to chase for
            CameraNode cameraNode = new CameraNode("ChasingCamera", camera);
            chasedObject.AddChild(cameraNode);

            // Initially assign the chasing camera to be our scene graph's active camera node
            scene.CameraNode = cameraNode;
        }
Example #13
0
        private void CreateStaticCamera(bool near)
        {
            // Set up the camera of the scene graph
            Camera camera = new Camera();

            if (near)
                camera.Translation = new Vector3(0, 0, 0);
            else
                camera.Translation = new Vector3(0, 10, 55);

            // Rotate the camera -20 degrees along the X axis
            camera.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX,
                MathHelper.ToRadians(-20));
            // Set the vertical field of view to be 45 degrees
            camera.FieldOfViewY = MathHelper.ToRadians(45);
            // Set the near clipping plane to be 0.1f unit away from the camera
            camera.ZNearPlane = 0.1f;
            // Set the far clipping plane to be 1000 units away from the camera
            camera.ZFarPlane = 1000;

            String prefix = (near) ? "Near" : "Far";
            // Add this camera node to our scene graph
            CameraNode cameraNode = new CameraNode(prefix + "Camera", camera);
            scene.RootNode.AddChild(cameraNode);
        }
        private void CreateCamera()
        {
            // Create a camera
            Camera camera = new Camera();

            if (State.IsServer)
            {
                camera.Translation = new Vector3(0, 5, 10);
                camera.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(-25));
            }
            else
            {
                camera.Translation = new Vector3(0, 0, -30);
                camera.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathHelper.Pi);
            }
            // Set the vertical field of view to be 60 degrees
            camera.FieldOfViewY = MathHelper.ToRadians(60);
            // Set the near clipping plane to be 0.1f unit away from the camera
            camera.ZNearPlane = 0.1f;
            // Set the far clipping plane to be 1000 units away from the camera
            camera.ZFarPlane = 1000;

            // Now assign this camera to a camera node, and add this camera node to our scene graph
            CameraNode cameraNode = new CameraNode(camera);
            scene.RootNode.AddChild(cameraNode);

            // Assign the camera node to be our scene graph's current camera node
            scene.CameraNode = cameraNode;
        }
Example #15
0
        public override void SetParameters(CameraNode camera)
        {
            cameraPos = camera.WorldTransformation.Translation;

            cameraPosition.SetValue(cameraPos);
        }
Example #16
0
 /// <summary>
 /// This shader does not support special camera effect.
 /// </summary>
 /// <param name="camera"></param>
 public virtual void SetParameters(CameraNode camera)
 {
 }
Example #17
0
        private void SetupStereoCamera()
        {
            // Create a stereo camera
            StereoCamera camera = new StereoCamera();
            camera.Translation = new Vector3(0, 0, 0);

            // Set the interpupillary distance which defines the distance between the left
            // and right eyes
#if VR
            camera.InterpupillaryDistance = 5.5f; // 5.5 cm
#else
            camera.InterpupillaryDistance = 20; 
#endif
            // Set the focal distance to be at infinity
            camera.FocalLength = float.MaxValue;

            CameraNode cameraNode = new CameraNode(camera);

            scene.RootNode.AddChild(cameraNode);
            scene.CameraNode = cameraNode;
        }