Archived

This topic is now archived and is closed to further replies.

problems loading a q2 bsp-file

This topic is 6015 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, i wrote a class for loading a quake2 bsp-file. i tested the class and i think some of the structure members like an edge have wrong data. it is also impossible to render a face. does anyone know what i made wrong or knows a better way of loading a quake2 bsp-file ?? q2bsp.h ---------------------------------------- #include #include class Q2BSP { protected: struct qBSP_Lump { unsigned long offset; unsigned long length; }; struct qBSP_Header { unsigned long magic; unsigned long version; qBSP_Lump lump[19]; }; struct qVertex { float x,y,z; }; struct qEdge { unsigned short v1,v2; }; struct qFace { unsigned short plane; short plane_side; int first_edge; short num_edges; short texture_info; byte lightmap_styles[4]; int lightmap_offset; }; FILE *file1; qBSP_Header header; public: bool OpenBSP(char *); ~Q2BSP(); void LoadVertexLump(); void LoadEdgeLump(); void LoadFaceEdgeLump(); void LoadFaceLump(); qVertex *vertexarray; qEdge *edgearray; unsigned long *faceedgearray; qFace *facearray; unsigned long num_vertices; unsigned long num_edges; unsigned long num_faceedges; unsigned long num_faces; }; ------------eof----------------------------- q2bsp.cpp -------------------------------------------- #include "q2bsp.h" bool Q2BSP::OpenBSP(char *filename) { file1=fopen(filename,"rb"); if(!file1) return false; fseek(file1,0L,SEEK_SET); fread(&header,sizeof(header),1,file1); return true; } Q2BSP::~Q2BSP() { fclose(file1); } void Q2BSP::LoadVertexLump() { fseek(file1,header.lump[2].offset,SEEK_SET); num_vertices=header.lump[2].length/sizeof(qVertex); vertexarray = new qVertex[num_vertices]; for(unsigned long i=0;i,sizeof(qVertex),1,file1); } void Q2BSP::LoadEdgeLump() { fseek(file1,header.lump[11].offset,SEEK_SET); num_edges=header.lump[11].length/sizeof(qEdge); edgearray = new qEdge[num_edges]; for(unsigned long i=0;i

Share this post


Link to post
Share on other sites