Octtree node -- Frustum Check

This topic is 4968 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I'm thinking I'm nearly done with OctTrees but I'm getting random triangles not showing up as seen here (click to enlarge): I'm thinking this is because of my Frustum-->Node check. Each node saves a max and min point, and the function is passed a cCamera* which contains six frustum planes: //Note: somehow in my mind the capital S stands for "sigma." Also SideOfPlane returns either -1 (opposite side of normal), 0 (on plane) or 1 (same side as normal)
BOOL cOctTreeNode::CheckVisibility(cCamera* cam)
{
Vector3 p[8];
p[0] = Vector3(m_Min.x, m_Min.y, m_Min.z);
p[1] = Vector3(m_Max.x, m_Min.y, m_Min.z);
p[2] = Vector3(m_Max.x, m_Max.y, m_Min.z);
p[3] = Vector3(m_Min.x, m_Max.y, m_Min.z);
p[4] = Vector3(m_Min.x, m_Min.y, m_Max.z);
p[5] = Vector3(m_Min.x, m_Max.y, m_Max.z);
p[6] = Vector3(m_Max.x, m_Min.y, m_Max.z);
p[7] = Vector3(m_Max.x, m_Max.y, m_Max.z);

for(DWORD j=0; j < 6; j++)
{
int Sd = 0;
for(DWORD i=0; i < 8; i++)
{
int d = SideOfPlane(p, cam->m_Frustum[j]);

Sd += d;
}
if(Sd == -8)
return FALSE;
}
return TRUE;
}


Does this function look right? If not, any ideas where else I should start looking (I know this is a longshot question but I suppose it's worth asking). More code (or pseudocode) available upon request. Thanks a bunch! [Edited by - ms291052 on November 10, 2004 3:45:13 PM]

Share on other sites
A few thoughts...

I assume

Sd += m;

Is supposed to be

Sd += d;

Probably just a typo in the post, because the m probably wouldn't compile (unless it's a member or something?).

Also, for static AABBs (like octree nodes) I'd cache the corners - you can probably afford the memory, and it will save a little time.

There is a faster AABB/plane test you can use as well - it was discussed in a recent thread (in the math forum maybe).

As to your problem, I'm not sure. There are a lot of places where the error could be. Are your node AABBs correct? Are the triangles in the correct nodes? Is the hierarchical recursion working? In situations like this I often find it helpful to draw debugging info - for example, set a key to step from node to node, and then draw the AABB and the triangles for that node in red to make sure they are contained correctly. And so on.

Share on other sites
I have been looking for answers to the same question, sorta. In my opinion, it looksa as if you are excluding triangles from the nodes themselves when creating them. Are you adding triangles that are completely in? If so, add triangles that are partially insie as well. Check out this link. The link inside this link is a gold mine of info. Hope this helps.

EDIT: If you use the method that I just learned (check the link) you can quit recursion and render once a node returns INSIDE because you then know that all of its child nodes are inside as well.

Share on other sites
or use two aabbs

one with the exact node boundaries and one which fits the boundaries of your opjects inside the octree

add new objects by testing their center to the exact boundary

then generate the center of each secondary aabb and get the radius

test the center against the frustrum planes if it is >= radius away to skip it

• 33
• 12
• 10
• 9
• 9
• Forum Statistics

• Total Topics
631354
• Total Posts
2999491
×