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 void SetLightParams(int idx, LightModel light) { Lights[idx] = light; }