Exemplo n.º 1
0
        private SceneGraph CreateSceneGraph()
        {
            var sceneGraph = new SceneGraph();

            _dirLight = new DirectionalLight(sceneGraph,
                                             intensity: new Vec3(1f),
                                             direction: new Vec3(0.7f, 1f, -0.7f),
                                             maxShadowDepth: 200f);

            _camera = new Camera(sceneGraph,
                                 position: new Vec3(0f, 10f, 10f),
                                 target: new Vec3(0f, 10f, -1f),
                                 upDirection: new Vec3(0f, 1f, 0f),
                                 frustum: new ViewingFrustum(FrustumKind.Perspective, 1f, 1f, -1f, -400f),
                                 aspectRatio: 1f);

            sceneGraph.GlobalLighting = new GlobalLighting()
            {
                AmbientLightIntensity = new Vec3(0.1f),
                MaxIntensity          = 1f,
                GammaCorrection       = 1.8f,
            };

            _terrainScene = new Terrain.Scene(sceneGraph);
            var fighterGeometry = new FighterGeometry <EntityVertex, PathNode> ();

            _fighter = new Mesh <EntityVertex> (sceneGraph, fighterGeometry.Fighter.RotateY(0f).Compact())
                       .OffsetOrientAndScale(new Vec3(0f, 15f, -10f), new Vec3(0f, 0f, 0f), new Vec3(1f));

            _infoWindow = new ControlPanel <TexturedVertex> (sceneGraph,
                                                             Container.Vertical(true, false,
                                                                                Label.Static("Options", FontStyle.Bold),
                                                                                new ListView(React.Ignore <IVisualizable> (),
                                                                                             new Visualizable(() => Visual.Label(string.Format("FPS: {0}", _fps))),
                                                                                             new Visualizable(() => Visual.Label(
                                                                                                                  string.Format("Mouse: {0}", new Vec2i(Mouse.X, Mouse.Y)))))),
                                                             new Vec2i(180, 64), false);
            sceneGraph.Root.Add(_dirLight, _camera, _terrainScene.Root, _fighter,
                                _infoWindow.Offset(new Vec3(-0.95f, 0.95f, 0f)));
            return(sceneGraph);
        }
Exemplo n.º 2
0
        private SceneGraph CreateSceneGraph()
        {
            var sceneGraph = new SceneGraph ();
            _dirLight = new DirectionalLight (sceneGraph,
                intensity: new Vec3 (1f),
                direction: new Vec3 (0.7f, 1f, -0.7f),
                maxShadowDepth: 200f);

            _camera = new Camera (sceneGraph,
                position: new Vec3 (0f, 10f, 10f),
                target: new Vec3 (0f, 10f, -1f),
                upDirection: new Vec3 (0f, 1f, 0f),
                frustum: new ViewingFrustum (FrustumKind.Perspective, 1f, 1f, -1f, -400f),
                aspectRatio: 1f);

            sceneGraph.GlobalLighting = new GlobalLighting ()
            {
                AmbientLightIntensity = new Vec3 (0.1f),
                MaxIntensity = 1f,
                GammaCorrection = 1.8f,
            };

            _terrainScene = new Terrain.Scene (sceneGraph);
            var fighterGeometry = new FighterGeometry<EntityVertex, PathNode> ();
            _fighter = new Mesh<EntityVertex> (sceneGraph, fighterGeometry.Fighter.RotateY (0f).Compact ())
                .OffsetOrientAndScale (new Vec3 (0f, 15f, -10f), new Vec3 (0f, 0f, 0f), new Vec3 (1f));

            _infoWindow = new ControlPanel<TexturedVertex> (sceneGraph,
                Container.Vertical (true, false,
                    Label.Static ("Options", FontStyle.Bold),
                    new ListView (React.Ignore <IVisualizable> (),
                        new Visualizable (() => Visual.Label (string.Format ("FPS: {0}", _fps))),
                        new Visualizable (() => Visual.Label (
                            string.Format ("Mouse: {0}", new Vec2i (Mouse.X , Mouse.Y)))))),
                new Vec2i (180, 64), false);
            sceneGraph.Root.Add (_dirLight, _camera, _terrainScene.Root, _fighter,
                _infoWindow.Offset (new Vec3 (-0.95f, 0.95f, 0f)));
            return sceneGraph;
        }