Exemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            inputManager = new InputManager(this, camera);

            phongShader = new PhongShader(FileManager.getMediaFile("phongVS.glsl"), FileManager.getMediaFile("phongFS.glsl"));
            postProcessShader = new PostProcessShader(FileManager.getMediaFile("postProcessVS.glsl"), FileManager.getMediaFile("postProcessFS.glsl"));
            volumetricLightingShader = new VolumetricLightingShader(FileManager.getMediaFile("volumetricLightingVS.glsl"), FileManager.getMediaFile("volumetricLightingFS.glsl"));
            blurShader = new PostProcessShader(FileManager.getMediaFile("gaussianBlurVS.glsl"), FileManager.getMediaFile("gaussianBlurFS.glsl"));
            blurShader2 = new PostProcessShader(FileManager.getMediaFile("gaussianBlurVS.glsl"), FileManager.getMediaFile("gaussianBlurFS.glsl"));
            shadowMapShader = new DepthMapShader(FileManager.getMediaFile("depthMapVS.glsl"), FileManager.getMediaFile("depthMapFS.glsl"));
            depthMapShader = new DepthMapShader(FileManager.getMediaFile("depthMapVS.glsl"), FileManager.getMediaFile("depthMapFS.glsl"), screenWidth, screenHeight);
            shadowMappingShader = new ShadowMappingShader(FileManager.getMediaFile("shadowMappingVS.glsl"), FileManager.getMediaFile("shadowMappingFS.glsl"));
            blackShader = new PhongShader(FileManager.getMediaFile("blackVS.glsl"), FileManager.getMediaFile("blackFS.glsl"));
            whiteShader = new PhongShader(FileManager.getMediaFile("whiteVS.glsl"), FileManager.getMediaFile("whiteFS.glsl"));

            // Load Models
            sun.loadModelFromFile("sun.3ds");
            sun.position = new Vector3(20f, 30f, -70f);
            sun.scale = new Vector3(2f);
            sun.update();

            monkey.loadModelFromFile("monkey.3ds");
            monkey.position = new Vector3(20f, 4f, 2f);
            monkey.update();
            monkey.diffuse = new Vector3(0.1f, 0.1f, 0.8f);
            monkey.ambient = new Vector3(0.05f, 0.05f, 0.4f);

            magicBox.loadModelFromFile("magicBox.3ds");
            magicBox.position = new Vector3(20f, 6f, 0f);
            magicBox.scale = new Vector3(5f);
            magicBox.update();
            magicBox.diffuse = new Vector3(0.2f, 0.2f, 0f);
            magicBox.ambient = new Vector3(0.1f, 0.1f, 0f);
            // No Specular for the magicBox
            magicBox.specular = new Vector3(0f);
            magicBox.shininess = 1f;

            //Load floor
            floor.loadModelFromFile("floor.3ds");
            floor.position = new Vector3(0f, 0f, -10f);
            // Scale the Floor (and the texCoords)
            floor.scale = new Vector3(1000f, 1f, 1000f);
            //floor.scale = new Vector3(0.05f, 0.05f, 0.05f);
               // floor.rotation = new Vector3(45, 0, 0);
             for (int i = 0; i < floor.mesh.textureCoordinates.Count; i++)
              floor.mesh.textureCoordinates[i] *= 200f;
             floor.mesh.updateTextureCoordinates();
            floor.update();
            // No Specular for floor
            floor.specular = new Vector3(0f);
            floor.shininess = 1f;

            //Load trees
            Random random = new Random();
            for (int x = 0; x < 2; x++)
            {
                for (int z = 0; z < 10; z++)
                {
                    WorldObject tree = new WorldObject();
                    tree.loadModelFromFile("tree.3ds");
                    tree.position = new Vector3((x * 10f) - 5f, 0f, -z * 6f);
                    tree.scale = new Vector3(2f);
                    tree.rotation = new Vector3(0f, (float)(random.NextDouble() * Math.PI * 2.0), 0f);
                    tree.update();
                    tree.diffuse = new Vector3(0.6f, 0.3f, 0f);
                    tree.ambient = new Vector3(0.3f, 0.15f, 0f);
                    trees.Add(tree);
                }
            }

            // Move initial Position of the Camera away from origin
            camera.Position += new Vector3(10f, 10f, 10f);

            // Hide Mouse Cursor
            CursorVisible = false;
        }
Exemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            inputManager = new InputManager(this, camera);

            phongShader              = new PhongShader(FileManager.getMediaFile("phongVS.glsl"), FileManager.getMediaFile("phongFS.glsl"));
            postProcessShader        = new PostProcessShader(FileManager.getMediaFile("postProcessVS.glsl"), FileManager.getMediaFile("postProcessFS.glsl"));
            volumetricLightingShader = new VolumetricLightingShader(FileManager.getMediaFile("volumetricLightingVS.glsl"), FileManager.getMediaFile("volumetricLightingFS.glsl"));
            blurShader          = new PostProcessShader(FileManager.getMediaFile("bilinearGaussianBlurVS.glsl"), FileManager.getMediaFile("bilinearGaussianBlurFS.glsl"));
            blurShader2         = new PostProcessShader(FileManager.getMediaFile("bilinearGaussianBlurVS.glsl"), FileManager.getMediaFile("bilinearGaussianBlurFS.glsl"));
            shadowMapShader     = new DepthMapShader(FileManager.getMediaFile("depthMapVS.glsl"), FileManager.getMediaFile("depthMapFS.glsl"));
            depthMapShader      = new DepthMapShader(FileManager.getMediaFile("depthMapVS.glsl"), FileManager.getMediaFile("depthMapFS.glsl"), screenWidth, screenHeight);
            shadowMappingShader = new ShadowMappingShader(FileManager.getMediaFile("shadowMappingVS.glsl"), FileManager.getMediaFile("shadowMappingFS.glsl"));
            blackShader         = new PhongShader(FileManager.getMediaFile("blackVS.glsl"), FileManager.getMediaFile("blackFS.glsl"));
            whiteShader         = new PhongShader(FileManager.getMediaFile("whiteVS.glsl"), FileManager.getMediaFile("whiteFS.glsl"));

            // Load Models
            sun.loadModelFromFile("sun.3ds");
            sun.position = new Vector3(20f, 30f, 35f);
            sun.scale    = new Vector3(2f);
            sun.update();

            monkey.loadModelFromFile("monkey.3ds");
            monkey.position = new Vector3(30f, 4f, 2f);
            monkey.update();
            monkey.diffuse = new Vector3(0.1f, 0.1f, 0.8f);
            monkey.ambient = new Vector3(0.05f, 0.05f, 0.4f);

            rmonkey.loadModelFromFile("monkey.3ds");
            rmonkey.position = new Vector3(18.5f, 2f, -27.5f);
            rmonkey.update();
            rmonkey.diffuse   = new Vector3(0.1f, 0.1f, 0.8f);
            rmonkey.ambient   = new Vector3(0.05f, 0.05f, 0.4f);
            rmonkey.diffuse   = new Vector3(0.1f, 0.1f, 0.1f);
            rmonkey.ambient   = new Vector3(0.05f, 0.05f, 0.05f);
            rmonkey.specular  = new Vector3(0f);
            rmonkey.shininess = 1f;

            house.loadModelFromFile("house.3ds");
            house.position = new Vector3(15f, 3.01f, -34f);
            house.scale    = new Vector3(3f);
            house.update();
            house.diffuse   = new Vector3(0.1f, 0.1f, 0.1f);
            house.ambient   = new Vector3(0.05f, 0.05f, 0.05f);
            house.specular  = new Vector3(0f);
            house.shininess = 1f;

            magicBox.loadModelFromFile("magicBox.3ds");
            magicBox.position = new Vector3(30f, 6f, 0f);
            magicBox.scale    = new Vector3(5f);
            magicBox.update();
            magicBox.diffuse = new Vector3(0.2f, 0.2f, 0f);
            magicBox.ambient = new Vector3(0.1f, 0.1f, 0f);
            // No Specular for the magicBox
            magicBox.specular  = new Vector3(0f);
            magicBox.shininess = 1f;

            //Load floor
            floor.loadModelFromFile("floor.3ds");
            floor.position = new Vector3(0f, 0f, -10f);
            // Scale the Floor (and the texCoords)
            floor.scale = new Vector3(1000f, 1f, 1000f);
            //floor.scale = new Vector3(0.05f, 0.05f, 0.05f);
            // floor.rotation = new Vector3(45, 0, 0);
            for (int i = 0; i < floor.mesh.textureCoordinates.Count; i++)
            {
                floor.mesh.textureCoordinates[i] *= 200f;
            }
            floor.mesh.updateTextureCoordinates();
            floor.update();
            // No Specular for floor
            floor.specular  = new Vector3(0f);
            floor.shininess = 1f;

            //Load trees
            Random random = new Random();

            for (int x = 0; x < 2; x++)
            {
                for (int z = 0; z < 10; z++)
                {
                    WorldObject tree = new WorldObject();
                    tree.loadModelFromFile("tree.3ds");
                    tree.position = new Vector3((x * 10f) - 5f, 0f, -z * 6f);
                    tree.scale    = new Vector3(2f);
                    tree.rotation = new Vector3(0f, (float)(random.NextDouble() * Math.PI * 2.0), 0f);
                    tree.update();
                    tree.diffuse   = new Vector3(0.6f, 0.3f, 0f);
                    tree.ambient   = new Vector3(0.3f, 0.15f, 0f);
                    tree.specular  = new Vector3(0f);
                    tree.shininess = 1f;
                    trees.Add(tree);
                }
            }

            // Move initial Position of the Camera away from origin
            camera.Position += new Vector3(0f, 0.5f, 0f);

            // Hide Mouse Cursor
            CursorVisible = false;
        }