1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
#ifndef Q3BSPLOAD_H
#define Q3BSPLOAD_H
#include <osg/Vec3f>
#include <osg/GL>
#include <vector>
#include <string>
#include <fstream>
namespace bsp
{
//Directory entry in header
class BSP_DIRECTORY_ENTRY
{
public:
int m_offset;
int m_length;
};
//Types of directory entry
enum BSP_DIRECTORY_ENTRY_TYPE
{
bspEntities=0,
bspTextures,
bspPlanes,
bspNodes,
bspLeaves,
bspLeafFaces,
bspLeafBrushes,
bspModels,
bspBrushes,
bspBrushSides,
bspVertices,
bspMeshIndices,
bspEffect,
bspFaces,
bspLightmaps,
bspLightVols,
bspVisData
};
//BSP file header
class BSP_HEADER
{
public:
char m_string[4];
int m_version;
BSP_DIRECTORY_ENTRY m_directoryEntries[17];
};
//vertex as found in file
class BSP_LOAD_VERTEX
{
public:
osg::Vec3f m_position;
float m_decalS, m_decalT;
float m_lightmapS, m_lightmapT;
osg::Vec3f m_normal;
unsigned char m_color[4];
};
struct BSP_LoadPlane
{
osg::Vec3f m_Normal;
float m_Dist;
};
//face as found in the file
class BSP_LOAD_FACE
{
public:
int m_texture;
int m_effect; // No se usa
int m_type;
int m_firstVertexIndex;
int m_numVertices;
unsigned int m_firstMeshIndex;
unsigned int m_numMeshIndices;
int m_lightmapIndex;
int m_lightmapStart[2]; // No se usa
int m_lightmapSize[2]; // No se usa
//VECTOR3D m_lightmapOrigin; // No se usa
//VECTOR3D m_sTangent, m_tTangent; // No se usa
//VECTOR3D m_normal; // No se usa
osg::Vec3f m_lightmapOrigin; // No se usa
osg::Vec3f m_sTangent, m_tTangent; // No se usa
osg::Vec3f m_normal; // No se usa
int m_patchSize[2];
};
//texture as found in file
class BSP_LOAD_TEXTURE
{
public:
char m_name[64];
int m_flags, m_contents; //unknown, no se usa
};
//lightmap as found in file
class BSP_LOAD_LIGHTMAP
{
public:
unsigned char m_lightmapData[128*128*3];
};
//leaf of bsp tree as found in file
class BSP_LOAD_LEAF
{
public:
int m_cluster; //cluster index for visdata
int m_area; //areaportal area, No se usa
int m_mins[3]; //min x,y,z (bounding box)
int m_maxs[3];
int m_firstLeafFace; //first index in leafFaces array
int m_numFaces;
int m_firstLeafBrush; //first index into leaf brushes array, No se usa
int m_numBrushes; // No se usa
};
//node of BSP tree
class BSP_NODE
{
public:
int m_planeIndex;
int m_front, m_back; //child nodes
int m_mins[3]; //min x,y,z (bounding box) No se usa
int m_maxs[3]; // No se usa
};
//VIS data table
class BSP_VISIBILITY_DATA
{
public:
int m_numClusters;
int m_bytesPerCluster;
std::vector<unsigned char> m_bitset;
};
class Q3BSPLoad
{
public:
bool Load(const std::string& filename, int curveTessellation);
void LoadVertices(std::ifstream& aFile);
void LoadFaces(std::ifstream& aFile, int curveTessellation);
void LoadTextures(std::ifstream& aFile);
void LoadLightmaps(std::ifstream& aFile);
void LoadBSPData(std::ifstream& aFile);
std::string m_entityString;
//header
BSP_HEADER m_header;
// Load Data
std::vector<BSP_LOAD_VERTEX> m_loadVertices;
std::vector<GLuint> m_loadMeshIndices;
std::vector<BSP_LOAD_FACE> m_loadFaces;
std::vector<BSP_LOAD_TEXTURE> m_loadTextures;
std::vector<BSP_LOAD_LIGHTMAP> m_loadLightmaps;
std::vector<BSP_LOAD_LEAF> m_loadLeaves;
std::vector<int> m_loadLeafFaces;
std::vector<BSP_LoadPlane> m_loadPlanes;
std::vector<BSP_NODE> m_loadNodes;
BSP_VISIBILITY_DATA m_loadVisibilityData;
};
}
#endif // Q3BSPLOAD_H
|