Exemplo n.º 1
0
        private void SetupRendering()
        {
            var shadowRender = Shadows.Renderer(_sceneGraph, 2500, ShadowMapType.Depth, true)
                               .MapInput((double _) => _camera);

            var skyboxRender  = Skybox.Renderer(_sceneGraph, _skyColor);
            var terrainRender = Terrain.Renderer(_sceneGraph, _skyColor, Shadows.Instance.csmUniforms);
            var entityRender  = Entities.Renderer(_sceneGraph, Shadows.Instance.csmUniforms);
            var panelRender   = Panels.Renderer(_sceneGraph)
                                .And(React.By((Vec2i vp) => ControlPanel <TexturedVertex> .UpdateAll(_sceneGraph, this, vp)))
                                .MapInput((double _) => new Vec2i(ClientSize.Width, ClientSize.Height));

            var moveFighter = React.By <float> (UpdateFighterAndCamera)
                              .Aggregate((float s, double t) => s + (float)t * 25f, 0f);

            React.By <double> (UpdateFPS)
            .And(shadowRender
                 .And(skyboxRender
                      .And(terrainRender)
                      .And(entityRender)
                      .MapInput((double _) => _camera)
                      .And(panelRender)
                      .Viewport(this)))
            .And(moveFighter)
            .SwapBuffers(this)
            .WhenRendered(this).Evoke();

            Entities.UpdatePerspectiveMatrix()
            .And(Skybox.UpdatePerspectiveMatrix())
            .And(Terrain.UpdatePerspectiveMatrix())
            .MapInput((Vec2 size) =>
                      (_camera.Frustum = new ViewingFrustum(FrustumKind.Perspective, size.X, size.Y, -1f, -400f))
                      .CameraToScreen)
            .WhenResized(this).Evoke();
        }