//********************************************************************************** // calculateVisibleNodes // // marks this node and all children as visible or not visible, depending whether // or not they are in the view frustum //********************************************************************************** void Node::calculateVisibleNodes(Frustum view_frustum) { VECTOR3D min = m_bounding_box.min_point; VECTOR3D max = m_bounding_box.max_point; VECTOR3D this_nodes_bounding_box[8]; this_nodes_bounding_box[0] = VECTOR3D(min.x, min.y, min.z); this_nodes_bounding_box[1] = VECTOR3D(max.x, min.y, min.z); this_nodes_bounding_box[2] = VECTOR3D(min.x, max.y, min.z); this_nodes_bounding_box[3] = VECTOR3D(max.x, max.y, min.z); this_nodes_bounding_box[4] = VECTOR3D(min.x, min.y, max.z); this_nodes_bounding_box[5] = VECTOR3D(max.x, min.y, max.z); this_nodes_bounding_box[6] = VECTOR3D(min.x, max.y, max.z); this_nodes_bounding_box[7] = VECTOR3D(max.x, max.y, max.z); if(view_frustum.IsBoundingBoxInside(this_nodes_bounding_box)) //if(view_frustum.IsPointInside(m_bounding_box.min_point) || view_frustum.IsPointInside(m_bounding_box.max_point)) { //mark this node as visible m_visible = true; } else { m_visible = false; } //check to see which children are visible std::vector<Node *>::iterator iter = m_children.begin(); while(iter != m_children.end()) { (*iter)->calculateVisibleNodes(view_frustum); iter++; } }