extract frustum corners

Started by
1 comment, last by smurfkiller 15 years, 10 months ago
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:

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);
}


This calculation does not give the correct frustum corners in world coordinates.
Crush your enemies, see them driven before you, and hear the lamentations of their women!
Advertisement
Assuming you're following OpenGL's notational conventions (e.g. using column vectors), you might try:
mat4 mvp = proj * modv;
Quote:Original post by jyk
Assuming you're following OpenGL's notational conventions (e.g. using column vectors), you might try:
mat4 mvp = proj * modv;


Did that (thanks). It looks better but still something is not entirely correct.
Crush your enemies, see them driven before you, and hear the lamentations of their women!

This topic is closed to new replies.

Advertisement