void Frustum::InitFromGLState() { glGetDoublev(GL_PROJECTION_MATRIX, m_projMatrix.Data()); glGetDoublev(GL_MODELVIEW_MATRIX, m_modelMatrix.Data()); matrix4x4d m = matrix4x4d(m_projMatrix) * matrix4x4d(m_modelMatrix); InitFromMatrix(m); }
Frustum::Frustum(float width, float height, float fovAng) { float fov = tan(DEG2RAD(Clamp(fovAng, FOV_MIN, FOV_MAX) / 2.0f)); float znear, zfar; GetNearFarClipPlane(znear, zfar); float left = fov * znear; float top = left * height/width; m_projMatrix = matrix4x4d::FrustumMatrix(-left, left, -top, top, znear, zfar); m_modelMatrix = matrix4x4d::Identity(); InitFromMatrix(m_projMatrix); }
Frustum::Frustum(float width, float height, float fovAng, float znear, float zfar) { //http://www.opengl.org/resources/faq/technical/transformations.htm const float fov = tan(DEG2RAD(Clamp(fovAng, FOV_MIN, FOV_MAX) / 2.0f)); const float aspect = width/height; const float top = znear * fov; const float bottom = -top; const float left = bottom * aspect; const float right = top * aspect; m_projMatrix = matrix4x4d::FrustumMatrix(left, right, bottom, top, znear, zfar); m_modelMatrix = matrix4x4d::Identity(); InitFromMatrix(m_projMatrix); }