For some reason when run my Quake III BSP engine it looks like everything is going toward the origin. I do not understand why my engine is doing this. Could someone please look at my code?
void NuclearBSP::Q3::RenderLeaf(int Leaf, bool CheckFrustum, Vect3& Pos)
{
BSPLeaf* leaf = &leafs[Leaf];//preform PVS
if(!IsClusterVisible(leafs[FindLeaf(Pos)].cluster, leaf->cluster))
{
return;
}//if the node we came from is COMPLETEIN then CheckFrustum will be false and we
//wont need to check this leaf against the frstum because we know we are COMPLETEIN
//if the node was intersecting then check agienst the frstumif(CheckFrustum)
{
if(!frustum.BoxInFrustum(leaf->min.x, leaf->min.y, leaf->min.z, leaf->max.x, leaf->max.y, leaf->max.z))
{
return;
}
}int lfacecount = leaf->leaffacecount;
//Size faces
CRender render(lfacecount);//render all the faces in this leaf
while(lfacecount–)
{
//get current face index
int faceindex = leaffaces[leaf->leafface + lfacecount];if((faces[faceindex].type == BEZIER_PATCH) | | (faces[faceindex].type == BILLBOARD)) { render.Push(0); continue; } //make sure the face hasnt been drawn if(!facesdrawn.On(faceindex)) { facesdrawn.Set(faceindex); render.Push(&faces[faceindex]); }else{ render.Push(0); }
}
render.Render();
}CRender::CRender(int size)
{
faces = 0;
SetupFaces(size);
}CRender::CRender()
{
faces = 0;
facecount = 0;
pos = 0;
}CRender::~CRender()
{
if(faces)
{
delete faces;
}
}//resizes the faces before they’re pushed
void CRender::SetupFaces(int size)
{
if(faces)
{
delete faces;
}facecount = size;
faces = new PVertexBuffer[facecount];
pos = 0;
}//add a face to the faces array
void CRender::Push(VertexBuffer* face)
{
faces[pos] = face;
pos++;
}//render the faces
void CRender::Render()
{
if(pos != facecount)
{
fprintf(stderr, "Error pos(%i) != facecount(%i)!!!
", pos, facecount);
}//go threw all the faces and render them
for(int i=0;i<facecount;i++)
{
if(faces[i] == 0)
{
continue;
}//set the texture glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, faces[i]->textureID); //set the lightmaps up glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, faces[i]->lightmapID); //set the vertex pointer for each face glVertexPointer(3, GL_FLOAT, sizeof(VertexBuffer), faces[i]->vert); //assign texture pass to point to normal texture coords glClientActiveTextureARB(GL_TEXTURE0_ARB); glTexCoordPointer(2, GL_FLOAT, sizeof(VertexBuffer), faces[i]->texcoord); //assign lightmap pass to point glClientActiveTextureARB(GL_TEXTURE1_ARB); glTexCoordPointer(2, GL_FLOAT, sizeof(VertexBuffer), faces[i]->lightmapcoord); //draw it glDrawElements(GL_TRIANGLES, faces[i]->indicescount, GL_UNSIGNED_INT, faces[i]->indices);
}
}
The complete source is here .
Can someone please help me figure out whats wrong?
Thanks
Nuke
[This message has been edited by nukem (edited 11-19-2003).]