Exemplo n.º 1
0
        public override void Preload()
        {
            levelmodel = MeshGenerator.LoadOBJMulti("Levels/sponza.obj"); //Levels/multi_test.obj Levels/sponza.obj
            //levelmodel = Resource.GetMesh("Levels/level1.obj");
            //levelmodel.mat = Resource.GetMaterial("levels/level1");

            //Spawn the little depth screen thingy
            EntManager.Create<ent_depthscreen>().Spawn();

            Vector3 OlegPos = new Vector3(-2.00f, 2.421f, -14.90f);
            //don't forget oleg
            oleg = EntManager.Create<ent_static>();
            oleg.Spawn();
            oleg.SetModel(Resource.GetMesh("props/oleg.obj"));
            oleg.Name = "Oleg";
            oleg.SetPos(OlegPos);
            oleg.Scale = new Vector3(0.75f);
            oleg.SetAngle(new Angle(0, 0, 14.3f));

            //and the boys
            var ent = EntManager.Create<ent_static>();
            ent.Spawn();
            ent.SetModel(Resource.GetMesh("props/oleg.obj"));
            ent.Material = Resource.GetMaterial("engine/white");
            ent.SetPos(OlegPos + new Vector3(0, 0.0f, -0.1f));
            ent.Scale = new Vector3(0.75f);
            ent.SetParent(oleg);

            ent_pointlight pointlight = (ent_pointlight)EntManager.Create<ent_pointlight>();
            pointlight.Spawn();
            pointlight.AmbientIntensity = 0.40f;
            pointlight.DiffuseIntensity = 0.85f;
            pointlight.Color = new Vector3(1.0f, 0.5f, 0.0f);
            pointlight.SetPos(OlegPos);
            pointlight.Linear = 0.1f;
            pointlight.SetParent(oleg);

            spotlight = (ent_spotlight)EntManager.Create<ent_spotlight>();
            spotlight.Spawn();

            spotlight.Color = new Vector3(1.0f, 1.0f, 1.0f);
            spotlight.Constant = 1.0f;
            spotlight.Cutoff = 20.0f;

            //Make us some nice environmental lighting
            DirectionalLight light = new DirectionalLight();
            light.AmbientIntensity = 0.4f;
            light.DiffuseIntensity = 0.9f;
            light.Color = new Vector3(0.133f, 0.149f, 0.176f);
            light.Direction = new Vector3(0.0f, -1.0f, 0.0f);

            LightingTechnique.SetEnvironmentLight(light);
            ShadowTechnique.Enable();

            //Gimme some skyboxes!
            SkyboxTechnique.SetSkyGradientMaterial(Resource.GetMaterial("skybox/skygradient_default"));
            SkyboxTechnique.PreDrawSkybox += new Action(SkyboxTechnique_PreDrawSkybox);
            dome = Resource.GetMesh("engine/skybox.obj");
            starBox = Resource.GetMaterial("skybox/skybox_starrynight");

            //Some fog!
            FogTechnique.SetFogParameters(new FogParams()
            {
                Color = new Vector3(0.37254f, 0.368627f, 0.427450f),
                Start = 20,
                End = 200,
                Density = 0.03f,
                Type = FogParams.FogType.Exp2,
            });
            FogTechnique.Enabled = true;

            Utilities.ForcedFrametime = 0.002604167;

            Utilities.engine.Keyboard.KeyDown += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown);
        }
Exemplo n.º 2
0
 private static void SetDirectionalLight(DirectionalLight Light)
 {
     GL.Uniform3(lightLocations.Color, Light.Color.X, Light.Color.Y, Light.Color.Z);
     GL.Uniform1(lightLocations.AmbientIntensity, Light.AmbientIntensity);
     Vector3 Direction = Light.Direction;
     Direction.Normalize();
     GL.Uniform3(lightLocations.Direction, Direction.X, Direction.Y, Direction.Z);
     GL.Uniform1(lightLocations.DiffuseIntensity, Light.DiffuseIntensity);
 }
Exemplo n.º 3
0
        private static void SetUpScene()
        {
            //Load the world
            WorldMesh = MeshGenerator.LoadOBJMulti("balancelevel.obj");
            /*
            //Create the floor's physics mesh
            Body level = FarseerPhysics.Factories.BodyFactory.CreateRectangle(Utilities.PhysicsWorld, 1000, 10, 1.00f);
            level.Position = new Microsoft.Xna.Framework.Vector2(0, -5.0f);
            level.BodyType = BodyType.Static;
            //Walls
            level = FarseerPhysics.Factories.BodyFactory.CreateRectangle(Utilities.PhysicsWorld, 10, 1000, 1.00f);
            level.Position = new Microsoft.Xna.Framework.Vector2(-153, 0);
            level.BodyType = BodyType.Static;
            level = FarseerPhysics.Factories.BodyFactory.CreateRectangle(Utilities.PhysicsWorld, 10, 1000, 1.00f);
            level.Position = new Microsoft.Xna.Framework.Vector2(153, 0);
            level.BodyType = BodyType.Static;

            ent_physics pole = EntManager.Create<ent_physics>();
            pole.Spawn();
            pole.SetPos(Vector2.Zero);
            pole.SetModel(new Mesh("pole.obj"));
            pole.Material = Resource.GetMaterial("Models/wood_log");
            //Create the physics for it
            pole.Physics.Body.BodyType = BodyType.Static;
            pole.SetPos(new Vector2(0, -pole.Model.BBox.Negative.Y));

            ent_physics bar = EntManager.Create<ent_physics>();
            bar.Spawn();
            bar.SetPos(Vector2.Zero);
            bar.SetModel(new Mesh("balancebeam.obj"));
            bar.Material = Resource.GetMaterial("Models/balancebeam");
            bar.SetPos(new Vector2(0, 30));
            bar.Physics.Body.BodyType = BodyType.Dynamic;
            bar.Physics.Body.Mass = 2;
            bar.Physics.Friction = 1000;

            BalanceEnt = bar;
            */
            //Turn on the lights
            DirectionalLight light = new DirectionalLight();
            light.AmbientIntensity = 0.4f;
            light.DiffuseIntensity = 0.9f;
            light.Color = new Vector3(0.745f, 0.820f, 0.847f); //new Vector3(0.133f, 0.149f, 0.176f);
            light.Direction = new Vector3(-1.0f, -1.0f, 0.0f);
            light.Direction.Normalize();

            ent_pointlight pointlight = EntManager.Create<ent_pointlight>();
            pointlight.Spawn();
            pointlight.AmbientIntensity = 0.4f;
            pointlight.DiffuseIntensity = 20.0f; //0.85f
            pointlight.Color = new Vector3(1.0f, 0.5f, 0.0f);
            pointlight.SetPos(new Vector3(-2.00f, 2.421f, -14.90f));
            pointlight.Linear = 22.7f;

            spotlight = (ent_spotlight)EntManager.Create<ent_spotlight>();
            spotlight.Spawn();

            spotlight.Color = new Vector3(1.0f, 1.0f, 1.0f);
            spotlight.Constant = 1.0f;
            spotlight.Cutoff = 20.0f;

            //Create a radio to set the mood
            ent_radio radio = EntManager.Create<ent_radio>();
            radio.Spawn();
            radio.SetPos(new Vector3(-7.00f, 0, -14.90f));
            radio.Scale = new Vector3(0.3f);

            LightingTechnique.SetEnvironmentLight(light);
            ShadowTechnique.Enable();

            //Load some groovy jams with our custom music handler
            Music = MusicMix.Create("Resources/Audio/Music", "mix_", ".wav");
            Music.Play(true);

            //Start waiting!
            SetState(LevelState.WAITING);
        }
Exemplo n.º 4
0
 public static void SetEnvironmentLight(DirectionalLight light)
 {
     EnvironmentLight = light;
 }