void CQuadMT::Update(float dt) { if( m_bMVUpdated ) { // Model View 的相關矩陣內容有更動 m_mxMVFinal = m_mxView * m_mxTRS; m_mxITMV = InverseTransposeMatrix(m_mxMVFinal); } }
void CWireSphere::Update(float dt, const structLightSource &LightSource) { #ifdef LIGHTING_WITHCPU if( m_bMVUpdated ) { // Model View 的相關矩陣內容有更動 m_mxMVFinal = m_mxModelView * m_mxTRS; m_mxMV3X3Final = mat3( m_mxMVFinal._m[0].x, m_mxMVFinal._m[1].x, m_mxMVFinal._m[2].x, m_mxMVFinal._m[0].y, m_mxMVFinal._m[1].y, m_mxMVFinal._m[2].y, m_mxMVFinal._m[0].z, m_mxMVFinal._m[1].z, m_mxMVFinal._m[2].z); #ifdef GENERAL_CASE m_mxITMV = InverseTransposeMatrix(m_mxMVFinal); #endif m_bMVUpdated = false; } if( m_iMode == FLAT_SHADING ) RenderWithGouraudShading(LightSource.position, LightSource.diffuse); else RenderWithGouraudShading(LightSource.position, LightSource.diffuse); #else // Lighting With GPU if( m_bMVUpdated ) { m_mxMVFinal = m_mxModelView * m_mxTRS; m_bMVUpdated = false; } m_vLightInView = m_mxModelView * LightSource.position; // 將 Light 轉換到鏡頭座標再傳入 // 算出 AmbientProduct DiffuseProduct 與 SpecularProduct 的內容 m_AmbientProduct = m_Material.ka * m_Material.ambient * LightSource.ambient; m_DiffuseProduct = m_Material.kd * m_Material.diffuse * LightSource.diffuse; m_SpecularProduct = m_Material.ks * m_Material.specular * LightSource.specular; #endif }
void CQuad::Update(float dt, const LightSource &lights) { #ifdef LIGHTING_WITHCPU if( m_bViewUpdated || m_bTRSUpdated ) { // Model View 的相關矩陣內容有更動 m_mxMVFinal = m_mxView * m_mxTRS; m_mxMV3X3Final = mat3( m_mxMVFinal._m[0].x, m_mxMVFinal._m[1].x, m_mxMVFinal._m[2].x, m_mxMVFinal._m[0].y, m_mxMVFinal._m[1].y, m_mxMVFinal._m[2].y, m_mxMVFinal._m[0].z, m_mxMVFinal._m[1].z, m_mxMVFinal._m[2].z); #ifdef GENERAL_CASE m_mxITMV = InverseTransposeMatrix(m_mxMVFinal); #endif m_bViewUpdated = m_bTRSUpdated = false; } if (m_iMode == FLAT_SHADING) RenderWithFlatShading(lights); else RenderWithGouraudShading(lights); #else // Lighting With GPU if (m_bViewUpdated || m_bTRSUpdated) { m_mxMVFinal = m_mxView * m_mxTRS; m_bViewUpdated = m_bTRSUpdated = false; } m_vLightInView = m_mxView * lights.position; // 將 Light 轉換到鏡頭座標再傳入 // 算出 AmbientProduct DiffuseProduct 與 SpecularProduct 的內容 m_AmbientProduct = m_Material.ka * m_Material.ambient * lights.ambient; m_AmbientProduct.w = m_Material.ambient.w; m_DiffuseProduct = m_Material.kd * m_Material.diffuse * lights.diffuse; m_DiffuseProduct.w = m_Material.diffuse.w; m_SpecularProduct = m_Material.ks * m_Material.specular * lights.specular; m_SpecularProduct.w = m_Material.specular.w; #endif }
void CQuad::Update(float dt) { if (m_bViewUpdated || m_bTRSUpdated) { // Model View 的相關矩陣內容有更動 m_mxMVFinal = m_mxView * m_mxTRS; m_mxITMV = InverseTransposeMatrix(m_mxMVFinal); m_bViewUpdated = m_bTRSUpdated = false; } }