Jump to content
  • Advertisement
Sign in to follow this  
bori

[SOLVED] Quake 3 BSP loader

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. Maybe you wonder why I am trying to create Q3 BSP renderer, but I have some weird reasons for that. :) I read the forum forward and backward and figured out, that this is going to be the right way to render my faces (all PVS stuff is omitted).
for(int i = 0; i < Geometry->numLeafs; i++) {
         
   for(int f = 0; f < Geometry->Leafs.numLeafFaces; f++) {
      
      glDrawElements(GL_TRIANGLES, Geometry->Faces[f].numMeshVerts, GL_UNSIGNED_INT,
         &Geometry->MeshVerts[Entity->Geometry->Faces[f].meshVertIndex]);
      
   }
         
}
I wondered, why I am not seeing anything and after short debug I found out, that every Leaf has the numLeafFaces set to 0. I absolutely don't know why, it happens on all original Quake 3 maps, all from the tutorials and even my own maps (compiled by q3map2). I think I haven't messed up the loading process (I can paste here more, if you want). Thanks for help in advance, bori [Edited by - bori on January 16, 2008 11:44:52 AM]

Share this post


Link to post
Share on other sites
Advertisement
If NumleafFaces is zero, it would suggest the problem lies with the loading process.

Post the loading code inside some source tags and let's see what we can find.

Share this post


Link to post
Share on other sites
Thanks for replying!

Quote:
Original post by deadstar
Post the loading code inside some source tags and let's see what we can find.


Well, there's the relevant part of loading process:


numLeafs = gLump[LUMPS_LEAFS].length / sizeof(sLeaf);
Geometry->Leafs = new sLeaf[numLeafs];
Geometry->numLeafs = numLeafs;

fseek(f, gLump[LUMPS_LEAFS].offset, SEEK_SET);

for(i = 0; i < numLeafs; i++) {

fread(Geometry->Leafs, 1, sizeof(sLeaf), f);

int temp = Geometry->Leafs.minBox[1];
Geometry->Leafs.minBox[1] = Geometry->Leafs.minBox[2];
Geometry->Leafs.minBox[2] = -temp;

temp = Geometry->Leafs.maxBox[1];
Geometry->Leafs.maxBox[1] = Geometry->Leafs.maxBox[2];
Geometry->Leafs.maxBox[2] = -temp;

printf("%i\n", Geometry->Leafs.numLeafFaces);

}



The printf function is there for printing number of leaf faces - that's the one returning zero every time.

Btw LUMPS_LEAFS is 4 actually and the inner structure of Leafs looks like this:


struct sLeaf {

int cluster;
int area;
int minBox[3];
int maxBox[3];
int leafFace;
int numLeafFaces;
int leafBrush;
int numLeafBrushes;

};

Share this post


Link to post
Share on other sites
hey

I suggest that you do further debugging. Why not also print out other variables such as gLump[LUMPS_LEAFS].offset, and/or numLeafs and such, and check that they are right?

BTW, try... fread(&Geometry->Leafs, 1, sizeof(sLeaf), f); instead ;).

cya

Share this post


Link to post
Share on other sites
Quote:
Original post by yosh64
BTW, try... fread(&Geometry->Leafs, 1, sizeof(sLeaf), f); instead ;).


Sure, that was a terrible mistake! Thanks for noticing that!

Well, it still doesn't render well, but I will manage with that. I was just wondering, why a bunch of zeros was there.

Thanks everyone for help.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!