Archived

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

PsyVision

Octree Culling The Proper Way

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

Share this post


Link to post
Share on other sites
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 ?

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