void DrawLookAtPoint(glutil::MatrixStack &modelMatrix) { glDisable(GL_DEPTH_TEST); glutil::PushStack push(modelMatrix); modelMatrix.SetIdentity(); modelMatrix.Translate(glm::vec3(0.0f, 0.0f, -g_viewPole.GetView().radius)); glUseProgram(UniformColor.theProgram); glUniformMatrix4fv(UniformColor.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); g_pCylinderMesh->Render(); glUseProgram(0); glEnable(GL_DEPTH_TEST); }
void DrawRoad(glutil::MatrixStack &modelMatrix) { glutil::PushStack push(modelMatrix); glDisable(GL_DEPTH_TEST); glm::mat4 worldToCamera = modelMatrix.Top(); modelMatrix.SetIdentity(); modelMatrix.Scale(glm::vec3(30.0f, 1.0f, 100.0f)); modelMatrix.Translate(0.0f, 0.0f, -0.5f); glUseProgram(UniformColorAndLightProgram.theProgram); glUniformMatrix4fv(UniformColorAndLightProgram.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniform3f(UniformColorAndLightProgram.ka, 0.3f, 0.3f, 0.3f); glUniform1f(UniformColorAndLightProgram.spotLight.cutoffUnif, 73.0); glUniform1f(UniformColorAndLightProgram.spotLight.exponentUnif, 3.0); glUniform3fv(UniformColorAndLightProgram.spotLight.directionUnif, 1, glm::value_ptr(car->reflectorDirection())); glUniform3fv(UniformColorAndLightProgram.spotLight.intensityUnif, 1, glm::value_ptr(glm::vec3(1.0, 1.0, 1.0))); SendReflectorPosition(UniformColorAndLightProgram.spotLight.positionLeftReflectorUnif, -0.2f, 0.2f, 0.5f); SendReflectorPosition(UniformColorAndLightProgram.spotLight.positionRightReflectorUnif, 0.2f, 0.2f, 0.5f); glUniformMatrix4fv(UniformColorAndLightProgram.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniformMatrix4fv(UniformColorAndLightProgram.worldToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(worldToCamera)); glUniformMatrix4fv(UniformColorAndLightProgram.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniform4f(UniformColorAndLightProgram.baseColorUnif, 0.72f, 0.71f, 0.35f, 1.0f); glUniform4fv(UniformColorAndLightProgram.lightIntensityUnif, 1, glm::value_ptr(glm::vec4(0.3f, 0.3f, 0.3f, 1.0f))); glm::vec3 worldLightPos(CalcLightPosition()); glUniform3fv(UniformColorAndLightProgram.worldSpaceLightPosUnif, 1, glm::value_ptr(worldLightPos)); g_pPlaneMesh->Render(); glUseProgram(0); glEnable(GL_DEPTH_TEST); }
void DrawTetrahedron(glutil::MatrixStack &modelMatrix) { glutil::PushStack push(modelMatrix); g_TetrahedronTimer.Update(); glm::mat4 worldToCamera = modelMatrix.Top(); modelMatrix.SetIdentity(); modelMatrix.Translate(40.0f, 2.0f, 75.0f); modelMatrix.RotateY(360.0f * g_TetrahedronTimer.GetAlpha()); modelMatrix.Translate(1.0f, 1.0f + sqrtf(2.0f) * 10, 1.0f); modelMatrix.Scale(10); modelMatrix.Rotate(glm::vec3(-0.707f, 0.0f, -0.707f), 54.735f); glUseProgram(ReflectorsAndLightProgram.reflectorsProgramData.theProgram); glUniform1f(ReflectorsAndLightProgram.reflectorsProgramData.shininess, 2.3f); glUniform3f(ReflectorsAndLightProgram.reflectorsProgramData.ks, 0.5f, 0.5f, 0.5f); glUniform3f(ReflectorsAndLightProgram.reflectorsProgramData.ka, 0.2f, 0.2f, 0.2f); glUniform3f(ReflectorsAndLightProgram.reflectorsProgramData.kd, 0.3f, 0.3f, 0.3f); glUniform1f(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.cutoffUnif, 73.0f); glUniform1f(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.exponentUnif, 3.0f); glUniform3fv(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.directionUnif, 1, glm::value_ptr(car->reflectorDirection())); glUniform3fv(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.intensityUnif, 1, glm::value_ptr(glm::vec3(0.8f, 0.8f, 0.8f))); SendReflectorPosition(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.positionLeftReflectorUnif, -0.2f, 0.2f, -0.5f); SendReflectorPosition(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.positionRightReflectorUnif, 0.2f, 0.2f, -0.5f); glUniformMatrix4fv(ReflectorsAndLightProgram.reflectorsProgramData.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniformMatrix4fv(ReflectorsAndLightProgram.reflectorsProgramData.worldToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(worldToCamera)); glUniform4fv(ReflectorsAndLightProgram.lightIntensityUnif, 1, glm::value_ptr(glm::vec4(0.7f, 0.7f, 0.7f, 1.0f))); glm::vec3 worldLightPos(CalcLightPosition()); glUniform3fv(ReflectorsAndLightProgram.worldSpaceLightPosUnif, 1, glm::value_ptr(worldLightPos)); g_pTetrahedronMesh->Render(); glUseProgram(0); }
void DrawShip(glutil::MatrixStack &modelMatrix) { glutil::PushStack push(modelMatrix); glm::mat4 worldToCamera = modelMatrix.Top(); modelMatrix.SetIdentity(); modelMatrix.Translate(glm::vec3(0.0f, 2.0f, 50.0f)); modelMatrix.Scale(3); modelMatrix.Rotate(glm::vec3(0, 1.0f, 0), -34); modelMatrix.Rotate(glm::vec3(0.5, 0.0, 0.5), 10); glUseProgram(ReflectorsAndLightProgram.reflectorsProgramData.theProgram); glUniform1f(ReflectorsAndLightProgram.reflectorsProgramData.shininess, 2.3f); glUniform3f(ReflectorsAndLightProgram.reflectorsProgramData.ks, 0.5f, 0.5f, 0.5f); glUniform3f(ReflectorsAndLightProgram.reflectorsProgramData.ka, 0.3f, 0.3f, 0.3f); glUniform3f(ReflectorsAndLightProgram.reflectorsProgramData.kd, 0.3f, 0.3f, 0.3f); glUniform1f(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.cutoffUnif, 73.0); glUniform1f(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.exponentUnif, 3.0); glUniform3fv(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.directionUnif, 1, glm::value_ptr(car->reflectorDirection())); glUniform3fv(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.intensityUnif, 1, glm::value_ptr(glm::vec3(0.8, 0.8, 0.8))); SendReflectorPosition(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.positionLeftReflectorUnif, -0.2f, 0.2f, 0.5f); SendReflectorPosition(ReflectorsAndLightProgram.reflectorsProgramData.spotLight.positionRightReflectorUnif, 0.2f, 0.2f, 0.5f); glUniformMatrix4fv(ReflectorsAndLightProgram.reflectorsProgramData.modelToWorldMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelMatrix.Top())); glUniformMatrix4fv(ReflectorsAndLightProgram.reflectorsProgramData.worldToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(worldToCamera)); glm::vec3 worldLightPos(CalcLightPosition()); glUniform3fv(ReflectorsAndLightProgram.worldSpaceLightPosUnif, 1, glm::value_ptr(worldLightPos)); g_pShip->Render(); glUseProgram(0); }