/** * Sets this to a perspective projection matrix. The formula comes from the OpenGL * documentation for the gluPerspective function. * * @return a reference to this matrix, for chaining. */ public Matrix4 setToPerspective (float fovy, float aspect, float near, float far) { float f = 1f / FloatMath.tan(fovy / 2f), dscale = 1f / (near - far); return set(f/aspect, 0f, 0f, 0f, 0f, f, 0f, 0f, 0f, 0f, (far+near) * dscale, 2f * far * near * dscale, 0f, 0f, -1f, 0f); }
/** * Sets this to a perspective projection matrix. The formula comes from the OpenGL * documentation for the gluPerspective function. * * @return a reference to this matrix, for chaining. */ public Matrix4 setToPerspective (float fovy, float aspect, float near, float far) { float f = 1f / FloatMath.tan(fovy / 2f), dscale = 1f / (near - far); return set(f/aspect, 0f, 0f, 0f, 0f, f, 0f, 0f, 0f, 0f, (far+near) * dscale, 2f * far * near * dscale, 0f, 0f, -1f, 0f); }
/** * Sets this frustum to one pointing in the Z- direction with the specified parameters * determining its size and shape (see the OpenGL documentation for * <code>gluPerspective</code>). * * @param fovy the vertical field of view, in radians. * @param aspect the aspect ratio (width over height). * @param znear the distance to the near clip plane. * @param zfar the distance to the far clip plane. * @return a reference to this frustum, for chaining. */ public Frustum setToPerspective (float fovy, float aspect, float znear, float zfar) { float top = znear * FloatMath.tan(fovy / 2f), bottom = -top; float right = top * aspect, left = -right; return setToFrustum(left, right, bottom, top, znear, zfar); }
/** * Sets this frustum to one pointing in the Z- direction with the specified parameters * determining its size and shape (see the OpenGL documentation for * <code>gluPerspective</code>). * * @param fovy the vertical field of view, in radians. * @param aspect the aspect ratio (width over height). * @param znear the distance to the near clip plane. * @param zfar the distance to the far clip plane. * @return a reference to this frustum, for chaining. */ public Frustum setToPerspective (float fovy, float aspect, float znear, float zfar) { float top = znear * FloatMath.tan(fovy / 2f), bottom = -top; float right = top * aspect, left = -right; return setToFrustum(left, right, bottom, top, znear, zfar); }