예제 #1
0
        /// <summary>
        /// Renders a scene from the perspective of a single, pre-configured drawing device.
        /// </summary>
        /// <param name="scene"></param>
        /// <param name="drawDevice"></param>
        /// <param name="viewportRect"></param>
        /// <param name="imageSize"></param>
        /// <param name="outputTargetRect"></param>
        public void RenderPointOfView(Scene scene, DrawDevice drawDevice, Rect viewportRect, Vector2 imageSize)
        {
            // Memorize projection matrix settings, so the drawing device can be properly reset later
            RenderMatrix oldDeviceMatrix     = drawDevice.RenderMode;
            Vector2      oldDeviceTargetSize = drawDevice.TargetSize;

            try
            {
                this.OnRenderPointOfView(scene, drawDevice, viewportRect, imageSize);
            }
            catch (Exception e)
            {
                Console.WriteLine("There was an error while {0} was rendering a point of view in {1}: {2}", this, scene, /*LogFormat.Exception(*/ e /*)*/);
            }

            // Reset matrices for projection calculations to their previous state
            drawDevice.RenderMode = oldDeviceMatrix;
            drawDevice.TargetSize = oldDeviceTargetSize;
            drawDevice.UpdateMatrices();
        }