void CBSPNode::Traverse(CVector position) // position is the position of the camera
{
float side = this->plane.GetSide(position);
if (side > 0.0) { // the camera is in front of the plane
if (this->back) this->back->Traverse(position);
if (this->leaf1) this->leaf1->Render();
if (this->leaf2) this->leaf2->Render();
if (this->front) this->front->Traverse(position);
}
else if (side < 0.0) {
if (this->front) this->front->Traverse(position);
if (this->leaf1) this->leaf1->Render();
if (this->leaf2) this->leaf2->Render();
if (this->back) this->back->Traverse(position);
}
else {
if (this->back) this->back->Traverse(position);
if (this->front) this->front->Traverse(position);
}
}
The bsp tree is exactly like the one in the file. I don't know if my plane.GetSide is correct, could someone verify it?
float side = point.DotProduct(plane.normal) - plane.distance;
And a final question: how do I determine which cluster the camera is currently in? I figure I need to know that to render all the other visible clusters?