Exemplo n.º 1
0
        public override void Render(ECScene scene)
        {
            var cam = Camera ?? scene.Camera;

            BeginRender(cam);

            for (var i = 0; i < RenderLayers.Length; i++)
            {
                var renderables = scene.RenderableComponents.ComponentsWithRenderLayer(RenderLayers[i]);
                for (var j = 0; j < renderables.Length; j++)
                {
                    var renderable = renderables.Buffer[j];
                    if (renderable.Enabled && renderable.IsVisibleFromCamera(cam))
                    {
                        RenderAfterStateCheck(renderable, cam);
                    }
                }
            }

            if (ShouldDebugRender && ECScene.DebugRenderEnabled)
            {
                DebugRender(scene, cam);
            }

            EndRender();
        }
Exemplo n.º 2
0
        /// <summary>
        /// called when a scene is ended or this PostProcessor is removed. use this for cleanup.
        /// </summary>
        public virtual void Unload()
        {
            // Ash-specific Effects will have a null name. We don't want to try to remove them.
            if (Effect != null && Effect.Name != null)
            {
                _scene.Content.UnloadEffect(Effect);
                Effect = null;
            }

            _scene = null;
        }
Exemplo n.º 3
0
        /// <summary>
        /// default debugRender method just loops through all entities and calls entity.debugRender. Note that you are in the middle of a batch
        /// at this point so you may want to call Batcher.End and Batcher.begin to clear out any Materials and items awaiting rendering.
        /// </summary>
        /// <param name="scene">Scene.</param>
        protected virtual void DebugRender(ECScene scene, Camera cam)
        {
            Graphics.Instance.Batcher.End();
            Graphics.Instance.Batcher.Begin(cam.TransformMatrix);

            for (var i = 0; i < scene.Entities.Count; i++)
            {
                var entity = scene.Entities[i];
                if (entity.Enabled)
                {
                    entity.DebugRender(Graphics.Instance.Batcher);
                }
            }
        }
Exemplo n.º 4
0
        public static ReflectionRenderer CreateAndSetupScene(ECScene scene, int renderOrder, params int[] renderLayers)
        {
            var reflectionRenderer = scene.AddRenderer(new ReflectionRenderer(-1, renderLayers));

            reflectionRenderer.RenderTargetClearColor = Color.Transparent;
            reflectionRenderer.RenderTexture          = new RenderTexture(1, 1);

            // create a Camera and parent it to the Scene's Camera
            var cameraEntity = scene.CreateEntity("reflection-camera");

            cameraEntity.Transform.SetParent(scene.Camera.Entity.Transform);
            reflectionRenderer.Camera = cameraEntity.AddComponent <Camera>();

            return(reflectionRenderer);
        }
Exemplo n.º 5
0
        protected override void DebugRender(ECScene scene, Camera cam)
        {
            Graphics.Instance.Batcher.End();
            Graphics.Instance.Batcher.Begin(cam.TransformMatrix);

            for (var i = 0; i < RenderLayers.Length; i++)
            {
                var renderables = scene.RenderableComponents.ComponentsWithRenderLayer(RenderLayers[i]);
                for (var j = 0; j < renderables.Length; j++)
                {
                    var entity = renderables.Buffer[j];
                    if (entity.Enabled)
                    {
                        entity.DebugRender(Graphics.Instance.Batcher);
                    }
                }
            }
        }
Exemplo n.º 6
0
        protected override void DebugRender(ECScene scene, Camera cam)
        {
            Graphics.Instance.Batcher.End();
            Graphics.Instance.Batcher.Begin(cam.TransformMatrix);

            for (var i = 0; i < RenderLayers.Length; i++)
            {
                var renderables = scene.RenderableComponents.ComponentsWithRenderLayer(RenderLayers[i]);
                for (var j = 0; j < renderables.Length; j++)
                {
                    var renderable = renderables.Buffer[j];
                    if (renderable.Enabled && renderable.IsVisibleFromCamera(cam))
                    {
                        renderable.DebugRender(Graphics.Instance.Batcher);
                    }
                }
            }

            base.DebugRender(scene, cam);
        }
Exemplo n.º 7
0
 public EntityList(ECScene scene)
 {
     Scene = scene;
 }
Exemplo n.º 8
0
 /// <summary>
 /// called when the Renderer is added to the Scene
 /// </summary>
 /// <param name="scene">Scene.</param>
 public virtual void OnAddedToScene(ECScene scene)
 {
 }
Exemplo n.º 9
0
 abstract public void Render(ECScene scene);
Exemplo n.º 10
0
 public void OnAddedToScene(ECScene scene)
 {
     InternalEffect = new PixelPlusEffect();
 }