I'm trying to setup a quadtree like terrain-loader like on codeplex's site (http://www.codeplex.com/quadtreeload)
The main thing is that I would like to use the XNA-BoundingFrustum
What i do is:
See if the root node is visible, if so, check each of its children which in case, check thier childs. With this I'm reducing the workload, If parent isn't visible then childs aren't either:
if the main update sequennce of the terrain:
m_Frustum = new BoundingFrustum(viewproj);
//try culling away stuff of the terrain here...
if (m_root != null)
m_root.TryCull(m_Frustum);
Trycull in case is a recursive function which does nothing more then:
switch (_frustum.Contains(new BoundingBox(new Vector3(this.m_startX, m_startY, m_minHeight), new Vector3(m_endX, m_endY, m_maxHeight))))
{
case ContainmentType.Disjoint:
//box is outside frustum
{
m_visible = false;
}
break;
case ContainmentType.Intersects:
//the box intersects the frustum
case ContainmentType.Contains:
//the box is inside the frustum
{
m_visible = true;
}
break;
}
//now if needed checks childs
if (m_visible == true)
{
for (int i = 0; i < 4; i++)
{
if (m_child != null)
m_child.TryCull(_frustum);
}
}
In some parts of the terrain, terrain objects dissapear, totally disappear and re-appear...
What does the BoundingFrustum.contains(...) returns if the frustum is totally inside the boundingbox of the terrain-section?
hopefully some ppl can shed some light on my problem and help me out.
Thx
Mike