Archived

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

Octree Culling The Proper Way

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

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 ?

Share this post


Link to post
Share on other sites


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[i].iNumVertices)
{
case 3:
glBegin(GL_TRIANGLES);
break;
case 4:
glBegin(GL_QUADS);
break;
default:
glBegin(GL_POLYGON);
}

for (j = 0; j < (int) m_pFaces[i].iNumVertices; j++)
{
glVertex3f(m_pFaces[i].pVertices[j].fX, m_pFaces[i].pVertices[j].fY, m_pFaces[i].pVertices[j].fZ);
}

glEnd();
}
return;
}
}
}
[/CODE]

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 ?

Share this post


Link to post
Share on other sites