public static Ray BuildRay(Point screenPixel, Base3DCamera camera)
        {
            Viewport vp = new Viewport(0, 0, camera.Game.GraphicsDevice.PresentationParameters.BackBufferWidth, camera.Game.GraphicsDevice.PresentationParameters.BackBufferHeight);

            vp.MinDepth = camera.Viewport.MinDepth;
            vp.MaxDepth = camera.Viewport.MaxDepth;

            Vector3 nearSource = vp.Unproject(new Vector3(screenPixel.X, screenPixel.Y, camera.Viewport.MinDepth), camera.Projection, camera.View, Matrix.Identity);
            Vector3 farSource  = vp.Unproject(new Vector3(screenPixel.X, screenPixel.Y, camera.Viewport.MaxDepth), camera.Projection, camera.View, Matrix.Identity);
            Vector3 direction  = farSource - nearSource;

            direction.Normalize();

            return(new Ray(nearSource, direction));
        }
        public static float RayPicking(Point screenPixel, BoundingBox volume, Base3DCamera camera)
        {
            float?retVal = float.MaxValue;

            BuildRay(screenPixel, camera).Intersects(ref volume, out retVal);

            if (retVal != null)
            {
                return(retVal.Value);
            }
            else
            {
                return(float.MaxValue);
            }
        }
Example #3
0
        public Game1()
            : base()
        {
            graphics.PreferredBackBufferHeight = 600;
            graphics.PreferredBackBufferWidth  = 800;

            camera = new Base3DCamera(this, .1f, 20000);

            floor = new BaseDeferredObject(this, "Models/plane");
            floor.TextureMaterials.Add("Textures/FloorColor");
            floor.NormalMaterials.Add("Textures/FloorNormal");
            floor.Position = new Vector3(0, -1f, -10);
            Components.Add(floor);

            skinnedInstancer = new Base3DDeferredSkinnedObjectInstancer(this, "Models/dude");
            skinnedInstancer.AnimationClip = "Take 001";
            Components.Add(skinnedInstancer);

            skinnedInstancerOffset = new Base3DDeferredSkinnedObjectInstancer(this, "Models/dude");
            skinnedInstancerOffset.AnimationOffSet = new TimeSpan(0, 0, 0, 0, 500);
            skinnedInstancerOffset.AnimationClip   = "Take 001";
            Components.Add(skinnedInstancerOffset);


            for (int d = 0; d < 10; d++)
            {
                float x = MathHelper.Lerp(-sqr, sqr, (float)rnd.NextDouble());
                float y = -1;
                float z = MathHelper.Lerp(-sqr, sqr / 2, (float)rnd.NextDouble());

                if (((d + 1) % 2) == 0) // Split them in two.
                {
                    dudes.Add(dudes.Count, new Base3DDeferredSkinnedInstance(this, new Vector3(x, y, z - 5), Vector3.One * .05f, Quaternion.CreateFromAxisAngle(Vector3.Up, MathHelper.PiOver2), new Vector4((float)rnd.NextDouble(), (float)rnd.NextDouble(), (float)rnd.NextDouble(), 1), ref skinnedInstancer));
                }
                else
                {
                    dudes.Add(dudes.Count, new Base3DDeferredSkinnedInstance(this, new Vector3(x, y, z - 5), Vector3.One * .05f, Quaternion.CreateFromAxisAngle(Vector3.Up, MathHelper.PiOver2), Color.White.ToVector4(), ref skinnedInstancerOffset));
                }
            }


            SunPosition = new Vector3(110, 110, 200);

            renderer.DirectionalLights.Add(new DeferredDirectionalLight(this, SunPosition, Vector3.Zero, Color.White, 1, true));
        }
Example #4
0
        public Game1()
            : base()
        {
            graphics.PreferredBackBufferHeight = 600;
            graphics.PreferredBackBufferWidth  = 800;

            camera = new Base3DCamera(this, .1f, 20000);

            terrain          = new BruteForceTerrain(this, "Textures/heightMap3");
            terrain.Position = new Vector3(-128, -30, -128);
            Components.Add(terrain);

            SunPosition = new Vector3(220, 225, 400);

            renderer.DirectionalLights.Add(new DeferredDirectionalLight(this, SunPosition, Vector3.Zero, Color.White, 1, true));

            Water.Enabled = true;
        }
Example #5
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            kbm = new KeyboardStateManager(this);

            camera          = new Base3DCamera(this, .5f, 2000);
            camera.Position = new Vector3(0, 0, 10);
            Components.Add(camera);
            Services.AddService(typeof(Base3DCamera), camera);

            Base3DObject tree = new Base3DObject(this, "Models/trees_pine", "Shaders/RenderObjectNoTangents");

            tree.ColorAsset = "Models/palette";
            tree.Rotate(Vector3.Up, -90);
            tree.Position = new Vector3(0, -2, 0);
            tree.Scale    = Vector3.One * .01f;
            Components.Add(tree);
        }
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            graphics.GraphicsProfile = GraphicsProfile.HiDef;

            graphics.PreferredBackBufferWidth  = 1920;
            graphics.PreferredBackBufferHeight = 1080;

            IsMouseVisible = true;

            kbm = new KeyboardStateManager(this);

            camera          = new Base3DCamera(this, .5f, 20000);
            camera.Position = new Vector3(0, 0, 10);
            Components.Add(camera);
            Services.AddService(typeof(Base3DCamera), camera);

            Fire3D                = new RCLayeredFire(this, 8);
            Fire3D.Scale          = new Vector3(2, 6, 8);
            Fire3D.AnimationSpeed = .01f;
            Fire3D.FlameOffSet    = .2f;

            Components.Add(Fire3D);

            Fire = new CPUOldSchoolFire(this, new Point(400, 240));
            Components.Add(Fire);

            Fire2 = new GPUOldSchoolFire(this, new Point(400, 240));
            Components.Add(Fire2);

            Fire3 = new GPUOldSchoolFireBox(this);
            Components.Add(Fire3);

            Fire3D.Enabled = false;
            Fire.Enabled   = false;
            Fire2.Enabled  = false;
            Fire3.Enabled  = false;
            Fire3D.Enabled = true;
        }
Example #7
0
        public Game1()
            : base()
        {
            graphics.PreferredBackBufferHeight = 600;
            graphics.PreferredBackBufferWidth  = 800;

            camera = new Base3DCamera(this, .1f, 20000);

            BasicColumnScene          = new BaseDeferredObject(this);
            BasicColumnScene.Position = new Vector3(0, -1, 0);
            BasicColumnScene.Scale    = new Vector3(.5f, 1, .5f);
            BasicColumnScene.Mesh     = "Models/BasicColumnScene";
            BasicColumnScene.TextureMaterials.Add("Textures/floor_color");
            BasicColumnScene.TextureMaterials.Add("Textures/bricks_color");
            BasicColumnScene.NormalMaterials.Add("Textures/floor_normal");
            BasicColumnScene.NormalMaterials.Add("Textures/bricks_normal");
            Components.Add(BasicColumnScene);

            dude               = new BaseDeferredSkinnedObject(this);
            dude.Position      = new Vector3(0, -1, -5);
            dude.AnimationClip = "Take 001";
            dude.Scale         = Vector3.One * .05f;
            dude.Mesh          = "Models/dude";
            Components.Add(dude);

            SunPosition = new Vector3(100, 300, -200);

            renderer.DirectionalLights.Add(new DeferredDirectionalLight(this, SunPosition, Vector3.Zero, Color.White, directionalIntensity, true));

            renderer.ConeLights.Add(new DeferredConeLight(this, Vector3.Zero + Vector3.Up * 5, new Vector3(0, 0, -20), Color.White, 1.5f, coneAngle, codeDecay, true));
            renderer.ConeLights.Add(new DeferredConeLight(this, Vector3.Zero + Vector3.Up * 5, new Vector3(0, 0, 20), Color.White, 1.5f, coneAngle, codeDecay, true));
            renderer.ConeLights.Add(new DeferredConeLight(this, Vector3.Zero + Vector3.Up * 5, new Vector3(20, 0, 0), Color.White, 1.5f, coneAngle, codeDecay, true));
            renderer.ConeLights.Add(new DeferredConeLight(this, Vector3.Zero + Vector3.Up * 5, new Vector3(-20, 0, 0), Color.White, 1.5f, coneAngle, codeDecay, true));

            renderer.PointLights.Add(new DeferredPointLight(new Vector3(-10, 5, -10), Color.White, 10, 2, false));
            renderer.PointLights.Add(new DeferredPointLight(new Vector3(10, 5, -10), Color.Red, 10, 2, false));
            renderer.PointLights.Add(new DeferredPointLight(new Vector3(0, 5, 0), Color.Green, 11, 2, false));
            renderer.PointLights.Add(new DeferredPointLight(new Vector3(-10, 5, 10), Color.Blue, 10, 2, false));
            renderer.PointLights.Add(new DeferredPointLight(new Vector3(10, 5, 10), Color.Gold, 10, 2, false));
        }
Example #8
0
        public Game1()
            : base()
        {
            graphics.PreferredBackBufferHeight = 600;
            graphics.PreferredBackBufferWidth  = 800;

            camera = new Base3DCamera(this, .1f, 20000);

            floor = new BaseDeferredObject(this, "Models/plane");
            floor.TextureMaterials.Add("Textures/FloorColor");
            floor.NormalMaterials.Add("Textures/FloorNormal");
            floor.Position = new Vector3(0, -.75f, -10);
            Components.Add(floor);

            box = new BaseDeferredObject(this, "Models/Box");
            box.TextureMaterials.Add("Textures/BoxColor");
            box.NormalMaterials.Add("Textures/BoxNormal");
            box.Position = new Vector3(0, 0, -10);
            Components.Add(box);

            box1 = new BaseDeferredObject(this, "Models/Box");
            box1.TextureMaterials.Add("Textures/BoxColor01");
            box1.NormalMaterials.Add("Textures/BoxNormal01");
            box1.Position = new Vector3(0, 2.25f, -10);
            Components.Add(box1);

            box2 = new BaseDeferredObject(this, "Models/Box");
            box2.TextureMaterials.Add("Textures/BoxColor02");
            box2.NormalMaterials.Add("Textures/BoxNormal02");
            box2.Position = new Vector3(0, 4.5f, -10);
            Components.Add(box2);

            snowInstancer = new Base3DParticleInstancer(this, "Shaders/Particles/FallingWeatherParticleInstance");
            snowInstancer.TextureMaterials.Add("Textures/Particles/snow");
            snowInstancer.Position = new Vector3(0, -1, 0);
            //instancer2.Size = Vector2.One * .1f;
            Components.Add(snowInstancer);

            float sqr = 100;

            for (int a = 0; a < 100000; a++)
            {
                float x = MathHelper.Lerp(-sqr, sqr, (float)rnd.NextDouble());
                float y = MathHelper.Lerp(0, sqr / 2, (float)rnd.NextDouble());
                float z = MathHelper.Lerp(-sqr, sqr, (float)rnd.NextDouble());

                particles.Add(new Base3DParticleInstance(this, new Vector3(x, y, z), Vector3.One, snowInstancer));
            }

            tailInstancer = new Base3DParticleInstancer(this, "Shaders/Particles/Trail");
            tailInstancer.TextureMaterials.Add("Textures/Particles/bling2");
            tailInstancer.Color = Color.White;
            tailInstancer.Rotate(Vector3.Forward, (float)Math.PI / 2);
            Components.Add(tailInstancer);

            for (int a = 0; a < 1000; a++)
            {
                float y = MathHelper.Lerp(0, sqr / 2, (float)rnd.NextDouble());
                float x = MathHelper.Lerp(0, .2f, (float)rnd.NextDouble());
                float z = MathHelper.Lerp(0, .2f, (float)rnd.NextDouble());

                System.Threading.Thread.Sleep(1);
                particles.Add(new Base3DParticleInstance(this, new Vector3(x, y, z), Vector3.One * 1f, tailInstancer));
            }

            smokeInstancer = new Base3DParticleInstancer(this, "Shaders/Particles/RisingSmokeInstanced");
            smokeInstancer.TextureMaterials.Add("Textures/Particles/smoke");
            Components.Add(smokeInstancer);

            for (int s = 0; s < 100; s++)
            {
                float x = MathHelper.Lerp(-sqr, sqr, (float)rnd.NextDouble());
                float z = MathHelper.Lerp(-sqr, sqr, (float)rnd.NextDouble());

                PlaceRisingsmoke(new Vector3(x, -.75f, z), 5);
            }

            SunPosition = new Vector3(0, 300, 200);

            renderer.DirectionalLights.Add(new DeferredDirectionalLight(this, SunPosition, Vector3.Zero, Color.White, 1, true));
        }
Example #9
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            graphics.GraphicsProfile = GraphicsProfile.HiDef;

            graphics.PreferredBackBufferWidth  = 1920;
            graphics.PreferredBackBufferHeight = 1080;

            IsMouseVisible = true;


            float dist = -25f;

            kbm = new KeyboardStateManager(this);

            camera          = new Base3DCamera(this, .5f, 20000);
            camera.Position = new Vector3(0, 0, 0);
            Components.Add(camera);
            Services.AddService(typeof(Base3DCamera), camera);


            #region Light And Shade I
            light          = new LightModel(this, Color.White);
            light.Position = new Vector3(7, 7, dist);
            Components.Add(light);

            ShowLightAndShader[0] = true;

            // Ambient Only
            skullAmbient                  = new LightAndShadeModel(this, "Models/skullocc", "Shaders/AmbientLight");
            skullAmbient.Scale            = Vector3.One * .5f;
            skullAmbient.AmbientColor     = AmbientColor;
            skullAmbient.AmbientIntensity = AmbientIntensity;
            skullAmbient.Position         = new Vector3(0, 5, dist);
            Components.Add(skullAmbient);

            sphereAmbient = new LightAndShadeModel(this, "Models/sphere", "Shaders/AmbientLight");
            sphereAmbient.AmbientColor     = AmbientColor;
            sphereAmbient.AmbientIntensity = AmbientIntensity;
            sphereAmbient.Position         = new Vector3(5, 5, dist);
            Components.Add(sphereAmbient);

            teapotAmbient = new LightAndShadeModel(this, "Models/teapot", "Shaders/AmbientLight");
            teapotAmbient.AmbientColor     = AmbientColor;
            teapotAmbient.AmbientIntensity = AmbientIntensity;
            teapotAmbient.Position         = new Vector3(-5, 5, dist);
            Components.Add(teapotAmbient);

            // Diffuse Only
            skullDiffuse       = new LightAndShadeModel(this, "Models/skullocc", "Shaders/DiffuseLight");
            skullDiffuse.Scale = Vector3.One * .5f;
            skullDiffuse.SetLightParams(0, light);
            skullDiffuse.Position = new Vector3(0, 0, dist);
            Components.Add(skullDiffuse);

            sphereDiffuse = new LightAndShadeModel(this, "Models/sphere", "Shaders/DiffuseLight");
            sphereDiffuse.SetLightParams(0, light);
            sphereDiffuse.Position = new Vector3(5, 0, dist);
            Components.Add(sphereDiffuse);

            teapotDiffuse = new LightAndShadeModel(this, "Models/teapot", "Shaders/DiffuseLight");
            teapotDiffuse.SetLightParams(0, light);
            teapotDiffuse.Position = new Vector3(-5, 0, dist);
            Components.Add(teapotDiffuse);

            // Ambitne & Diffuse
            skullAmbientDiffuse       = new LightAndShadeModel(this, "Models/skullocc", "Shaders/AmbientDiffuseLight");
            skullAmbientDiffuse.Scale = Vector3.One * .5f;
            skullAmbientDiffuse.SetLightParams(0, light);
            skullAmbientDiffuse.AmbientColor     = AmbientColor;
            skullAmbientDiffuse.AmbientIntensity = AmbientIntensity;
            skullAmbientDiffuse.Position         = new Vector3(0, -5, dist);
            Components.Add(skullAmbientDiffuse);

            sphereAmbientDiffuse = new LightAndShadeModel(this, "Models/sphere", "Shaders/AmbientDiffuseLight");
            sphereAmbientDiffuse.AmbientColor = AmbientColor;
            sphereAmbientDiffuse.SetLightParams(0, light);
            sphereAmbientDiffuse.AmbientIntensity = AmbientIntensity;
            sphereAmbientDiffuse.Position         = new Vector3(5, -5, dist);
            Components.Add(sphereAmbientDiffuse);

            teapotAmbientDiffuse = new LightAndShadeModel(this, "Models/teapot", "Shaders/AmbientDiffuseLight");
            teapotAmbientDiffuse.AmbientColor = AmbientColor;
            teapotAmbientDiffuse.SetLightParams(0, light);
            teapotAmbientDiffuse.AmbientIntensity = AmbientIntensity;
            teapotAmbientDiffuse.Position         = new Vector3(-5, -5, dist);
            Components.Add(teapotAmbientDiffuse);
            #endregion

            #region Light & Shade II

            ShowLightAndShader[1] = false;
            // Colored Lights
            lights = new List <LightModel>();

            for (int l = 0; l < 3; l++)
            {
                LightModel lm = null;
                switch (l)
                {
                case 0:
                    lm          = new LightModel(this, Color.Gold, Color.White);
                    lm.Position = new Vector3(7, 7, dist);
                    break;

                case 1:
                    lm          = new LightModel(this, Color.Red, Color.White);
                    lm.Position = new Vector3(-7, 7, dist);
                    break;

                case 2:
                    lm          = new LightModel(this, Color.Blue, Color.White);
                    lm.Position = new Vector3(-7, -7, dist);
                    break;
                }

                lights.Add(lm);
                Components.Add(lm);
            }

            // Diffuse Colored
            skullAmbientDiffuseColorLight                  = new LightAndShadeModel(this, "Models/skullocc", "Shaders/AmbientDiffuseColoredLight");
            skullAmbientDiffuseColorLight.Scale            = Vector3.One * .5f;
            skullAmbientDiffuseColorLight.AmbientColor     = AmbientColor;
            skullAmbientDiffuseColorLight.AmbientIntensity = AmbientIntensity;
            skullAmbientDiffuseColorLight.Position         = new Vector3(0, 5, dist);
            skullAmbientDiffuseColorLight.SetLightParams(0, lights[0]);
            Components.Add(skullAmbientDiffuseColorLight);

            sphereAmbientDiffuseColorLight = new LightAndShadeModel(this, "Models/sphere", "Shaders/AmbientDiffuseColoredLight");
            sphereAmbientDiffuseColorLight.AmbientColor     = AmbientColor;
            sphereAmbientDiffuseColorLight.AmbientIntensity = AmbientIntensity;
            sphereAmbientDiffuseColorLight.Position         = new Vector3(5, 5, dist);
            sphereAmbientDiffuseColorLight.SetLightParams(0, lights[0]);
            Components.Add(sphereAmbientDiffuseColorLight);

            teapotAmbientDiffuseColorLight = new LightAndShadeModel(this, "Models/teapot", "Shaders/AmbientDiffuseColoredLight");
            teapotAmbientDiffuseColorLight.AmbientColor     = AmbientColor;
            teapotAmbientDiffuseColorLight.AmbientIntensity = AmbientIntensity;
            teapotAmbientDiffuseColorLight.Position         = new Vector3(-5, 5, dist);
            teapotAmbientDiffuseColorLight.SetLightParams(0, lights[0]);
            Components.Add(teapotAmbientDiffuseColorLight);

            // MultiLight
            skullAmbientDiffuseColorMultiLight                  = new LightAndShadeModel(this, "Models/skullocc", "Shaders/ADCMultiLight");
            skullAmbientDiffuseColorMultiLight.MultiLight       = true;
            skullAmbientDiffuseColorMultiLight.Scale            = Vector3.One * .5f;
            skullAmbientDiffuseColorMultiLight.AmbientColor     = AmbientColor;
            skullAmbientDiffuseColorMultiLight.AmbientIntensity = AmbientIntensity;
            skullAmbientDiffuseColorMultiLight.Position         = new Vector3(0, 0, dist);
            Components.Add(skullAmbientDiffuseColorMultiLight);

            sphereAmbientDiffuseColorMultiLight                  = new LightAndShadeModel(this, "Models/sphere", "Shaders/ADCMultiLight");
            sphereAmbientDiffuseColorMultiLight.MultiLight       = true;
            sphereAmbientDiffuseColorMultiLight.AmbientColor     = AmbientColor;
            sphereAmbientDiffuseColorMultiLight.AmbientIntensity = AmbientIntensity;
            sphereAmbientDiffuseColorMultiLight.Position         = new Vector3(5, 0, dist);
            Components.Add(sphereAmbientDiffuseColorMultiLight);

            teapotAmbientDiffuseColorMultiLight                  = new LightAndShadeModel(this, "Models/teapot", "Shaders/ADCMultiLight");
            teapotAmbientDiffuseColorMultiLight.MultiLight       = true;
            teapotAmbientDiffuseColorMultiLight.AmbientColor     = AmbientColor;
            teapotAmbientDiffuseColorMultiLight.AmbientIntensity = AmbientIntensity;
            teapotAmbientDiffuseColorMultiLight.Position         = new Vector3(-5, 0, dist);
            Components.Add(teapotAmbientDiffuseColorMultiLight);

            // Light with specualr Blinn-Phong
            skullAmbientDiffuseColorBlinnPhongLight                  = new LightAndShadeModel(this, "Models/skullocc", "Shaders/BlinnPhong");
            skullAmbientDiffuseColorBlinnPhongLight.MultiLight       = false;
            skullAmbientDiffuseColorBlinnPhongLight.Scale            = Vector3.One * .5f;
            skullAmbientDiffuseColorBlinnPhongLight.AmbientColor     = AmbientColor;
            skullAmbientDiffuseColorBlinnPhongLight.AmbientIntensity = AmbientIntensity;
            skullAmbientDiffuseColorBlinnPhongLight.Position         = new Vector3(0, -5, dist);
            Components.Add(skullAmbientDiffuseColorBlinnPhongLight);

            sphereAmbientDiffuseColorBlinnPhongLight                  = new LightAndShadeModel(this, "Models/sphere", "Shaders/BlinnPhong");
            sphereAmbientDiffuseColorBlinnPhongLight.MultiLight       = false;
            sphereAmbientDiffuseColorBlinnPhongLight.AmbientColor     = AmbientColor;
            sphereAmbientDiffuseColorBlinnPhongLight.AmbientIntensity = AmbientIntensity;
            sphereAmbientDiffuseColorBlinnPhongLight.Position         = new Vector3(5, -5, dist);
            Components.Add(sphereAmbientDiffuseColorBlinnPhongLight);

            teapotAmbientDiffuseColorBlinnPhongLight                  = new LightAndShadeModel(this, "Models/teapot", "Shaders/BlinnPhong");
            teapotAmbientDiffuseColorBlinnPhongLight.MultiLight       = false;
            teapotAmbientDiffuseColorBlinnPhongLight.AmbientColor     = AmbientColor;
            teapotAmbientDiffuseColorBlinnPhongLight.AmbientIntensity = AmbientIntensity;
            teapotAmbientDiffuseColorBlinnPhongLight.Position         = new Vector3(-5, -5, dist);
            Components.Add(teapotAmbientDiffuseColorBlinnPhongLight);

            skullAmbientDiffuseColorBlinnPhongLight.SetLightParams(0, lights[0]);
            sphereAmbientDiffuseColorBlinnPhongLight.SetLightParams(0, lights[0]);
            teapotAmbientDiffuseColorBlinnPhongLight.SetLightParams(0, lights[0]);

            for (int l = 0; l < lights.Count; l++)
            {
                skullAmbientDiffuseColorMultiLight.SetLightParams(l, lights[l]);
                sphereAmbientDiffuseColorMultiLight.SetLightParams(l, lights[l]);
                teapotAmbientDiffuseColorMultiLight.SetLightParams(l, lights[l]);
            }
            #endregion

            #region Light & Shade III
            lightIII          = new LightModel(this, Color.Gold);
            lightIII.Position = new Vector3(10, 0, 0);
            Components.Add(lightIII);

            ShowLightAndShader[2] = false;

            colorPlanet          = new LightAndShadeModel(this, "Models/sphere", "Shaders/ColorMap", "Textures/Earth_Diffuse");
            colorPlanet.Position = new Vector3(-2, 0, -5);
            colorPlanet.SetLightParams(0, lightIII);
            Components.Add(colorPlanet);

            colorGlowPlanet          = new LightAndShadeModel(this, "Models/sphere", "Shaders/ColorGlowMap", "Textures/Earth_Diffuse", "Textures/Earth_Night");
            colorGlowPlanet.Position = new Vector3(0, 0, -7);
            colorGlowPlanet.SetLightParams(0, lightIII);
            Components.Add(colorGlowPlanet);

            colorGlowBumpPlanet          = new LightAndShadeModel(this, "Models/sphere", "Shaders/ColorGlowBumpMap", "Textures/Earth_Diffuse", "Textures/Earth_Night", "Textures/Earth_NormalMap");
            colorGlowBumpPlanet.Position = new Vector3(2, 0, -9);
            colorGlowBumpPlanet.SetLightParams(0, lightIII);
            Components.Add(colorGlowBumpPlanet);

            colorGlowBumpReflectPlanet          = new LightAndShadeModel(this, "Models/sphere", "Shaders/ColorGlowBumpReflect", "Textures/Earth_Diffuse", "Textures/Earth_Night", "Textures/Earth_NormalMap", "Textures/Earth_ReflectionMask");
            colorGlowBumpReflectPlanet.Position = new Vector3(4, 0, -11);
            colorGlowBumpReflectPlanet.SetLightParams(0, lightIII);
            Components.Add(colorGlowBumpReflectPlanet);

            #endregion


            #region Light & Shade V
            ShowLightAndShader[3] = false;
            skyBox = new BaseSkyBox(this, "Textures/cubemap");
            Components.Add(skyBox);

            skullGlass          = new LightAndShadeModel(this, "Models/skullocc", "Shaders/glass1", "Textures/cubemap");
            skullGlass.Scale    = Vector3.One * .5f;
            skullGlass.Tint     = Color.White;
            skullGlass.Position = new Vector3(0, 5, dist);
            Components.Add(skullGlass);

            sphereGlass          = new LightAndShadeModel(this, "Models/sphere", "shaders/glass1", "Textures/cubemap");
            sphereGlass.Tint     = Color.White;
            sphereGlass.Position = new Vector3(-5, 5, dist);
            Components.Add(sphereGlass);

            teapotGlass          = new LightAndShadeModel(this, "Models/teapot", "shaders/glass1", "Textures/cubemap");
            teapotGlass.Position = new Vector3(5, 5, dist);
            teapotGlass.Tint     = Color.White;
            Components.Add(teapotGlass);

            skullGlassFrez          = new LightAndShadeModel(this, "Models/skullocc", "shaders/glass2", "Textures/cubemap", "Textures/Fresnel");
            skullGlassFrez.Scale    = Vector3.One * .5f;
            skullGlassFrez.Tint     = Color.White;
            skullGlassFrez.Position = new Vector3(0, 0, dist);
            Components.Add(skullGlassFrez);

            sphereGlassFrez          = new LightAndShadeModel(this, "Models/sphere", "shaders/glass2", "Textures/cubemap", "Textures/Fresnel");
            sphereGlassFrez.Position = new Vector3(-5, 0, dist);
            sphereGlassFrez.Tint     = Color.White;
            Components.Add(sphereGlassFrez);

            teapotGlassFrez          = new LightAndShadeModel(this, "Models/teapot", "shaders/glass2", "Textures/cubemap", "Textures/Fresnel");
            teapotGlassFrez.Position = new Vector3(5, 0, dist);
            teapotGlassFrez.Tint     = Color.White;
            Components.Add(teapotGlassFrez);

            skullGlassFrezFree          = new LightAndShadeModel(this, "Models/skullocc", "shaders/glass3", "Textures/cubemap");
            skullGlassFrezFree.Scale    = Vector3.One * .5f;
            skullGlassFrezFree.Tint     = Color.White;
            skullGlassFrezFree.Position = new Vector3(0, -5, dist);
            Components.Add(skullGlassFrezFree);

            sphereGlassFrezFree          = new LightAndShadeModel(this, "Models/sphere", "shaders/glass3", "Textures/cubemap");
            sphereGlassFrezFree.Position = new Vector3(-5, -5, dist);
            sphereGlassFrezFree.Tint     = Color.White;
            Components.Add(sphereGlassFrezFree);

            teapotGlassFrezFree          = new LightAndShadeModel(this, "Models/teapot", "shaders/glass3", "Textures/cubemap");
            teapotGlassFrezFree.Position = new Vector3(5, -5, dist);
            teapotGlassFrezFree.Tint     = Color.White;
            Components.Add(teapotGlassFrezFree);

            #endregion

            #region Light & Shade VI
            ShowLightAndShader[4] = false;
            skullRefract          = new LightAndShadeModel(this, "Models/skullocc", "Shaders/Refraction", "Textures/cubemap");
            skullRefract.Scale    = Vector3.One * .5f;
            skullRefract.Position = new Vector3(0, 5, dist);
            Components.Add(skullRefract);

            sphereRefract          = new LightAndShadeModel(this, "Models/sphere", "Shaders/Refraction", "Textures/cubemap");
            sphereRefract.Position = new Vector3(-5, 5, dist);
            Components.Add(sphereRefract);

            teapotRefract          = new LightAndShadeModel(this, "Models/teapot", "Shaders/Refraction", "Textures/cubemap");
            teapotRefract.Position = new Vector3(5, 5, dist);
            Components.Add(teapotRefract);

            skullReflect          = new LightAndShadeModel(this, "Models/skullocc", "Shaders/Reflection", "Textures/cubemap");
            skullReflect.Scale    = Vector3.One * .5f;
            skullReflect.Position = new Vector3(0, 0, dist);
            Components.Add(skullReflect);

            sphereReflect          = new LightAndShadeModel(this, "Models/sphere", "Shaders/Reflection", "Textures/cubemap");
            sphereReflect.Position = new Vector3(-5, 0, dist);
            Components.Add(sphereReflect);

            teapotReflect          = new LightAndShadeModel(this, "Models/teapot", "Shaders/Reflection", "Textures/cubemap");
            teapotReflect.Position = new Vector3(5, 0, dist);
            Components.Add(teapotReflect);

            skullReflectRefract          = new LightAndShadeModel(this, "Models/skullocc", "Shaders/ReflectionAndRefraction", "Textures/cubemap");
            skullReflectRefract.Scale    = Vector3.One * .5f;
            skullReflectRefract.Position = new Vector3(0, -5, dist);
            Components.Add(skullReflectRefract);

            sphereReflectRefract          = new LightAndShadeModel(this, "Models/sphere", "Shaders/ReflectionAndRefraction", "Textures/cubemap");
            sphereReflectRefract.Position = new Vector3(-5, -5, dist);
            Components.Add(sphereReflectRefract);

            teapotReflectRefract          = new LightAndShadeModel(this, "Models/teapot", "Shaders/ReflectionAndRefraction", "Textures/cubemap");
            teapotReflectRefract.Position = new Vector3(5, -5, dist);
            Components.Add(teapotReflectRefract);

            skullRC3DGlass          = new LightAndShadeModel(this, "Models/skullocc", "Shaders/RC3DGlass", "Textures/cubemap");
            skullRC3DGlass.Scale    = Vector3.One * .5f;
            skullRC3DGlass.Position = new Vector3(0, -10, dist);
            Components.Add(skullRC3DGlass);

            sphereRC3DGlass          = new LightAndShadeModel(this, "Models/sphere", "Shaders/RC3DGlass", "Textures/cubemap");
            sphereRC3DGlass.Position = new Vector3(-5, -10, dist);
            Components.Add(sphereRC3DGlass);

            teapotRC3DGlass          = new LightAndShadeModel(this, "Models/teapot", "Shaders/RC3DGlass", "Textures/cubemap");
            teapotRC3DGlass.Position = new Vector3(5, -10, dist);
            Components.Add(teapotRC3DGlass);
            #endregion

            #region Light & Shade VIII
            ShowLightAndShader[5] = false;

            lightVIII          = new LightModel(this, Color.White);
            lightVIII.Position = Vector3.Right * 10;
            Components.Add(lightVIII);

            earth          = new LightAndShadeModel(this, "Models/sphere", "Shaders/PlanetShader", "Textures/Earth_Diffuse", "Textures/Earth_Night", "Textures/Earth_NormalMap", "Textures/Earth_ReflectionMask", "Textures/Earth_Cloud", "Textures/WaterRipples", "Textures/Earth_Atmos");
            earth.Position = new Vector3(0, 0, -50);
            earth.SetLightParams(0, lightVIII);
            earth.Scale = Vector3.One * 10f;
            Components.Add(earth);
            #endregion
        }
        public static Vector2 CameraScreenPoint(Point screenPixel, Base3DCamera camera)
        {
            Vector2 retVal = new Vector2(((((float)screenPixel.X)) / camera.Game.GraphicsDevice.PresentationParameters.BackBufferWidth) * camera.Viewport.Width, ((((float)screenPixel.Y)) / camera.Game.GraphicsDevice.PresentationParameters.BackBufferHeight) * camera.Viewport.Height);

            return(retVal);
        }
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            graphics.GraphicsProfile = GraphicsProfile.HiDef;

            graphics.PreferredBackBufferWidth  = 1920;
            graphics.PreferredBackBufferHeight = 1080;

            IsMouseVisible = true;

            kbm = new KeyboardStateManager(this);

            camera          = new Base3DCamera(this, .5f, 20000);
            camera.Position = new Vector3(0, 0, 0);
            Components.Add(camera);
            Services.AddService(typeof(Base3DCamera), camera);

            skyBox = new BaseSkyBox(this, "Textures/SkyBox/NebulaBlue");
            Components.Add(skyBox);

            bunny               = new Base3DObject(this, "Models/bunny", "Shaders/RenderObjectNotTangentsOrTexCoords");
            bunny.Position      = new Vector3(2, -1.5f, -20);
            bunny.LightPosition = LightPosition;
            Components.Add(bunny);

            cube               = new Base3DObject(this, "Models/cube");
            cube.Position      = new Vector3(0, 0, -10);
            cube.ColorAsset    = "Textures/h2mcpCube";
            cube.BumpAsset     = "Textures/h2mcpCubeNormal";
            cube.LightPosition = LightPosition;
            Components.Add(cube);

            bunnies = new Base3DObject[10];
            for (int s = 0; s < 10; s++)
            {
                bunnies[s]               = new Base3DObject(this, "Models/Bunny");
                bunnies[s].Position      = new Vector3(20 + (s * 12), -1.5f, -10 - (s * 12));
                bunnies[s].ColorAsset    = "Textures/WindmillTopColor";
                bunnies[s].BumpAsset     = "Textures/WindmillTopNormal";
                bunnies[s].LightPosition = LightPosition;
                Components.Add(bunnies[s]);
            }

            landShark          = new Base3DObject(this, "Models/landShark");
            landShark.Position = new Vector3(-20, 0, -10);

            landShark.ColorAsset    = "Textures/Speeder_diff";
            landShark.BumpAsset     = "Textures/Speeder_bump";
            landShark.LightPosition = LightPosition;
            Components.Add(landShark);

            earth               = new Base3DObject(this, "Models/sphere");
            earth.Position      = new Vector3(0, 0, -200);
            earth.ColorAsset    = "Textures/Earth_Diffuse";
            earth.BumpAsset     = "Textures/Earth_NormalMap";
            earth.LightPosition = LightPosition;
            Components.Add(earth);

            ppManager = new PostProcessingManager(this);

            fog         = new FogEffect(this, 50, 100, Color.DarkSlateGray);
            fog.Enabled = false;
            ppManager.AddEffect(fog);

            GodRays         = new CrepuscularRays(this, LightPosition, "Textures/flare", 1500, .99f, .99f, .5f, .12f, .25f);
            GodRays.Enabled = false;
            ppManager.AddEffect(GodRays);

            sun         = new SunEffect(this, LightPosition);
            sun.Enabled = false;
            ppManager.AddEffect(sun);

            bloom         = new BloomEffect(this, 1.25f, 1f, 1f, 1f, .25f, 4f);
            bloom.Enabled = false;
            ppManager.AddEffect(bloom);

            dof         = new DepthOfFieldEffect(this, 5, 30);
            dof.Enabled = false;
            ppManager.AddEffect(dof);

            haze         = new HeatHazeEffect(this, "Textures/bumpmap", false);
            haze.Enabled = false;
            ppManager.AddEffect(haze);

            radialBlur         = new RadialBlurEffect(this, 0.009f);
            radialBlur.Enabled = false;
            ppManager.AddEffect(radialBlur);

            ripple         = new RippleEffect(this);
            ripple.Enabled = false;
            ppManager.AddEffect(ripple);

            sepia         = new SepiaEffect(this);
            sepia.Enabled = false;
            ppManager.AddEffect(sepia);

            greyScale         = new GreyScaleEffect(this);
            greyScale.Enabled = false;
            ppManager.AddEffect(greyScale);

            invert         = new InvertColorEffect(this);
            invert.Enabled = false;
            ppManager.AddEffect(invert);

            colorFilter         = new ColorFilterEffect(this, Color.White, .5f, .5f, .5f);
            colorFilter.Enabled = false;
            ppManager.AddEffect(colorFilter);

            bleach         = new BleachEffect(this, 1);
            bleach.Enabled = false;
            ppManager.AddEffect(bleach);

            scanLines         = new ScanLinesEffect(this, .001f, .001f, 128);
            scanLines.Enabled = false;
            ppManager.AddEffect(scanLines);

            deRezed         = new DeRezedEffect(this, 128);
            deRezed.Enabled = false;
            ppManager.AddEffect(deRezed);
        }