   BSP30 rendering
  Hi, I'm loading and using bsp version 30 files (same as half-life 1) and have successfully loaded the file into data, but I'm having trouble figuring out how I'm to render this data...Here is how the data is structured:// BSP Lumpsstruct tBSPLump {unsigned int offset, length;};// BSP headerstruct tBSPHeader {unsigned int version;tBSPLump dir[NUM_LUMPS];};// BSP Entitytypedef unsigned char tBSPEntity;// BSP Planesstruct tBSPPlane{float normal[3];float dist;// Plane equation is: Normal * X = Distenum{PLANE_X = 0,// Plane is perpendicular to given axisPLANE_Y,PLANE_Z,PLANE_ANYX,// Dominant axis (axis along which projection of normal has greatest magnitude)PLANE_ANYY,PLANE_ANYZ} type;};// BSP Mip-mapped Textures...headerstruct tBSPTextureHeader {unsigned int numMiptex;unsigned int offset[4];};//...bodystruct tBSPMiptex{char name[16];unsigned int width;unsigned int height;unsigned int offset[4];};// BSP Verticesstruct tBSPVertices{float x, y, z;};// BSP Visibilitytypedef unsigned __int8 tBSPVisibility;// BSP Nodesstruct tBSPNodes{unsigned short plane_idx;signed short children[2];signed short mins[3];signed short maxs[3];unsigned short firstface;unsigned short numfaces;};// BSP Texture Infostruct tBSPTexinfo{float vecs[2][4]; // [s/t][x/y/z/offset]int miptex_idx;int flags;};// BSP Facesstruct tBSPFaces{unsigned __int16 plane_idx;unsigned __int16 side;unsigned __int32 firstedge;unsigned __int16 numedges;unsigned __int16 texinfo;unsigned __int8 styles[4];unsigned __int32 light_offset;};// BSP Lightmapsstruct tBSPLightmap {signed __int8 imageBits[128][128][3];};// BSP Leavesstruct tBSPLeaf{signed int contents;signed int visofs;signed short mins[3];signed short maxs[3];unsigned short firstmarksurface;unsigned short nummarksurfaces;unsigned char ambient_level[4];};typedef unsigned short tBSPMarkedsurf;// BSP Clipping nodesstruct tBSPClipnode{int plane_idx;short children[2];};// BSP Edgesstruct tBSPEdge{unsigned short v[2]; // indices numbers of the vertices bounding this edge};// BSP Surface Edgestypedef signed int tBSPSurfedge;// BSP Modelsstruct tBSPModels{float mins[3];float maxs[3];float origin[3];int headnode[4];int visleafs;int firstface;int numfaces;};// HeadertBSPHeader head;// Entity ListtBSPEntity *entity;//Planesunsigned int numPlanes;tBSPPlane *plane;//TexturetBSPTextureHeader textureheader;tBSPMiptex *miptex;//Verticesunsigned int numVertices;tBSPVertices *vertex;//Visibilityunsigned int numClusters;tBSPVisibility *pvs;//Nodesunsigned int numNodes;tBSPNodes *node;//Leavesunsigned int numLeaves;tBSPLeaf *leaf;//Texinfounsigned int numTextures;tBSPTexinfo *texture;//Facesunsigned int numFaces;tBSPFaces *face;//Lightmapsunsigned int numLightmaps;tBSPLightmap *lightmap;//Clipping nodesunsigned int numClipNodes;tBSPClipnode *clipnode;// Marked Surfacesunsigned int numMarkedsurfaces;tBSPMarkedsurf *markedsurf;//Edgesunsigned int numEdges;tBSPEdge *edge;//Surface Edgesunsigned int numSurfEdges;tBSPSurfedge *surfedge;//Modelsunsigned int numModels;tBSPModels *model;This is what I have for rendering so far:int BSPLeaf( bspFile info, glVector camera_pos ){int index = 0;bspFile::tBSPNodes node;bspFile::tBSPPlane;float distance;while( index >= 0 ) {node = info.node[index];plane = info.plane[node.plane_idx];distance = dotproduct( glVector( plane.normal[0], plane.normal[1], plane.normal[2] ), camera_pos ) - plane.dist;if( distance >= 0 ) {index.node.children[0];} else {index.node.children[1];}}return -index - 1;}bool BSPClusterCompare( bspFile info, int visCluster, int testCluster ){if( info.numClusters == NULL || visCluster < 0 ) return true;int i = (visCluster * 8) + (testcluster >> 3 );unsigned __int8 set = info.pvs;return (set & (1 << (testCluster & 7))) != 0;}void BSPRender( glPoint campos, bspFile info ){std::set<int> alreadyvis;std::vector<int> visible;int camleaf = BSPLeaf( info, campos );int f;// Begin leaf iteration :)for( int l = 0; l < info.numLeaves; l++ ) {if( BSPClusterCompare( info, camleaf, info.leaf[l].visofs ) ) {for (int i = 0; i < leaf[l].numFaces; ++i) { f = i + leaf[L].firstFace; pair<iterator,bool> data = alreadyvis.insert( f );    if( data.second == true ) {   visible.append( f );    }}}}for( int v = 0; v < visible.size(); v++ ) {switch( info.face[ visible[v] ].type ) {case 1:// Polygonbreak;case 2:// Patchbreak;case 3:// Meshes ???break;case 4:// Billboardbreak;}}}Basically, I don't know how I would render any of them in any fashion - I'm fairly new to bsp trees and bsp30 files, so i'm not entirely sure.  Any help would be appreciatedThanks,Oz~   
  I've found some bugs in my code, so i've recoded some of itperhaps that would be more helpData structures#define _atosoft_bspfile_h_#include <cstdlib>#include <cstdio>#include <iostream>#include <vector>#include <fstream>// BSP-30 files contain these lumpsenum{LUMP_ENTITIES = 0,LUMP_PLANES,LUMP_TEXTURES,LUMP_VERTICES,LUMP_VISIBILITY,LUMP_NODES,LUMP_TEXINFO,LUMP_FACES,LUMP_LIGHTING,LUMP_CLIPNODES,LUMP_LEAVES,LUMP_MARKSURFACES,LUMP_EDGES,LUMP_SURFEDGES,LUMP_MODELS,NUM_LUMPS};namespace bsptype{#pragma pack(4)// BSP Lumpsstruct tBSPLump {unsigned int offset, length;};// BSP headerstruct tBSPHeader {unsigned int version;tBSPLump dir[NUM_LUMPS];};// BSP Entitytypedef unsigned char tBSPEntity;// BSP Planesstruct tBSPPlane{float normal[3];float dist;// Plane equation is: Normal * X = Distenum{PLANE_X = 0,// Plane is perpendicular to given axisPLANE_Y,PLANE_Z,PLANE_ANYX,// Dominant axis (axis along which projection of normal has greatest magnitude)PLANE_ANYY,PLANE_ANYZ} type;};// BSP Mip-mapped Textures...headerstruct tBSPTextureHeader {unsigned int numMiptex;unsigned int offset[1];};//...bodystruct tBSPMiptex{char name[16];unsigned int width;unsigned int height;unsigned int offset[4];};// BSP Verticesstruct tBSPVertices{float x, y, z;};// BSP Visibilitytypedef unsigned __int8 tBSPVisibility;// BSP Nodesstruct tBSPNodes{unsigned short plane_idx;signed short children[2];signed short mins[3];signed short maxs[3];unsigned short firstface;unsigned short numfaces;};// BSP Texture Infostruct tBSPTexinfo{float vecs[2][4]; // [s/t][x/y/z/offset]int miptex_idx;int flags;};// BSP Facesstruct tBSPFaces{unsigned __int16 plane_idx;unsigned __int16 side;unsigned __int32 firstedge;unsigned __int16 numedges;unsigned __int16 texinfo;unsigned __int8 styles[4];unsigned __int32 light_offset;};// BSP Lightmapsstruct tBSPLightmap {signed __int8 imageBits[128][128][3];};// BSP Leavesstruct tBSPLeaf{signed int contents;signed int visofs;signed short mins[3];signed short maxs[3];unsigned short firstmarksurface;unsigned short nummarksurfaces;unsigned char ambient_level[4];};typedef unsigned short tBSPMarkedsurf;// BSP Clipping nodesstruct tBSPClipnode{int plane_idx;short children[2];};// BSP Edgesstruct tBSPEdge{unsigned short v[2]; // indices numbers of the vertices bounding this edge};// BSP Surface Edgestypedef signed int tBSPSurfedge;// BSP Modelsstruct tBSPModels{float mins[3];float maxs[3];float origin[3];int headnode[4];int visleafs;int firstface;int numfaces;};#pragma pack()};class bspFile{public:bspFile();~bspFile();FILE* bspfile;bool bspLoad( const char* fname );void *bspLump( bsptype::tBSPLump lump );int bspElements( bsptype::tBSPLump lump, unsigned int typesize );void bspUnload();// Headerbsptype::tBSPHeader head;// Entity Listbsptype::tBSPEntity *entity;//Planesunsigned int numPlanes;bsptype::tBSPPlane *plane;//Texturebsptype::tBSPTextureHeader textureheader;bsptype::tBSPMiptex *miptex;//Verticesunsigned int numVertices;bsptype::tBSPVertices *vertex;//Visibilityunsigned int numClusters;bsptype::tBSPVisibility *pvs;//Nodesunsigned int numNodes;bsptype::tBSPNodes *node;//Leavesunsigned int numLeaves;bsptype::tBSPLeaf *leaf;//Texinfounsigned int numTextures;bsptype::tBSPTexinfo *texture;//Facesunsigned int numFaces;bsptype::tBSPFaces *face;//Lightmapsunsigned int numLightmaps;bsptype::tBSPLightmap *lightmap;//Clipping nodesunsigned int numClipNodes;bsptype::tBSPClipnode *clipnode;// Marked Surfacesunsigned int numMarkedsurfaces;bsptype::tBSPMarkedsurf *markedsurf;//Edgesunsigned int numEdges;bsptype::tBSPEdge *edge;//Surface Edgesunsigned int numSurfEdges;bsptype::tBSPSurfedge *surfedge;//Modelsunsigned int numModels;bsptype::tBSPModels *model;};#endifAnd here is my fixed rendering code which still doesn't do much...int BSPLeaf( bspFile info, glVector camera_pos ){int index = 0;bsptype::tBSPNodes node;bsptype::tBSPPlane plane;float distance;while( index >= 0 ) {node = info.node[index];plane = info.plane[node.plane_idx];distance = dotproduct( glVector( plane.normal[0], plane.normal[1], plane.normal[2] ), camera_pos ) - plane.dist;if( distance >= 0 ) {index = node.children[0];} else {index = node.children[1];}}return -index - 1;}bool BSPClusterCompare( bspFile info, int visCluster, int testCluster ){if( info.numClusters == 0 || visCluster < 0 ) return true;int i = (visCluster * 8) + (testCluster >> 3 );unsigned __int8 set = info.pvs;return (set & (1 << (testCluster & 7))) != 0;}void BSPRender( glPoint campos, bspFile info ){std::set<int> alreadyvis;std::vector<int> visible;bsptype::tBSPFaces *face;int fid;int vert;int camleaf = BSPLeaf( info, glVector( campos.x, campos.y, campos.z ) );int f;// Begin leaf iteration :)for( unsigned int l = 0; l < info.numLeaves; l++ ) {if( BSPClusterCompare( info, camleaf, info.leaf[l].visofs ) ) {for ( unsigned int i = 0; i < info.leaf[l].nummarksurfaces; i++ ) { f = i + info.leaf[l].firstmarksurface;    if( alreadyvis.insert( f ).second == true ) {   visible.push_back( f );    }}}}for( unsigned int v = 0; v < visible.size(); v++ ) {face = info.face;fid = visible[v];if( info.plane[ face[ fid ].plane_idx ] == 1) {vert = face[ fid ].firstedge;for( int edge = 0; edge < (face[ fid ].numedges / 3); edge+=3 ) {glBegin( GL_TRIANGLES );glVertex3f( info.vertex[ edge + vert + 0 ].x, info.vertex[ edge + vert + 0 ].y, info.vertex[ edge + vert + 0 ].z );glVertex3f( info.vertex[ edge + vert + 1 ].x, info.vertex[ edge + vert + 1 ].y, info.vertex[ edge + vert + 1 ].z );glVertex3f( info.vertex[ edge + vert + 2 ].x, info.vertex[ edge + vert + 2 ].y, info.vertex[ edge + vert + 2 ].z );glEnd();}}}}Can anyone give me a hand at all?Oz~   ;  I've just gotten word that triangle strips might be helpful....any good places that I could learn about them?Oz~   