void frustum::calc_points(const mat4 &modv, const mat4 &proj) {
mat4 mvp = modv * proj;
mat4 imvp = inverse(mvp);
_points[0] = transform_point(imvp, vec3( 1.0f, 1.0f, -1.0f);
_points[1] = transform_point(imvp, vec3(-1.0f, 1.0f, -1.0f);
_points[2] = transform_point(imvp, vec3( 1.0f, -1.0f, -1.0f);
_points[3] = transform_point(imvp, vec3(-1.0f, -1.0f, -1.0f);
_points[4] = transform_point(imvp, vec3( 1.0f, 1.0f, 1.0f);
_points[5] = transform_point(imvp, vec3(-1.0f, 1.0f, 1.0f);
_points[6] = transform_point(imvp, vec3( 1.0f, -1.0f, 1.0f);
_points[7] = transform_point(imvp, vec3(-1.0f, -1.0f, 1.0f);
}
extract frustum corners
Hello.
I have some problems extracting the corners of a frustum. The frustum is given by a 'modelview' and a 'projection' matrix. The points are calculated as:
This calculation does not give the correct frustum corners in world coordinates.
Assuming you're following OpenGL's notational conventions (e.g. using column vectors), you might try:
mat4 mvp = proj * modv;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement