protected override void SetWorldAndRenderTechnich(out RenderTechnich2D renderTech, out I2DWorld world)
 {
     Basic2DRenderTechnich rt = new Basic2DRenderTechnich();            
     rt.RenderBackGround += new RenderBackGround(rt_RenderBackGround);
     renderTech = rt;            
     world = new I2DWorld(new FarseerWorld(new Vector2(0, 9.8f)),new DPSFParticleManager());            
 }
        protected override void SetWorldAndRenderTechnich(out RenderTechnich2D renderTech, out I2DWorld world)
        {
            Basic2DRenderTechnich rt = new Basic2DRenderTechnich();
            rt.UsePostProcessing = false;            
            renderTech = rt;

            world = new I2DWorld(new FarseerWorld(new Vector2(0, 9.8f)),new DPSFParticleManager());            
        }
 /// <summary>
 /// Called once on screen load
 /// </summary>
 /// <param name="renderTech"></param>
 /// <param name="world"></param>
 protected override void SetWorldAndRenderTechnich(out RenderTechnich2D renderTech, out I2DWorld world)
 {
     ////creating the rendering technic
     Basic2DRenderTechnich rt = new Basic2DRenderTechnich();            
     rt.RenderBackGround += new RenderBackGround(rt_RenderBackGround);
     ///enable draw components
     rt.UseDrawComponents = true;
     renderTech = rt;                  
     ///creating the world =P
     world = new I2DWorld(new FarseerWorld(new Vector2(0, 9.8f)),new DPSFParticleManager());            
 }
 /// <summary>
 /// Called once each frame before the draw phase
 /// </summary>
 /// <param name="gt">The gt.</param>
 /// <param name="mundo">The mundo.</param>
 /// <param name="obj">The obj.</param>
 /// <param name="render">The render.</param>
 public virtual void PreDrawnPhase(GameTime gt, I2DWorld mundo, I2DObject obj, RenderHelper render) { }
        protected override void ExecuteTechnic(Microsoft.Xna.Framework.GameTime gameTime, RenderHelper render, I2DWorld world)
        {
            Matrix simview       = world.Camera2D.SimView;
            Matrix simprojection = world.Camera2D.SimProjection;
            Matrix view          = world.Camera2D.View;
            Matrix projection    = world.Camera2D.Projection;


            world.Culler.StartFrame(ref simview, ref simprojection, world.Camera2D.BoundingFrustrum);
            Dictionary <Type, List <I2DObject> > objs = world.Culler.GetNotCulledObjectsList();

            if (UsePreDrawPhase)
            {
                foreach (var item in objs.Keys)
                {
                    IMaterialProcessor MaterialProcessor = MaterialProcessors[item];

                    if (MaterialProcessor != null)
                    {
                        MaterialProcessor.ProcessPreDraw(UseLayerInPreDraw, gameTime, render, world.Camera2D, world, objs[item]);
                    }
                    else
                    {
                        foreach (var iobj in objs[item])
                        {
                            if (iobj.PhysicObject.Enabled == true)
                            {
                                iobj.Material.PreDrawnPhase(gameTime, world, iobj, render);
                            }
                        }
                    }
                }
            }

#if !WINDOWS_PHONE && !REACH
            if (UseShadow)
            {
                render.PushRenderTarget(screenShadowsTESTE);
                render.Clear(Color.Black);
                foreach (var item in objs.Keys)
                {
                    IMaterialProcessor MaterialProcessor = MaterialProcessors[item];

                    if (MaterialProcessor != null)
                    {
                        MaterialProcessor.ProcessDraw(UseLayerInDraw, gameTime, render, world.Camera2D, objs[item]);
                    }
                    else
                    {
                        foreach (var iobj in objs[item])
                        {
                            if (iobj.PhysicObject.Enabled == true)
                            {
                                iobj.Material.Draw(gameTime, iobj, render);
                            }
                        }
                    }
                }
                render.PopRenderTarget();
            }


            render.PushRenderTarget(renderTarget);
            render.Clear(Color.Black);

            if (RenderBackGround != null)
            {
                RenderBackGround(ginfo, render);
            }

            if (UseDrawComponents)
            {
                render.RenderPreComponents(gameTime, ref view, ref projection);
            }

            if (BeforeDraw != null)
            {
                BeforeDraw(ginfo, render);
            }

            foreach (var item in objs.Keys)
            {
                IMaterialProcessor MaterialProcessor = MaterialProcessors[item];

                if (MaterialProcessor != null)
                {
                    MaterialProcessor.ProcessDraw(UseLayerInDraw, gameTime, render, world.Camera2D, objs[item]);
                }
                else
                {
                    foreach (var iobj in objs[item])
                    {
                        if (iobj.PhysicObject.Enabled == true)
                        {
                            iobj.Material.Draw(gameTime, iobj, render);
                        }
                    }
                }
            }

            if (UseDrawComponents)
            {
                render.RenderPosWithDepthComponents(gameTime, ref view, ref projection);
            }

            if (world.ParticleManager != null)
            {
                world.ParticleManager.iDraw(gameTime, world.Camera2D.View, world.Camera2D.SimProjection, render);
            }

            if (AfterDrawBeforePostEffects != null)
            {
                AfterDrawBeforePostEffects(ginfo, render);
            }

            render.PopRenderTarget();

            if (UseLights)
            {
                BoundingFrustum bf = world.Camera2D.BoundingFrustrum;
                foreach (var item in world.Lights2D)
                {
                    if (UseShadow)
                    {
                        item.BeginDrawingShadowCasters(render);
                        item.UpdateLight(world.Camera2D.View);

                        if (item.CasShadow)
                        {
                            foreach (var item2 in objs.Keys)
                            {
                                IMaterialProcessor MaterialProcessor = MaterialProcessors[item2];

                                if (MaterialProcessor != null)
                                {
                                    MaterialProcessor.ProcessLightDraw(gameTime, render, world.Camera2D, objs[item2], Color.Black, item);
                                }
                                else
                                {
                                    foreach (var iobj in objs[item2])
                                    {
                                        if (iobj.PhysicObject.Enabled == true)
                                        {
                                            iobj.Material.LightDraw(gameTime, iobj, render, Color.Black, item);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            render.Clear(Color.Black);
                        }
                        item.EndDrawingShadowCasters(render);
                        shadowmapResolver.ResolveShadows(item);
                        shadowmapResolver.ResolveNoShadow(item);
                    }
                    else
                    {
                        item.UpdateLight(world.Camera2D.View);
                        shadowmapResolver.ResolveNoShadow(item);
                    }
                }

                render.PushRenderTarget(screenShadows);
                render.Clear(ambientColor);
                render.RenderBegin(Matrix.Identity, null, SpriteSortMode.Deferred, SamplerState.LinearClamp, BlendState.Additive);

                if (UseShadow)
                {
                    foreach (var item in world.Lights2D)
                    {
                        render.RenderTexture(item.RenderTarget, item.LightPosition - item.LightAreaSize * 0.5f, item.Color, 0, Vector2.Zero, 1);
                    }
                }
                else
                {
                    foreach (var item in world.Lights2D)
                    {
                        render.RenderTexture(item.RenderTargetNS, item.LightPosition - item.LightAreaSize * 0.5f, item.Color, 0, Vector2.Zero, 1);
                    }
                }

                render.RenderEnd();
                render.PopRenderTarget();

                if (UseShadow)
                {
                    render.PushRenderTarget(screenShadowsNS);
                    render.Clear(AmbientColor);
                    render.RenderBegin(Matrix.Identity, null, SpriteSortMode.Deferred, SamplerState.LinearClamp, BlendState.Additive);
                    foreach (var item in world.Lights2D)
                    {
                        render.RenderTexture(item.RenderTargetNS, item.LightPosition - item.LightAreaSize * 0.5f, item.Color, 0, Vector2.Zero, 1);
                    }
                    render.RenderEnd();
                    render.PopRenderTarget();

                    render.PushRenderTarget(lalalala);

                    render.Clear(Color.Black);
                    render.RenderBegin(Matrix.Identity, null, SpriteSortMode.Immediate, SamplerState.LinearClamp, BlendState.Opaque);
                    render.RenderTexture(screenShadowsNS, Vector2.Zero, LightMaskAttenuation, 0, Vector2.Zero, 1);
                    render.RenderEnd();

                    render.RenderBegin(Matrix.Identity, null, SpriteSortMode.Immediate, SamplerState.LinearClamp, blend);
                    render.RenderTexture(screenShadowsTESTE, Vector2.Zero, Color.White, 0, Vector2.Zero, 1);
                    render.RenderEnd();

                    render.PopRenderTarget();

                    if (UsePostProcessing)
                    {
                        render.PushRenderTarget(postEffectTargetScene);
                    }

                    render.RenderBegin(Matrix.Identity, null, SpriteSortMode.Immediate, SamplerState.LinearClamp, BlendState.Opaque);
                    render.RenderTexture(screenShadows, Vector2.Zero, Color.White, 0, Vector2.Zero, 1);
                    render.RenderEnd();

                    render.RenderBegin(Matrix.Identity, null, SpriteSortMode.Immediate, SamplerState.LinearClamp, blend);
                    render.RenderTexture(renderTarget, Vector2.Zero, Color.White, 0, Vector2.Zero, 1);
                    render.RenderEnd();

                    render.RenderBegin(Matrix.Identity, null, SpriteSortMode.Immediate, SamplerState.LinearClamp, BlendState.Additive);
                    render.RenderTexture(lalalala, Vector2.Zero, Color.White, 0, Vector2.Zero, 1);
                    render.RenderEnd();
                }
                else
                {
                    if (UsePostProcessing)
                    {
                        render.PushRenderTarget(postEffectTargetScene);
                    }

                    render.RenderBegin(Matrix.Identity, null, SpriteSortMode.Immediate, SamplerState.LinearClamp, BlendState.Opaque);
                    render.RenderTexture(screenShadows, Vector2.Zero, Color.White, 0, Vector2.Zero, 1);
                    render.RenderEnd();

                    render.RenderBegin(Matrix.Identity, null, SpriteSortMode.Immediate, SamplerState.LinearClamp, blend);
                    render.RenderTexture(renderTarget, Vector2.Zero, Color.White, 0, Vector2.Zero, 1);
                    render.RenderEnd();
                }
            }
            else
            {
#endif
            if (UsePostProcessing)
            {
                render.PushRenderTarget(postEffectTargetScene);
            }

            render.Clear(AmbientColor);

            if (RenderBackGround != null)
            {
                RenderBackGround(ginfo, render);
            }

            if (UseDrawComponents)
            {
                render.RenderPreComponents(gameTime, ref view, ref projection);
            }

            if (BeforeDraw != null)
            {
                BeforeDraw(ginfo, render);
            }

            foreach (var item in objs.Keys)
            {
                IMaterialProcessor MaterialProcessor = MaterialProcessors[item];

                if (MaterialProcessor != null)
                {
                    MaterialProcessor.ProcessDraw(UseLayerInDraw, gameTime, render, world.Camera2D, objs[item]);
                }
                else
                {
                    foreach (var iobj in objs[item])
                    {
                        if (iobj.PhysicObject.Enabled == true)
                        {
                            iobj.Material.Draw(gameTime, iobj, render);
                        }
                    }
                }
            }

            if (UseDrawComponents)
            {
                render.RenderPosWithDepthComponents(gameTime, ref view, ref projection);
            }

            if (world.ParticleManager != null)
            {
                world.ParticleManager.iDraw(gameTime, world.Camera2D.View, world.Camera2D.SimProjection, render);
            }

            if (AfterDrawBeforePostEffects != null)
            {
                AfterDrawBeforePostEffects(ginfo, render);
            }

#if !WINDOWS_PHONE && !REACH
        }
#endif


            if (UsePostProcessing)
            {
                render[PrincipalConstants.CurrentImage]  = render.PopRenderTarget()[0].RenderTarget as Texture2D;
                render[PrincipalConstants.CombinedImage] = render[PrincipalConstants.CurrentImage];
                for (int i = 0; i < PostEffects.Count; i++)
                {
                    if (PostEffects[i].Enabled)
                    {
                        render.PushRenderTarget(postEffectTarget);
                        PostEffects[i].Draw(render[PrincipalConstants.CurrentImage], render, gameTime, ginfo, null, false);
                        Texture2D tex = render.PopRenderTarget()[0].RenderTarget as Texture2D;
                        render[PrincipalConstants.CurrentImage] = tex;
                    }
                }
                render.Clear(Color.Black);
                render.RenderTextureComplete(render[PrincipalConstants.CurrentImage], Color.White, ginfo.FullScreenRectangle, Matrix.Identity, null, true, SpriteSortMode.Deferred, SamplerState.AnisotropicClamp, BlendState.AlphaBlend);
            }

            if (UseDrawComponents)
            {
                render.RenderPosComponents(gameTime, ref view, ref projection);
            }
        }
 internal void iExecuteTechnic(GameTime gameTime, RenderHelper render, I2DWorld world)
 {
     ExecuteTechnic(gameTime, render, world);
 }
 /// <summary>
 /// Executes the technic.
 /// </summary>
 /// <param name="gameTime">The game time.</param>
 /// <param name="render">The render.</param>
 /// <param name="world">The world.</param>
 protected abstract void ExecuteTechnic(GameTime gameTime, RenderHelper render, I2DWorld world);
 internal void iBeforeFirstExecution(RenderHelper render, I2DWorld world)
 {
     BeforeFirstExecution(render, world);
 }
 /// <summary>
 /// Befores the first execution.
 /// </summary>
 /// <param name="render">The render.</param>
 /// <param name="world">The world.</param>
 protected virtual void BeforeFirstExecution(RenderHelper render, I2DWorld world)
 {
 }
 /// <summary>
 /// Sets the world and render technich.
 /// </summary>
 /// <param name="renderTech">The render tech.</param>
 /// <param name="world">The world.</param>
 protected abstract void SetWorldAndRenderTechnich(out RenderTechnich2D renderTech, out I2DWorld world);
Beispiel #11
0
 /// <summary>
 /// Sets the world and render technich.
 /// </summary>
 /// <param name="renderTech">The render tech.</param>
 /// <param name="world">The world.</param>
 protected abstract void SetWorldAndRenderTechnich(out RenderTechnich2D renderTech, out I2DWorld world);
 internal void iExecuteTechnic(GameTime gameTime, RenderHelper render, I2DWorld  world)
 {
     ExecuteTechnic(gameTime, render, world);
 }
 /// <summary>
 /// Executes the technic.
 /// </summary>
 /// <param name="gameTime">The game time.</param>
 /// <param name="render">The render.</param>
 /// <param name="world">The world.</param>
 protected abstract void ExecuteTechnic(GameTime gameTime, RenderHelper render, I2DWorld world);
 internal void iBeforeFirstExecution(RenderHelper render, I2DWorld  world)
 {
     BeforeFirstExecution(render, world);
 }
 /// <summary>
 /// Befores the first execution.
 /// </summary>
 /// <param name="render">The render.</param>
 /// <param name="world">The world.</param>
 protected virtual void BeforeFirstExecution(RenderHelper render, I2DWorld  world) { }