• ### Announcements

#### Archived

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

# Frustum Culling code

## Recommended Posts

I had a look at the frustum culling tutorial by Mark Morley at http://www.markmorley.com/opengl/frustumculling.html And I thinks it''s a very cool tutorial. However there is a couple of things that I cant understand in it, they are as follows.. In the tutorial he has said float frustum[6][4]; That''s six sets of four numbers (six planes, each with an A, B, C, and D value). Now after multiplying the projection with the model view matrix, we get a number of clip[] array. What I dont understand is how we are getting the value of A,B,C by subtracting between those clip array''s,like.. /* Extract the numbers for the RIGHT plane */ frustum[0][0] = clip[ 3] - clip[ 0]; frustum[0][1] = clip[ 7] - clip[ 4]; frustum[0][2] = clip[11] - clip[ 8]; frustum[0][3] = clip[15] - clip[12]; How do we get the value of A by subtracting between clip[3] and clip[0] ? AS we know frustum[0][0] is A ,the next is B and so on...which are the values for right plane. Later on also why normalizing the result ? /* Normalize the result */ t = sqrt( frustum[0][0] * frustum[0][0] + frustum[0][1] * frustum[0][1] + frustum[0][2] * frustum[0][2] ); frustum[0][0] /= t; frustum[0][1] /= t; frustum[0][2] /= t; frustum[0][3] /= t; Please can anyone describe me these in a bit detail, so that I can understand. Muksitul

##### Share on other sites
Why isnt anyone answering to this post

(

##### Share on other sites
Hi. I dont know the answer to your first question. But for 2nd question, note that normalizing does not change the plane equation:
Ax + By + Cz = D => xA/t + yB/t + zC/t = D/t
are same things. However, when t = sqrt( AA + BB + CC ), this means the vector (A/t, B/t, C/t) is a vector of length 1.0. And this vector is the normal of the plane. So that later in the code you can use this normal vector for other purposes also.

##### Share on other sites

Hi,

Found an explnation for quesiton 1 here.

http://www.frii.com/~martz/oglfaq/viewcull.c

Keef

##### Share on other sites
Check out www.realtimerendering.com . There is a link which explains this.

I had the exact same question (and the solution). Search the archives for the exact link if you can''t find it.

##### Share on other sites
Thanks Everyone
I am checking all the links
so, I am still going through the learning stage
so btw DigiBen posted an anwer for me at the forum
I havent still finished reading it yet , lol
http://www.gametutorials.com/forum/topic.asp?TOPIC_ID=1708&FORUM_ID=4&CAT_ID=1&Topic_Title=help+on+frustum+culling&Forum_Title=Newbie

You guys might wanna have a look at it too
Muksitul

• ### Forum Statistics

• Total Topics
628278
• Total Posts
2981785

• 10
• 11
• 17
• 13
• 9