std::vector<glm::vec3> trapezoid(4);
for(unsigned int i=0;i<numCascades;i++)
{
Frustum &frustum = m_frustums[i]; // The cascade frustum
glm::vec3 &ftr = frustum.points[FRUSTUM_POINT::FAR_TOP_RIGHT];
glm::vec3 &fbl = frustum.points[FRUSTUM_POINT::FAR_BOTTOM_LEFT];
glm::vec3 &nbl = frustum.points[FRUSTUM_POINT::NEAR_BOTTOM_LEFT];
glm::vec3 &ntr = frustum.points[FRUSTUM_POINT::NEAR_TOP_RIGHT];
trapezoid[0] = ftr;
trapezoid[1] = fbl;
trapezoid[2] = nbl;
trapezoid[3] = ntr;
glm::vec3 center;
float radius;
Seb::Calculate(trapezoid,center,radius); // Generates the MEC from the frustum's trapezoid
glm::mat4 matView = Matrix::LookAt(center -dir,center,glm::vec3(0,1,0)); // 'dir' is the light direction; 'center' the center of the MEC (Parameters are the same as for glm::lookAt)
float diameter = radius *2.f;
m_frustums[i].projection = glm::ortho(0.f,diameter,diameter,0.f,0.f,1000.f); // width and height = diameter of the MEC, near and far plane are arbitrary values for now
m_frustums[i].viewProjection = m_frustums[i].projection *matView;
}
[...]