void initScene() { mNormalMapShader = new Shader("shader/universalShader.vert", "shader/universalShader.frag"); Material *mat; objLoader.loadObjFile("./meshes/sphere.obj", "sun", 2.0f); mat = new Material(); mat->setShaderProgram(mNormalMapShader); mat->setEmissiveTexture("textures/sun.jpg"); objLoader.getMeshObj("sun")->setMaterial(mat); objLoader.loadObjFile("./meshes/sphere.obj", "mars", 0.5f); mat = new Material(); mat->setShaderProgram(mNormalMapShader); mat->setDiffuseTexture("textures/mars.png"); mat->setNormalTexture("textures/mars_normal.png"); mat->setAmbientColor(0.15, 0.15, 0.15); objLoader.getMeshObj("mars")->setMaterial(mat); objLoader.loadObjFile("./meshes/sphere.obj", "moon", 0.2f); mat = new Material(); mat->setShaderProgram(mNormalMapShader); mat->setDiffuseTexture("textures/moon.png"); mat->setNormalTexture("textures/moon_normal.png"); mat->setAmbientColor(0.15, 0.15, 0.15); objLoader.getMeshObj("moon")->setMaterial(mat); // TODO: init you additional shaders here (you might want to use simple.vert as vertex shader) // }
void initScene() { // load scene.obj from disk and create renderable MeshObj // objLoader.loadObjFile("../meshes/scene.obj", "scene"); // import data from bunny.h and create VAO // if (bunnyVAO == 0) { glGenVertexArrays(1, &bunnyVAO); } glBindVertexArray(bunnyVAO); glGenBuffers(2, bunnyVBOs); glBindBuffer(GL_ARRAY_BUFFER, bunnyVBOs[0]); glBufferData(GL_ARRAY_BUFFER, 3 * NUM_POINTS * sizeof(GLfloat), &bunny[0], GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, bunnyVBOs[1]); glBufferData(GL_ARRAY_BUFFER, 3 * NUM_POINTS * sizeof(GLfloat), &normals[0], GL_STATIC_DRAW); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(1); // init and bind a IBO (index buffer object) // if (bunnyIBO == 0) { glGenBuffers(1, &bunnyIBO); } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bunnyIBO); // copy data into the IBO // glBufferData(GL_ELEMENT_ARRAY_BUFFER, 3 * NUM_TRIANGLES * sizeof(GLint), triangles, GL_STATIC_DRAW); // unbind buffers // glBindVertexArray(0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0); }
void initScene() { // load scene.obj from disk and create renderable MeshObj // // you may switch between the following mesh files // // - make sure to use the correct texture file for each mesh object // objLoader.loadObjFile("../meshes/trashbin.obj", "sceneObject"); //objLoader.loadObjFile("../meshes/ball.obj", "sceneObject"); // init materials // Material mat; mat.ambient_color = glm::vec3(1.0, 1.0, 1.0); mat.diffuse_color = glm::vec3(1.0, 1.0, 1.0); mat.specular_color = glm::vec3(1.0, 1.0, 1.0); mat.specular_shininess = 50.0; materials.push_back(mat); mat.specular_shininess = 100.0; materials.push_back(mat); mat.ambient_color = glm::vec3(1.0, 0.9, 0.8); mat.diffuse_color = glm::vec3(1.0, 0.9, 0.8); mat.specular_shininess = 50.0; materials.push_back(mat); // save material count for later and select first material // materialCount = materials.size(); materialIndex = 0; // init lights // LightSource light; light.ambient_color = glm::vec3(0.001, 0.001, 0.001); light.diffuse_color = glm::vec3(1.0, 1.0, 1.0); light.specular_color = glm::vec3(1.0, 1.0, 1.0); light.position = glm::vec3(15, 15, 15); lights.push_back(light); light.position = glm::vec3(-15, 15, 15); lights.push_back(light); light.position = glm::vec3(15, 15, -15); lights.push_back(light); light.position = glm::vec3(-15, 15, -15); lights.push_back(light); // save light source count for later and select first light source // lightCount = lights.size(); }
void initScene() { camera.setFar(1000.0f); // load scene.obj from disk and create renderable MeshObj // objLoader.loadObjFile("../meshes/testbox.obj", "sceneObject"); // init materials // Material mat; mat.ambient_color = glm::vec3(1.0, 1.0, 1.0); mat.diffuse_color = glm::vec3(0.8, 1.0, 0.5); mat.specular_color = glm::vec3(1.0, 1.0, 1.0); mat.specular_shininess = 5.0; materials.push_back(mat); // save material count for later and select first material // materialCount = materials.size(); materialIndex = 0; // init light // light.ambient_color = glm::vec3(0.05, 0.05, 0.05); light.diffuse_color = glm::vec3(1.0, 1.0, 1.0); light.specular_color = glm::vec3(1.0, 1.0, 1.0); light.position = initialLightPos; }
void initScene() { // load scene.obj from disk and create renderable MeshObj // objLoader.loadObjFile("../meshes/bunny.obj", "bunny"); // init materials // // TODO: initialize your materials here // // - create a new Material and insert it into the 'materials' vector // - set material properties for ambient, diffuse and specular color as glm::vec3 // - set shininess exponent as float Material mat1; Material mat2; Material mat3; Material mat4; mat1.ambient_color = glm::vec3(1, 0, 0); mat1.diffuse_color = glm::vec3(1, 0, 0); mat1.specular_color = glm::vec3(1, 1, 1); mat1.specular_shininess = 15.0f; mat2.ambient_color = glm::vec3(0, 1, 0); mat2.diffuse_color = glm::vec3(0, 1, 0); mat2.specular_color = glm::vec3(1, 1, 1); mat2.specular_shininess = 25.0f; mat3.ambient_color = glm::vec3(0, 0, 1); mat3.diffuse_color = glm::vec3(0, 0, 1); mat3.specular_color = glm::vec3(1, 1, 1); mat3.specular_shininess = 75.0f; mat4.ambient_color = glm::vec3(1, 1, 0); mat4.diffuse_color = glm::vec3(1, 1, 0); mat4.specular_color = glm::vec3(1, 1, 1); mat4.specular_shininess = 5.0f; materials.push_back(mat1); materials.push_back(mat2); materials.push_back(mat3); materials.push_back(mat4); // save material count for later and select first material // materialCount = materials.size(); materialIndex = 0; // init lights // // TODO: initialize your light sources here // // - set the color properties of the light source as glm::vec3 // - set the lights position as glm::vec3 LightSource l1; LightSource l2; l1.ambient_color = glm::vec3(0.1f, 0.1f, 0.1f); l1.diffuse_color = glm::vec3(1, 1, 1); l1.specular_color = glm::vec3(1, 1, 1); l1.position = glm::vec3(4, 4, 4); l2.ambient_color = glm::vec3(0.0f, 0.0f, 0.1f); l2.diffuse_color = glm::vec3(0, 0, 1); l2.specular_color = glm::vec3(0, 0, 1); l2.position = glm::vec3(0, 2, 0); lights.push_back(l1); lights.push_back(l2); // save light source count for later and select first light source // lightCount = lights.size(); lightIndex = 0; }