예제 #1
0
        public static DepthFunction To(DepthTestFunction function)
        {
            switch (function)
            {
            case DepthTestFunction.Never:
                return(DepthFunction.Never);

            case DepthTestFunction.Less:
                return(DepthFunction.Less);

            case DepthTestFunction.Equal:
                return(DepthFunction.Equal);

            case DepthTestFunction.LessThanOrEqual:
                return(DepthFunction.Lequal);

            case DepthTestFunction.Greater:
                return(DepthFunction.Greater);

            case DepthTestFunction.NotEqual:
                return(DepthFunction.Notequal);

            case DepthTestFunction.GreaterThanOrEqual:
                return(DepthFunction.Gequal);

            case DepthTestFunction.Always:
                return(DepthFunction.Always);
            }

            throw new ArgumentException("function");
        }
예제 #2
0
        /// <summary>
        /// Paint another RenderBuffer over this one
        /// </summary>
        public void BitBlockTransfer(RenderBuffer r, int offsetX, int offsetY)
        {
            // Guard against x & y overflow/underflow
            int width  = Math.Min(Width, offsetX + r.Width);
            int height = Math.Min(Height, offsetY + r.Height);
            int startX = Math.Max(offsetX, 0);
            int startY = Math.Max(offsetY, 0);

            // save depth test
            DepthTestFunction oldDepthTest = depthTest;

            depthTest = DepthTestFunction.Always;
            // Render
            for (int y = startY; y < height; y++)
            {
                for (int x = startX; x < width; x++)
                {
                    frameBuffer[x, y]     = r.frameBuffer[x - offsetX, y - offsetY];
                    toleranceBuffer[x, y] = r.toleranceBuffer[x - offsetX, y - offsetY];
                    zBuffer[x, y]         = r.zBuffer[x - offsetX, y - offsetY];
                }
            }
            // restore depth test
            depthTest = oldDepthTest;
        }
예제 #3
0
        /// <summary/>
        public SceneRenderer(Size windowSize, Viewport3D viewport, Color background, DepthTestFunction depthTest)
        {
            //

            RenderTolerance.IgnoreViewportBorders = true;

            InitializeThis(
                viewport.Camera,
                ExtractModels(viewport.Children),
                new Bounds(windowSize, ComputeBounds(viewport), viewport.ClipToBounds),
                background,
                depthTest);
        }
예제 #4
0
        private void InitializeThis(Camera camera, Model3DGroup scene, Bounds bounds, Color background, DepthTestFunction depthTest)
        {
            this.background = background;
            bounds.ConvertToAbsolutePixels();

            ExtractLightsAndPrimitives(scene);

            this.camera = camera.CloneCurrentValue();
            AdjustCamera(this.camera, scene);

            // If we are set for 4XAA, we render the model 4 times as big
            if (SceneRenderer.enableAntiAliasedRendering)
            {
                bounds.ScaleWidthAndHeight(2);
            }

            // Create the buffer for this scene
            //For integer conversion, bound on ceiling for consistency w/Dev Bits
            buffer = new RenderBuffer((int)Math.Ceiling(bounds.WindowSize.Width), (int)Math.Ceiling(bounds.WindowSize.Height));

            renderer           = new ModelRenderer(bounds, this.camera, buffer, lights);
            renderer.DepthTest = depthTest;

            this.bounds      = bounds;
            this.opacity     = 1.0;
            this.opacityMask = null;
            this.clip        = null;
            this.transform   = null;
            this.effect      = null;
            this.effectInput = null;
        }
예제 #5
0
 /// <summary/>
 public SceneRenderer(Camera camera, Model3DGroup scene, Bounds bounds, Color background, DepthTestFunction depthTest)
 {
     InitializeThis(camera, scene, bounds, background, depthTest);
 }
예제 #6
0
        /// <summary/>
        public SceneRenderer(Size windowSize, Viewport3DVisual visual, Color background, DepthTestFunction depthTest)
        {
            bool clipToBounds = visual.Clip != null && MathEx.ContainsCloseEnough(visual.Viewport, visual.Clip.Bounds);

            InitializeThis(
                visual.Camera,
                ExtractModels(visual.Children),
                new Bounds(windowSize, visual.Viewport, clipToBounds),
                background,
                depthTest);
        }
예제 #7
0
        public static DepthFunction To(DepthTestFunction function)
        {
            switch (function)
            {
                case DepthTestFunction.Never:
                    return DepthFunction.Never;
                case DepthTestFunction.Less:
                    return DepthFunction.Less;
                case DepthTestFunction.Equal:
                    return DepthFunction.Equal;
                case DepthTestFunction.LessThanOrEqual:
                    return DepthFunction.Lequal;
                case DepthTestFunction.Greater:
                    return DepthFunction.Greater;
                case DepthTestFunction.NotEqual:
                    return DepthFunction.Notequal;
                case DepthTestFunction.GreaterThanOrEqual:
                    return DepthFunction.Gequal;
                case DepthTestFunction.Always:
                    return DepthFunction.Always;
            }

            throw new ArgumentException("function");
        }