Jump to content
  • Advertisement
Sign in to follow this  
smurfkiller

extract frustum corners

This topic is 3816 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
Assuming you're following OpenGL's notational conventions (e.g. using column vectors), you might try:
mat4 mvp = proj * modv;

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!