Original Post
I''ve tried to look up some stuff on BSP''s but I must admit I''m having some trouble understanding them... particularly how to handle textures and such. This is the basic data structure I have so far... (listed backwards just to make it easier to understand)
typedef struct tagBSPobject
{
BSPNODE *Root;
short VertexCount;
VERTEX *Vertex;
short NormalCount;
NORMAL *Normal;
BYTE MaterialCount;
MATERIAL *Material;
} BSPobject;
// The vertex, normal, and material stuff are the actual vertices, materials, and normals. The triangle type is where the faces are and they have indices that point to the vertices, materials, and normals here
typedef struct tagBSPNODE
{
TRIANGLE *Divider;
TRIANGLE *List;
BSPNODE *Front;
BSPNODE *Back;
} BSPNODE;
typedef struct tagCOLORMATERIAL
{
float r, b, g, a;
} COLORMATERIAL;
typedef struct tagMATERIAL
{
COLORMATERIAL Ambient, Diffuse, Emissive, Specular;
float Shininess;
float Transparancy;
unsigned int TextureID;
unsigned int LightmapID;
} MATERIAL;
typedef struct tagVERTEX
{
float x, y, z;
float u , v;
} VERTEX;
typedef struct tagNORMAL
{
float x, y, z;
} NORMAL;
typedef struct tagTRIANLGE
{
short v1, v2, v3;
short n1, n2, n3;
} TRIANGLE;
Now, the way I understand it is that the BSP nodes have the face information, and each node only has the face whose plane is used to divide the other faces, and therefore it would also be drawn. where a node doesn''t have a divider it becomes a leaf and it has more than one face in the list and all those are drawn.
But how would I handle textures? My models all have seperate meshes, each mesh has a material assigned to it, each material having a texture and a lightmap... It doesn''t make sense to have a different tree for each mesh, but then I have no idea what to do with textures if everything is thrown together in one tree...
I''d appreciate any suggestions anyone might have.
------------
- outRider -