private void setupScene() { // Create our objects TexturedCube tc = new TexturedCube(); tc.TextureID = textures[materials["opentk1"].DiffuseMap]; tc.CalculateNormals(); tc.Material = materials["opentk1"]; objects.Add(tc); TexturedCube tc2 = new TexturedCube(); tc2.Position += new Vector3(1f, 1f, 1f); tc2.TextureID = textures[materials["opentk2"].DiffuseMap]; tc2.CalculateNormals(); tc2.Material = materials["opentk2"]; objects.Add(tc2); ObjVolume earth = ObjVolume.LoadFromFile("earth.obj"); earth.TextureID = textures["earth.png"]; earth.Position += new Vector3(1f, 1f, -2f); earth.Material = new Material(new Vector3(0.15f), new Vector3(1), new Vector3(0.2f), 5); objects.Add(earth); // Create lights lights.Add(new Light(new Vector3(), new Vector3(0.4f, 0.4f, 0.4f))); lights.Add(new Light(new Vector3(5, 0, 0), new Vector3(0.9f, 0.1f, 0.1f))); lights.Add(new Light(new Vector3(-5, 0, 0), new Vector3(0.1f, 0.9f, 0.1f))); lights.Add(new Light(new Vector3(0, 5, 0), new Vector3(0.1f, 0.1f, 0.9f))); // Move camera away from origin cam.Position += new Vector3(0f, 0f, 3f); }
private void setupScene() { // Create our objects TexturedCube tc = new TexturedCube(); tc.TextureID = textures[materials["opentk1"].DiffuseMap]; tc.CalculateNormals(); tc.Material = materials["opentk1"]; objects.Add(tc); TexturedCube tc2 = new TexturedCube(); tc2.Position += new Vector3(1f, 1f, 1f); tc2.TextureID = textures[materials["opentk2"].DiffuseMap]; tc2.CalculateNormals(); tc2.Material = materials["opentk2"]; objects.Add(tc2); ObjVolume earth = ObjVolume.LoadFromFile("earth.obj"); earth.TextureID = textures["earth.png"]; earth.Position += new Vector3(1f, 1f, -2f); earth.Material = new Material(new Vector3(0.15f), new Vector3(1), new Vector3(0.2f), 5); objects.Add(earth); TexturedCube floor = new TexturedCube(); floor.TextureID = textures[materials["opentk1"].DiffuseMap]; floor.Scale = new Vector3(20, 0.1f, 20); floor.Position += new Vector3(0, -2, 0); floor.CalculateNormals(); floor.Material = materials["opentk1"]; objects.Add(floor); TexturedCube backWall = new TexturedCube(); backWall.TextureID = textures[materials["opentk1"].DiffuseMap]; backWall.Scale = new Vector3(20, 20, 0.1f); backWall.Position += new Vector3(0, 8, -10); backWall.CalculateNormals(); backWall.Material = materials["opentk1"]; objects.Add(backWall); // Create lights Light sunLight = new Light(new Vector3(), new Vector3(0.7f, 0.7f, 0.7f)); sunLight.Type = LightType.Directional; sunLight.Direction = (sunLight.Position - floor.Position).Normalized(); lights.Add(sunLight); Light spotLight = new Light(new Vector3(2, 7, 0), new Vector3(0.7f, 0.2f, 0.2f)); spotLight.Type = LightType.Spot; spotLight.Direction = (spotLight.Position - earth.Position).Normalized(); spotLight.ConeAngle = 35.0f; lights.Add(spotLight); Light spotLight2 = new Light(new Vector3(2, 0, 3), new Vector3(0.2f, 0.6f, 0.25f)); spotLight2.Type = LightType.Spot; spotLight2.Direction = (spotLight2.Position - earth.Position).Normalized(); spotLight2.ConeAngle = 15; lights.Add(spotLight2); Light spotLight3 = new Light(new Vector3(6, 4, 0), new Vector3(0.2f, 0.25f, 0.6f)); spotLight3.Type = LightType.Spot; spotLight3.Direction = (spotLight3.Position - earth.Position).Normalized(); spotLight3.ConeAngle = 30; lights.Add(spotLight3); // Move camera away from origin cam.Position += new Vector3(0f, 1f, 3f); }