Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / best way to get frustrum planes to world space? Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

February 21, 2005, 03:34 AM

my origonal idea on this was to extract the frustrum planes from the projection matrix, then transform each plane.

but im wondering if i can simply multiply my projeciton matrix with my camera view matrix then do plane extraction to get my planes in world space?


February 21, 2005, 04:08 AM

yes you can definitely do that and it works too.



February 21, 2005, 05:55 AM

i think i need some sort of offset matrix to move the frustum fowards along the view vector otherwise the near plane seems to end up at the cameras position, not at the cameras real near plane :-/


February 21, 2005, 07:06 AM

your plane extraction might be broken..check against the code in this pdf to see what's wrong

quite much explains what you are trying to do in good detail



February 22, 2005, 03:36 AM

i use that pdf to write my plane extraction, so i double checked and its all correct.

i wonder if its in my camera code thats the problem:

  2. void Camera::Transform()
  3. {
  4.         // set the camera view matrix
  5.         transform[ 0] = right[Vector3::X];
  6.         transform[ 4] = right[Vector3::Y];
  7.         transform[ 8] = right[Vector3::Z];
  9.         transform[ 1] = up[Vector3::X];
  10.         transform[ 5] = up[Vector3::Y];
  11.         transform[ 9] = up[Vector3::Z];
  13.         transform[ 2] = view[Vector3::X];
  14.         transform[ 6] = view[Vector3::Y];
  15.         transform[10] = view[Vector3::Z];
  17.         transform[12] = -position.Dot(right);
  18.         transform[13] = -position.Dot(up);
  19.         transform[14] = -position.Dot(view);
  21.         //set world matrix also
  22.         world[ 0] = -right[Vector3::X];
  23.         world[ 1] = -right[Vector3::Y];
  24.         world[ 2] = -right[Vector3::Z];
  26.         world[ 4] = -up[Vector3::X];
  27.         world[ 5] = -up[Vector3::Y];
  28.         world[ 6] = -up[Vector3::Z];
  30.         world[ 8] = -view[Vector3::X];
  31.         world[ 9] = -view[Vector3::Y];
  32.         world[10] = -view[Vector3::Z];
  33.         world.Translate( position[Vector3::X], position[Vector3::Y], position[Vector3::Z] );
  35.         UpdateFrustrum();
  36. }
  38. Matrix4& Camera::GetTransform()
  39. {
  40.         return transform;
  41. }
  43. void Camera::UpdateFrustrum()
  44. {      
  45.         // get frustrum in to world space
  46.         Matrix4 matViewProjection = GetTransform();
  48.         Matrix4 projViewMatrix = matViewProjection * projection;
  49.         frustum.SetUpFromProjection(projViewMatrix); // does plane extraction
  50. }

it seems as if when i move left the frustrum moves right, i move right the frstrum moves left. I look up, the frustrum looks down in a funkey sort of way.

so i tried using the world matrix, and it gives different results. also tried the transpose of them all but no luck either :-/


February 22, 2005, 03:47 AM

Remember that there is a slight difference between D3D and OpenGL with regards to the homogenous space. D3D uses a z' range of 0..1, OpenGL uses -1..1. Make sure you use the correct extraction method.


February 22, 2005, 04:17 AM

yep i'm sure plane extraction is all good. set up exactly like the doco for opengl

Rui Martins

February 22, 2005, 05:37 AM

Are you setting the Camera on the correct Matrix (Modelview)?


February 23, 2005, 02:50 AM

rui, eh? not sure what ya mean?

Rui Martins

February 23, 2005, 06:11 AM

I assumed you are using OpenGL, so pardon my lingo if you are not.

In OpenGL at least, when you move the camera, you don't need to update your frustrum, since the frustum is defined using the ProjectionMatrix, and the Camera should be setup using the ModelViewMatrix.

This is why your "UpdateFrustum" Camera method seems wrong to me, since a camera shouldn't mess with the frustrum, unless you are implementing a very generic camera system, where you also control aperture and depth of view trough your camera class.

However What I said above still stands, i.e. when you move or make your camera look elsewhere (aim your camera), you don't need to mess with your frustum setup.


February 23, 2005, 09:21 AM

Invert your view matrix


February 24, 2005, 04:03 AM

put you do need to mess with your frustrum set up, because the frustrum in the case you talk about above, is in camera space. all my bounding volumes to cull against are in world space, so i need to get my frustrum in world space.

so camera space to world space. oooohh sounds like a transpose of the view matrix? but iv'e tried that and it didnt work :(

Erik Faye-Lund

February 24, 2005, 08:23 AM

no, it's INVERSE of your view matrix. not transpose.


February 25, 2005, 04:06 AM

in most cases, the inverse is the transpose?

am i gonna have to do the fully blown inverse ?

Victor Widell

February 25, 2005, 04:57 AM

"in most cases, the inverse is the transpose?"

For rotation matrices, the transpose equals the inverse. Note that this will ONLY work for PURE ROTATIONS.

The transposing mentioned above seems to be a fix for opengl/direct3d/math convention confusions.


March 01, 2005, 05:01 AM

right, i finaly implemented a fully working Inverse in my matrix class, but it's still not working properly :-/

  2.         // get frustrum in to world space
  3.         Matrix4 matViewProjection = GetWorld();
  4.         matViewProjection.Inverse();
  6.         Matrix4 projViewMatrix = matViewProjection * projection;
  7.         frustum.SetUpFromProjection(projViewMatrix);

if i dont move the camera and look around the frustrum culling works perfectly, but it falls apart when the camera moves, the frustrum doesnt move properly with the camera.


March 01, 2005, 08:52 AM

without knowing the conventions you are using your code I can't really tell, but try

1. try changing the translation from the last row to the last column in the matrix or vice versa

2. try flipping the concatenation order of the matrices


This thread contains 17 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.