Ejemplo n.º 1
0
        /*
         * public Ray GetRayFromScreenPoint(Vector2 screen) {
         * var screenX = screen.X;
         * var screenY = screen.Y;
         * var scaleFactor = new Vector2(1, 1);
         * // Normalized Device Coordinates Top-Left (-1, 1) to Bottom-Right (1, -1)
         * float x = (2.0f * screenX) / (prevScreenWidth / scaleFactor.X) - 1.0f;
         * float y = 1.0f - (2.0f * screenY) / (prevScreenHeight / scaleFactor.Y);
         * float z = 1.0f;
         * Vector3 deviceCoords = new Vector3(x, y, z);
         *
         * // Clip Coordinates
         * Vector4 clipCoords = new Vector4(deviceCoords.X, deviceCoords.Y, -1.0f, 1.0f);
         *
         * // View Coordinates
         * Matrix4x4.Invert(ProjectionMatrix, out Matrix4x4 invProj);
         * Vector4 viewCoords = Vector4.Transform(clipCoords, invProj);
         * viewCoords.Z = -1.0f;
         * viewCoords.W = 0.0f;
         *
         * Matrix4x4.Invert(ViewMatrix, out Matrix4x4 invView);
         * Vector3 worldCoords = Vector4.Transform(viewCoords, invView).XYZ();
         * worldCoords = Vector3.Normalize(worldCoords);
         *
         * return new Ray(Position, worldCoords);
         * }*/

        protected override void CreateState(out CameraState state)
        {
            state = CameraState.OrthographicState();
        }