Octree Culling The Proper Way
hey,
I have my octree implementation working fine. And i can render the scene. So far though it renders all of the polygons, the octrees are only used for collisions. Whats the proper way to test to see if the octree is visible ?
If my first Octree is the main parent containing all of the others, do i check that to see if its in the frustrum ? like this ?
Check Octree, Is it out of frustrum ?
Don''t Draw / Check Sub Octrees
Is it totally in ?
Draw all of this octrees polys, dont check children
Is it half in ?
Do same check for children
Is this the correct way ?
if your current octree node isn''t within the frustum, you need not to check your child-nodes, for they can never be within the frustum if the parent isn''t.
Hehe, thanks for the help. At the moment my octree code only returns true/false for the cube in frusutrum check. Does anyone have any code that returns inside all the way, partcial or outside ?
void COctreeNode::DrawFrustrumCulled(CFrustrum &Frustrum){ unsigned short int i; int j; switch (Frustrum.CubeLocation(m_NodeBoundingVolume.m_fCenter, m_NodeBoundingVolume.m_fSize)) { case 0: // Full Outside { return; } case 1: // Partcial Inside { for (i = 0; i < 8; i++) { m_pChildNodes.DrawFrustrumCulled(Frustrum); } return; } case 2: // Full Inside { for (i = 0; i < m_iFaceCount; i++) { switch (m_pFaces.iNumVertices)<br> {<br> case 3:<br> glBegin(GL_TRIANGLES);<br> break;<br> case 4:<br> glBegin(GL_QUADS);<br> break;<br> default:<br> glBegin(GL_POLYGON);<br> }<br><br> for (j = 0; j < (int) m_pFaces.iNumVertices; j++)<br> {<br> glVertex3f(m_pFaces.pVertices[j].fX, m_pFaces.pVertices[j].fY, m_pFaces.pVertices[j].fZ);<br> }<br><br> glEnd();<br> }<br> return;<br> }<br> }<br>}<br></pre><br><br>There is the code that i came up with, does it look alright to you. It doesnt work properly at the moment, im bout to debug it but thats the kinda thing ? </i> </pre>
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement