Esempio n. 1
0
        protected override void LoadResources()
        {
            base.LoadResources();

            Stage.ClearColor = new Triton.Vector4(185 / 255.0f, 224 / 255.0f, 239 / 255.0f, 0) * 0.1f;

            {
                var city = GameWorld.CreateGameObject();
                city.AddComponent(new Mesh { Filename = "/models/city" });
                city.AddComponent(new MeshRigidBody { Filename = "/collision/city" });
                GameWorld.Add(city);
            }

            Player = GameWorld.CreateGameObject();
            Player.Position = new Vector3(0, 2f, 0);
            PlayerCharacter = new CharacterController();
            Player.AddComponent(PlayerCharacter);
            GameWorld.Add(Player);

            for (int i = 0; i < 5; i++)
            {
                var crate = GameWorld.CreateGameObject();
                crate.Position = new Vector3(-3 + i * 1.5f, 0.5f, 2);
                crate.AddComponent(new Mesh { Filename = "/models/crate" });
                crate.AddComponent(new BoxRigidBody());
                GameWorld.Add(crate);
            }

            CreateContainer(new Vector3(0, 0, 4 + 4 * 0));
            CreateContainer(new Vector3(0, 0, 4 + 4 * 1));
            CreateContainer(new Vector3(0, 0, 4 + 4 * 2));
            CreateContainer(new Vector3(6, 0, 4 + 4 * 2));

            CreateContainer(new Vector3(0, 2, 5 + 2 * 0));
            CreateContainer(new Vector3(0, 2, 5 + 2 * 1));
            CreateContainer(new Vector3(0, 2, 5 + 2 * 2));
            CreateContainer(new Vector3(0, 2, 5 + 2 * 3));

            Stage.AmbientColor = Vector3.Zero;
            Stage.CreateDirectionalLight(new Vector3(-0.3f, -0.8f, 0.66f), new Vector3(1f, 0.8f, 0.5f), true, intensity: 1);
            Stage.CreateDirectionalLight(new Vector3(0.3f, -0.8f, -0.66f), new Vector3(0.8f, 0.7f, 1.0f), false, intensity: 0.2f);
            Camera.FarClipDistance = 200;

            DebugFlags |= Game.DebugFlags.RenderStats;

            PostEffectManager.HDRSettings.EnableLensFlares = true;
            PostEffectManager.HDRSettings.EnableBloom = true;
            PostEffectManager.HDRSettings.AdaptationRate = 2;

            DeferredRenderer.Settings.ShadowQuality = Graphics.Deferred.ShadowQuality.Medium;
        }
Esempio n. 2
0
        protected override void LoadResources()
        {
            base.LoadResources();

            Stage.ClearColor = new Triton.Vector4(185 / 255.0f, 224 / 255.0f, 239 / 255.0f, 0);
            Stage.AmbientColor = Vector3.Zero;

            var floor = GameWorld.CreateGameObject();
            floor.AddComponent(new Mesh { Filename = "/models/room" });
            floor.AddComponent(new BoxRigidBody { Height = 0.01f, Width = 400.0f, Length = 400.0f, IsStatic = true });
            GameWorld.Add(floor);

            Player = GameWorld.CreateGameObject();
            Player.Position = new Vector3(0, 2f, 0);
            PlayerCharacter = new CharacterController();
            Player.AddComponent(PlayerCharacter);
            GameWorld.Add(Player);

            var materials = new string[]
            {
                "/materials/sphere",
                "/materials/gold",
                "/materials/iron",
                "/materials/wood",
            };

            for (int i = 0; i < 5; i++)
            {
                var materialName = materials[i % materials.Length];

                var cube = GameWorld.CreateGameObject();
                cube.Position = new Vector3(-3 + i * 1.5f, 1.0f, 2);
                cube.AddComponent(new Mesh { Filename = "/models/crate", MeshParameters = materialName });
                GameWorld.Add(cube);
            }

            for (int i = 0; i < 5; i++)
            {
                var materialName = materials[i % materials.Length];

                var cube = GameWorld.CreateGameObject();
                cube.Position = new Vector3(-3 + i * 1.5f, 1.0f, -2);
                cube.AddComponent(new Mesh { Filename = "/models/sphere", MeshParameters = materialName });
                GameWorld.Add(cube);
            }

            {
                var sphere = GameWorld.CreateGameObject();
                sphere.Position = new Vector3(2, 2.5f, 0);
                sphere.Scale = new Vector3(1, 1, 1) * 0.15f;
                sphere.AddComponent(new PointLight { Color = new Vector3(0.8f, 0.3f, 0.35f), Intensity = 2, Range = 8 });
                sphere.AddComponent(new LightAnimator() { WaveFunction = WaveFunction.Sin, Phase = 0.4f, Base = 0.1f });
                GameWorld.Add(sphere);
            }

            {
                var sphere = GameWorld.CreateGameObject();
                sphere.Position = new Vector3(-10, 2.5f, 1);
                sphere.Scale = new Vector3(1, 1, 1) * 0.15f;
                sphere.AddComponent(new PointLight { Color = new Vector3(0.55f, 0.5f, 0.8f), Intensity = 2 });
                GameWorld.Add(sphere);
            }

            {
                var sphere = GameWorld.CreateGameObject();
                sphere.Position = new Vector3(-18, 2.5f, -5);
                sphere.Scale = new Vector3(1, 1, 1) * 0.15f;
                sphere.AddComponent(new PointLight { Color = new Vector3(0.55f, 0.5f, 0.8f), Intensity = 1.5f, Range = 8 });
                GameWorld.Add(sphere);
            }

            for (var i = 0; i < 0; i++)
            {
                var x = (float)(-6.0 + RNG.NextDouble() * 15.0);
                var z = (float)(-8.0 + RNG.NextDouble() * 20.0);

                var sphere = GameWorld.CreateGameObject();
                sphere.Position = new Vector3(x, 0.5f, z);
                sphere.AddComponent(new PointLight
                {
                    Color = new Vector3(0.1f + (float)RNG.NextDouble() * 0.9f, 0.1f + (float)RNG.NextDouble() * 0.9f, 0.1f + (float)RNG.NextDouble() * 0.9f),
                    Intensity = 0.3f + (float)RNG.NextDouble() * 0.6f,
                    Range = 0.7f + (float)RNG.NextDouble() * 0.9f,
                    CastShadows = false
                });
                GameWorld.Add(sphere);
            }

            //Stage.AddMesh("/models/skybox");
            //Stage.SetSkyBox("/models/skybox");

            PostEffectManager.HDRSettings.AdaptationRate = 2;
            PostEffectManager.HDRSettings.KeyValue = 0.1f;
            DeferredRenderer.Settings.ShadowQuality = Graphics.Deferred.ShadowQuality.Lowest;

            DebugFlags |= Game.DebugFlags.RenderStats;
        }