yeh i think there is a flag.. but i can't remember for the life of me..
i use mingw which is windows port of gcc..
try using
typedef struct {
/* stuff here */
}__attribute__((packed)) Tfoo;
on your structures.
Quake 3 BSP problem
If your Header struct is correct, then I don't see how this could be a padding issue:
struct DirEntry {
unsigned int offset; // 32 bit
unsigned int length; // 32 bit
};
struct Header {
char magic[4]; // 32 bit
unsigned int version; // 32 bit
DirEntry dir[17]; // 17 * 64 bit
};
So unless you are on a 64 bit machine...?
struct DirEntry {
unsigned int offset; // 32 bit
unsigned int length; // 32 bit
};
struct Header {
char magic[4]; // 32 bit
unsigned int version; // 32 bit
DirEntry dir[17]; // 17 * 64 bit
};
So unless you are on a 64 bit machine...?
I tried using the padding-attribute suggested by dev_null, but no dice.
I've checked my structs about 50 times, and they look like they should.
And i'm not on a 64-bit machine. I guess i'll go RTFM for gcc or something. :)
I've checked my structs about 50 times, and they look like they should.
And i'm not on a 64-bit machine. I guess i'll go RTFM for gcc or something. :)
very true.. was just a sugestion.. i got caught out when i did MD3 model loading.
couldn't remember if there was any funnys in the BSP format.
i think we need to see more code to help solve this problem.. :)
Here are my structure definitions. I'm sorry about weird naming and lack of comments, but i'm just doing this as a test. I've not yet implemented structs for the other data in the bsp file, I thought i'd begin with vertices and faces.
Do you see something I don't? :)
Do you see something I don't? :)
enum BspLumps{ ENTITIES = 0, TEXTURES, PLANES, NODES, LEAFS, LEAFFACES, LEAFBRUSHES, MODELS, BRUSHES, BRUSHSIDES, VERTICES, MESHVERTS, SHADERS, FACES, LIGHTMAPS, LIGHTVOLUMES, VISDATA, MAXLUMPS };typedef struct { char ID[4]; unsigned int Version;} BspHeader_t;typedef struct { unsigned int Offset; unsigned int Length;} BspLump_t;typedef struct { float Point[3]; float TexCoords[2]; float LightMapCoords[2]; float Normal[3]; char Color[4];} BspVertex_t;typedef struct { int TextureID; int Effect; int Type; int VertexIndex; int NumVerts; int MeshVertIndex; int NumMeshVerts; int LightmapID; int LMapCorner[2]; int LMapSize[2]; float LMapPos[3]; float LMapBitsets[2][3]; float VNormal[3]; int Size[2]; } BspFace_t;class CBsp{ public: CBsp(); ~CBsp(); bool LoadBSP(char *fileName); void DrawBSP(); private: BspVertex_t *Vertices; BspFace_t *Faces; int *MeshVertices; int NumVertices; int NumMeshVertices; int NumFaces; CTextureManager *TextureManager; CLogger *Logger;};
hmm... can't see anything there... though its starting to get late here.
might call it a night and have a closer look tomorrow (when my eyes aren't so saw)
:)
might call it a night and have a closer look tomorrow (when my eyes aren't so saw)
:)
Okay, now this is getting weird. I added a texture-struct and read these from the file. Now the program crashes again, and I get completely different values in the meshvertex indices. What could be causing this? I'm not even using the textures yet, I just read them. :(
[Edited by - crippeli on May 26, 2005 8:03:42 AM]
[Edited by - crippeli on May 26, 2005 8:03:42 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement