Jump to content
  • Advertisement
Sign in to follow this  

How is the plane represented in this example?

This topic is 4485 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

I define my planes in my game by two vectors, one for the position of an arbitrary point on the plane, and one normalized vector for the normal. Now I'm trying to implement view frustum culling, and I found this code for retrieving the view frustum planes, but apparently this code uses some other way of representing a plane than the one I use - here there seems to be 4 floats to define a plane. What format is the plane represented in here? How can I convert from this representation to my own representation (aribtrary point and normal)? Matrix viewProjection = m_view * m_projection; // Left plane m_frustum[0].A = viewProjection.M14 + viewProjection.M11; m_frustum[0].B = viewProjection.M24 + viewProjection.M21; m_frustum[0].C = viewProjection.M34 + viewProjection.M31; m_frustum[0].D = viewProjection.M44 + viewProjection.M41; // Right plane m_frustum[1].A = viewProjection.M14 - viewProjection.M11; m_frustum[1].B = viewProjection.M24 - viewProjection.M21; m_frustum[1].C = viewProjection.M34 - viewProjection.M31; m_frustum[1].D = viewProjection.M44 - viewProjection.M41; // Top plane m_frustum[2].A = viewProjection.M14 - viewProjection.M12; m_frustum[2].B = viewProjection.M24 - viewProjection.M22; m_frustum[2].C = viewProjection.M34 - viewProjection.M32; m_frustum[2].D = viewProjection.M44 - viewProjection.M42; // Bottom plane m_frustum[3].A = viewProjection.M14 + viewProjection.M12; m_frustum[3].B = viewProjection.M24 + viewProjection.M22; m_frustum[3].C = viewProjection.M34 + viewProjection.M32; m_frustum[3].D = viewProjection.M44 + viewProjection.M42; // Near plane m_frustum[4].A = viewProjection.M13; m_frustum[4].B = viewProjection.M23; m_frustum[4].C = viewProjection.M33; m_frustum[4].D = viewProjection.M43; // Far plane m_frustum[5].A = viewProjection.M14 - viewProjection.M13; m_frustum[5].B = viewProjection.M24 - viewProjection.M23; m_frustum[5].C = viewProjection.M34 - viewProjection.M33; m_frustum[5].D = viewProjection.M44 - viewProjection.M43; // Normalize planes for ( int i = 0; i < 6; i++ ) { m_frustum = Plane.Normalize( m_frustum ); }

Share this post

Link to post
Share on other sites
It's a representation of normal vector (A,B,C) and a distance of closest point on a plane to (0,0,0) D.

In your representation, your distance vector (aka arbitrary point) is (A,B,C)*D
To compute D from your representation, use gramm-shmidt to substract normal component from your offset vector, to get closest point on the plane (closest to (0,0,0)) and take its length.


EDIT: found this old paper: plane extraction for dummies.. ekhm, programmers.

Share this post

Link to post
Share on other sites
Why are you representing your plane by a point and a normal? Thats totaly unusefull in any situation i can think off. Normaly you are representin a plane by its normal 'vec3 norm;' and distance from origin 'float d;' where 'd' is where the plane intercepts a line going from the origin in the direction of the normal (plane = normal, -dot(point, normal)), you can find tons of information on the net about that.

So basicaly you have a 'vec4 plane' where components x, y, z define the normal and component 'w' defines the 'd' parameter.

The '-dot(point, normal)' is so that the value 'd' is represented as negative wich makes it convinient to classify points to the plane by computing a 'plane dot product' like this:
dot(plane, point) = plane.x * point.x + plane.y * point.y + plane.x * point.x + plane.w;
Where a result of '0' meens that the point is inside the plane,

In your case to convert from 'vec3 point, norm;' to 'vec4 plane;' you do:
vec4 plane(norm.x, norm.y, norm.z, -dot(point, norm));
and in the oposite direction:
vec3 norm(plane.x, plane.y, plane.z);
vec3 point(norm * -plane.w);

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!