示例#1
0
        private void DMakeLightMap()
        {
            Game1.graphicsDevice.SetRenderTargets(null);
            Game1.graphicsDevice.SetRenderTarget(LightMap);
            Game1.graphicsDevice.Clear(Color.Transparent);
            Game1.graphicsDevice.BlendState        = LightMapBS;
            Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;


            Game1.graphicsDevice.Textures[0]      = GBufferTargets[0].RenderTarget;
            Game1.graphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;

            Game1.graphicsDevice.SamplerStates[1] = SamplerState.PointWrap;
            Game1.graphicsDevice.Textures[1]      = GBufferTargets[1].RenderTarget;

            MasterManager.SetViewportToFullscreen();

            foreach (GameObject g in OverLightingChildren)
            {
                g.Draw3D(DrawCamera, GameObjectTag._3DDeferredOverLighting);
            }

#if EDITOR && WINDOWS
            if (ParentLevel.LevelForEditing && DrawCamera != null)
            {
                DrawCamera.MakeInverse();
                foreach (GameObject g in WorldLightingChildren)
                {
                    g.Draw3D(DrawCamera, GameObjectTag._3DDeferredOverLighting);
                }
            }
            else
#endif
            {
                int      i             = 0;
                Camera3D currentCamera = null;

                foreach (WorldViewer3D s in WorldViewerChildren)
                {
                    Render.ViewIndex = i++;
                    s.getSceneView().Set();
                    currentCamera = s.getCamera();

                    currentCamera.MakeInverse();
                    foreach (GameObject g in WorldLightingChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DDeferredOverLighting);
                    }
                }
            }
        }
示例#2
0
        private void model1_CameraMoveEnd(object sender, Model.CameraMoveEventArgs e)
        {
            // removes previous camera drawing
            if (Camera != null)
            {
                Camera.DeletePrevious(model2);
            }

            // draws new camera and new view model of model1 in model2
            Camera = new DrawCamera(model1.Viewports[0], model1.Size.Height, "Camera");
            Camera.Draw(model2);

            for (int i = 0; i < 8; i++)
            {
                Lights[i].MoveIfStationary(model2);
            }

            model2.Entities.Regen();
            model2.Invalidate();
        }
        public override void PreDraw()
        {
            Game1.graphicsDevice.SetRenderTarget(FinalTarget);
            Game1.graphicsDevice.Clear(Color.Black);

#if EDITOR && WINDOWS
            if (ParentLevel.LevelForEditing && DrawCamera != null)
            {
                DrawCamera.SetOffset(Vector2.Zero);
                DrawCamera.SetMult(Vector2.One);

                Game1.graphicsDevice.BlendState        = BlendState.AlphaBlend;
                Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;

                Draw3D(DrawCamera, GameObjectTag._3DForward);
            }
            else
#endif
            {
                int      i             = 0;
                Camera3D currentCamera = null;

                foreach (WorldViewer3D s in WorldViewerChildren)
                {
                    Game1.graphicsDevice.BlendState        = BlendState.Opaque;
                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;

                    Render.ViewIndex = i++;
                    s.getSceneView().Set();
                    currentCamera = s.getCamera();

                    Draw3D(currentCamera, GameObjectTag._3DForward);
                }
            }

            base.PreDraw();
        }
示例#4
0
        private void DMakeFinalPass()
        {
            Game1.graphicsDevice.SetRenderTarget(FinalTarget);
            Game1.graphicsDevice.Clear(Color.Black);

            Game1.graphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;


#if EDITOR && WINDOWS
            if (ParentLevel.LevelForEditing && DrawCamera != null)
            {
                DrawCamera.SetOffset(Vector2.Zero);
                DrawCamera.SetMult(Vector2.One);

                Game1.graphicsDevice.BlendState        = BlendState.Opaque;
                Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;

                foreach (GameObject g in BackgroundChildren)
                {
                    g.Draw3D(DrawCamera, GameObjectTag._3DBackground);
                }

                Game1.graphicsDevice.DepthStencilState = DepthStencilState.Default;

                if (deferredControls.deferredMode == DeferredMode.Basic)
                {
                    Game1.graphicsDevice.Textures[0] = Render.TransparentTexture;
                }
                else
                {
                    Game1.graphicsDevice.Textures[0] = LightMap;
                }

                foreach (GameObject g in ForwardChildren)
                {
                    g.Draw3D(DrawCamera, GameObjectTag._3DForward);
                }

                Game1.graphicsDevice.DepthStencilState = DepthStencilState.DepthRead;
                Game1.graphicsDevice.BlendState        = BlendState.AlphaBlend;

                foreach (GameObject g in DepthOverChildren)
                {
                    g.Draw3D(DrawCamera, GameObjectTag._3DForward);
                }
            }
            else
#endif
            {
                int      i             = 0;
                Camera3D currentCamera = null;

                foreach (WorldViewer3D s in WorldViewerChildren)
                {
                    Game1.graphicsDevice.BlendState        = BlendState.Opaque;
                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;

                    Render.ViewIndex = i++;
                    s.getSceneView().Set();
                    currentCamera = s.getCamera();
                    foreach (GameObject g in BackgroundChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DBackground);
                    }

                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.Default;

#if EDITOR && WINDOWS
                    if (deferredControls.deferredMode == DeferredMode.Basic)
                    {
                        Game1.graphicsDevice.Textures[0] = Render.TransparentTexture;
                    }
                    else
#endif
                    Game1.graphicsDevice.Textures[0] = LightMap;

                    foreach (GameObject g in ForwardChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DForward);
                    }

                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.DepthRead;
                    Game1.graphicsDevice.BlendState        = BlendState.AlphaBlend;
                    foreach (GameObject g in DepthOverChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DForward);
                    }
                }
            }
        }