Sign in to follow this  

rendering planes with lines for debugging.

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

Anyone got a simple function that render planes with lines or someting that can be used to see that the planes are correct? Or even better, a function that calculate plane intersectionpoints and renders a frustum. Thanks in advance!

Share this post


Link to post
Share on other sites
That depends on your graphics API. And you can't render planes with lines, since planes have infinite area - there's no edges to draw. If you know the extents of the plane (So it's a quad, really), you can draw lines around that.

Share this post


Link to post
Share on other sites
Quote:
Original post by peter_b
Anyone got a simple function that render planes with lines or someting that can be used to see that the planes are correct? Or even better, a function that calculate plane intersectionpoints and renders a frustum.


Thanks in advance!
I usually render planes (for debugging purposes) as a grid, but it sounds like what you really want is to render the volume of a view frustum.

The key thing you need for this is a plane intersection function, as you mentioned. The algorithm is straightforward, and is simply the solution to a 3x3 system of equations, where each equation represents one of the three planes. Note that there are various configurations (all planes parallel, two planes parallel, and so on) where the system has no solution or no unique solution, but when intersecting the planes of a frustum you should not encounter these situations under normal circumstances.

Here's some code (note that the input planes are in ax+by+cz+d = 0 form):


template <class T> bool intersect_planes(T p0[4], T p1[4], T p2[4], Vector3<T>& v, T epsilon)
{
Vector3<T> n0(p0[0], p0[1], p0[2]);
Vector3<T> n1(p1[0], p1[1], p1[2]);
Vector3<T> n2(p2[0], p2[1], p2[2]);

T d0 = -p0[3];
T d1 = -p1[3];
T d2 = -p2[3];

T denom = no.Dot(n1.Cross(n2));
if (Math<T>::Fabs(denom) < epsilon)
return false;

v = (d0 * n1.Cross(n2) + d1 * n2.Cross(n0) + d2 * n0.Cross(n1)) / denom;
return true;
}

Share this post


Link to post
Share on other sites

This topic is 4197 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this