void onFrameMove(float delta) { if( g_bAutoRotating ) { // Part 2 : 重新計算 Light 的位置 UpdateLightPosition(delta); } // 如果需要重新計算時,在這邊計算每一個物件的顏色 g_pFloor->Update(delta, g_Light1); g_pCube->Update(delta, g_Light1); g_pSphere->Update(delta, g_Light1); g_pLight->Update(delta); GL_Display(); }
void Shader::Update(Transform *transform, Camera *camera, Material* mat) { glm::mat4 M = transform->GetModel(); glm::mat4 V = camera->getView(); glm::mat4 P = camera->getProjection(); glm::mat4 Normal = transform->getNormalMat(camera); glm::vec4 d = mat->getDiffuse(); glm::vec4 a = mat->getAmbient(); glm::vec4 s = mat->getSpecular(); glm::vec4 e = mat->getEmissive(); float shiny = mat->getShininess(); UpdateMVP(M, V, P); UpdateMaterial(d, a, s, e, shiny); UpdateNormalMat(Normal); UpdateLightPosition(m_lightPosition); UpdateLightDirection(m_lightDirection); }
void Shader::UpdateLight(Light* light){ UpdateLightPosition(light->GetPosition()); UpdateLightColor(light->GetColor()); }