Frustum Culling code

Started by
4 comments, last by Muksitul 21 years, 11 months ago
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
Advertisement
Why isnt anyone answering to this post

(
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.

Hi,

Found an explnation for quesiton 1 here.

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


Keef
-----------------------Current Project: The Chromatic Game Engine
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.
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
here is the link
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

This topic is closed to new replies.

Advertisement