void initProgram() { lastMousePos = new Vector2(Mouse.X, Mouse.Y); CursorVisible = false; GL.GenBuffers(1, out ibo_elements); // Load shaders from file shaders.Add("default", new ShaderProgram("vs.glsl", "fs.glsl", true)); shaders.Add("textured", new ShaderProgram("vs_tex.glsl", "fs_tex.glsl", true)); shaders.Add("normal", new ShaderProgram("vs_norm.glsl", "fs_norm.glsl", true)); shaders.Add("lit", new ShaderProgram("vs_lit.glsl", "fs_lit.glsl", true)); activeShader = "lit"; loadMaterials("opentk.mtl"); // 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); // Move camera away from origin cam.Position += new Vector3(0f, 0f, 3f); cam.MouseSensitivity = 0.0025f; textures.Add("earth.png", loadImage("earth.png")); 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); }
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); loadMaterials("Paris2010_0.mtl"); ObjVolume ea = ObjVolume.LoadFromFile("Paris2010_0.obj"); ea.TextureID = textures["earth.png"]; ea.Position += new Vector3(1f, 1f, -2f); ea.Material = new Material(new Vector3(0.15f), new Vector3(1), new Vector3(0.2f), 5); objects.Add(ea); // Create lights // Light sunLight = new Light(new Vector3(), new Vector3(0.7f, 0.7f, 0.7f)); // sunLight.Type = LightType.Directional; //// sunLight.QuadraticAttenuation = 0.15f; // sunLight.Direction = (sunLight.Position - floor.Position).Normalized(); // lights.Add(sunLight); //Light pointLight = new Light(new Vector3(2, 7, 0), new Vector3(1.5f, 0.2f, 0.2f)); //pointLight.QuadraticAttenuation = 0.05f; //lights.Add(pointLight); Light pointLight2 = new Light(new Vector3(2, 0, 3), new Vector3(1f, 1f, 1f)); pointLight2.QuadraticAttenuation = 0.05f; lights.Add(pointLight2); //Light pointLight3 = new Light(new Vector3(6, 4, 0), new Vector3(0.2f, 0.25f, 1.5f)); //pointLight3.QuadraticAttenuation = 0.05f; //lights.Add(pointLight3); // Move camera away from origin cam.Position += new Vector3(0f, 1f, 3f); }