Exemplo n.º 1
0
 private bool CameraHasDefaultOrientation()
 {
     var defaultData = new CameraData();
     var cam = ((HelixWatch3DViewModel)ViewModel.BackgroundPreviewViewModel).Camera;
     return cam.Position == defaultData.EyePosition &&
         cam.LookDirection == defaultData.LookDirection &&
         cam.UpDirection == defaultData.UpDirection;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Create a CameraData object from an XmlNode representing the Camera's serialized
        /// position data.
        /// </summary>
        /// <param name="cameraNode">The XmlNode containing the camera position data.</param>
        /// <returns></returns>
        public CameraData DeserializeCamera(XmlNode cameraNode)
        {
            if (cameraNode.Attributes == null || cameraNode.Attributes.Count == 0)
            {
                return new CameraData();
            }

            try
            {
                var name = cameraNode.Attributes["Name"].Value;
                var ex = float.Parse(cameraNode.Attributes["eyeX"].Value, CultureInfo.InvariantCulture);
                var ey = float.Parse(cameraNode.Attributes["eyeY"].Value, CultureInfo.InvariantCulture);
                var ez = float.Parse(cameraNode.Attributes["eyeZ"].Value, CultureInfo.InvariantCulture);
                var lx = float.Parse(cameraNode.Attributes["lookX"].Value, CultureInfo.InvariantCulture);
                var ly = float.Parse(cameraNode.Attributes["lookY"].Value, CultureInfo.InvariantCulture);
                var lz = float.Parse(cameraNode.Attributes["lookZ"].Value, CultureInfo.InvariantCulture);
                var ux = float.Parse(cameraNode.Attributes["upX"].Value, CultureInfo.InvariantCulture);
                var uy = float.Parse(cameraNode.Attributes["upY"].Value, CultureInfo.InvariantCulture);
                var uz = float.Parse(cameraNode.Attributes["upZ"].Value, CultureInfo.InvariantCulture);

                var camData = new CameraData
                {
                    Name = name,
                    EyePosition = new Point3D(ex, ey, ez),
                    LookDirection = new Vector3D(lx, ly, lz),
                    UpDirection = new Vector3D(ux, uy, uz)
                };

                return camData;
            }
            catch (Exception ex)
            {
                logger.LogError(Properties.Resources.CameraDataLoadError);
                logger.Log(ex);
            }

            return new CameraData();
        }
Exemplo n.º 3
0
 public void SetCameraData(CameraData data)
 {
     Camera.LookDirection = data.LookDirection;
     Camera.Position = data.EyePosition;
     Camera.UpDirection = data.UpDirection;
     Camera.NearPlaneDistance = data.NearPlaneDistance;
     Camera.FarPlaneDistance = data.FarPlaneDistance;
 }
Exemplo n.º 4
0
        public static CameraData ToCameraData(this PerspectiveCamera camera, string name)
        {
            var camData = new CameraData
            {
                Name = name,
                LookDirection = camera.LookDirection,
                EyePosition = camera.Position,
                UpDirection = camera.UpDirection,
                NearPlaneDistance = camera.NearPlaneDistance,
                FarPlaneDistance = camera.FarPlaneDistance
            };

            return camData;
        }