Archived

This topic is now archived and is closed to further replies.

Ranger_One

Ok- Frustum Question

Recommended Posts

I have a Frustum system... now I need a rectangle which defines a plane perpendicular to the camera at some given distance. I want to implement a infinite scrolling surface in the background of the screen, but I need to know what the view coordinates of the infinite surface will be... I could phrase this question another way- How can I find the intersection points between a frustum and an infinite plane? Thanks, Ranger

Share this post


Link to post
Share on other sites
you don''t have to.
you can use the screen coordinates instead.

or if I misunderstood, you can find the direction of a given corner, then take that direction * some number, then repeat for the other corners, and you get the corners.

// in case you don''t use opengl, just take (xx or 0) and (yy or 5)
// positions in the matrix and do the same thing

// if you use opengl you would do this
float temp_mat[16];
glGetFloatv(GL_PROJECTION_MATRIX, temp_mat); // get your projection matrix

/*
OpenGl arranges its matricies like this, if I remember right
but doesn''t matter if it is transposed, since you only want
the 0 and 5.

0123
4567
89..
....
*/

// then find your corners
view_x = ( [+/-] .5f)*(1/temp_mat[0]);
view_y = ( [+/-] .5f)*(1/temp_mat[5]);

(view_x, view_y, 1.0f) * some distance in that direction

Share this post


Link to post
Share on other sites
Interesting Idea- I''ll try that. Thanks

The only time that wouldn''t work is when the infinite surface would be at a angle to the camera, instead of perpendicular. Although that wouldn''t be a problem right now.

Thanks again,
Ranger

Share this post


Link to post
Share on other sites
Your camera is a point. Each corner of your frustrum rectangle is a point. Take the rays going from the camera point to each of the frustrum corner points. You know equations for rays. You know the standard equation for a plane. Find the intersections. Each of the four rays will intersect once with the plane; as a result you''ll have 4 points of intersection. These define the quadrilateral you want to draw. Note that you may need to cull one or more of these points if they lie behind the camera plane.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well Rnager I can surely help but I dont understand clearly your idea Is the camera supposed to turn or are you just translating // to this surface ? If your "background" turns with the camera then what kind of background is it supposed to be ?

Do you want to do an infinite scrolling sky ? Then it''s not exactly what U said.

Charles B

Share this post


Link to post
Share on other sites