| 1 | #ifndef __VBSP_DATA_H_ |
|---|
| 2 | #define __VBSP_DATA_H_ |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | #include <osg/Vec3f> |
|---|
| 6 | #include <osg/StateSet> |
|---|
| 7 | #include <osg/Referenced> |
|---|
| 8 | #include <string> |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | namespace bsp |
|---|
| 12 | { |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | struct Plane |
|---|
| 16 | { |
|---|
| 17 | osg::Vec3f plane_normal; |
|---|
| 18 | float origin_dist; |
|---|
| 19 | int type; |
|---|
| 20 | }; |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | struct Edge |
|---|
| 24 | { |
|---|
| 25 | unsigned short vertex[2]; |
|---|
| 26 | }; |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | struct Face |
|---|
| 30 | { |
|---|
| 31 | unsigned short plane_index; |
|---|
| 32 | unsigned char plane_side; |
|---|
| 33 | unsigned char on_node; |
|---|
| 34 | int first_edge; |
|---|
| 35 | short num_edges; |
|---|
| 36 | short texinfo_index; |
|---|
| 37 | short dispinfo_index; |
|---|
| 38 | short surface_fog_volume_id; |
|---|
| 39 | unsigned char styles[4]; |
|---|
| 40 | int light_offset; |
|---|
| 41 | float face_area; |
|---|
| 42 | int lightmap_texture_mins_in_luxels[2]; |
|---|
| 43 | int lightmap_texture_size_in_luxels[2]; |
|---|
| 44 | int original_face; |
|---|
| 45 | unsigned short num_primitives; |
|---|
| 46 | unsigned short first_primitive_id; |
|---|
| 47 | unsigned int smoothing_groups; |
|---|
| 48 | }; |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | struct Model |
|---|
| 52 | { |
|---|
| 53 | osg::Vec3f bound_min; |
|---|
| 54 | osg::Vec3f bound_max; |
|---|
| 55 | osg::Vec3f model_origin; |
|---|
| 56 | int head_node; |
|---|
| 57 | int first_face; |
|---|
| 58 | int num_faces; |
|---|
| 59 | }; |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | struct StaticPropV4 |
|---|
| 63 | { |
|---|
| 64 | osg::Vec3f prop_origin; |
|---|
| 65 | osg::Vec3f prop_angles; |
|---|
| 66 | unsigned short prop_type; |
|---|
| 67 | unsigned short first_leaf; |
|---|
| 68 | unsigned short leaf_count; |
|---|
| 69 | unsigned char prop_solid; |
|---|
| 70 | unsigned char prop_flags; |
|---|
| 71 | unsigned int prop_skin; |
|---|
| 72 | float min_fade_dist; |
|---|
| 73 | float max_fade_dist; |
|---|
| 74 | |
|---|
| 75 | osg::Vec3f lighting_origin; |
|---|
| 76 | }; |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | struct StaticProp |
|---|
| 80 | { |
|---|
| 81 | osg::Vec3f prop_origin; |
|---|
| 82 | osg::Vec3f prop_angles; |
|---|
| 83 | unsigned short prop_type; |
|---|
| 84 | unsigned short first_leaf; |
|---|
| 85 | unsigned short leaf_count; |
|---|
| 86 | unsigned char prop_solid; |
|---|
| 87 | unsigned char prop_flags; |
|---|
| 88 | unsigned int prop_skin; |
|---|
| 89 | float min_fade_dist; |
|---|
| 90 | float max_fade_dist; |
|---|
| 91 | |
|---|
| 92 | osg::Vec3f lighting_origin; |
|---|
| 93 | float forced_fade_scale; |
|---|
| 94 | }; |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | struct TexInfo |
|---|
| 98 | { |
|---|
| 99 | float texture_vecs[2][4]; |
|---|
| 100 | float lightmap_vecs[2][4]; |
|---|
| 101 | int texture_flags; |
|---|
| 102 | int texdata_index; |
|---|
| 103 | }; |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | struct TexData |
|---|
| 107 | { |
|---|
| 108 | osg::Vec3f texture_reflectivity; |
|---|
| 109 | int name_string_table_id; |
|---|
| 110 | int texture_width; |
|---|
| 111 | int texture_height; |
|---|
| 112 | int view_width; |
|---|
| 113 | int view_height; |
|---|
| 114 | }; |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | struct DisplaceSubNeighbor |
|---|
| 118 | { |
|---|
| 119 | unsigned short neighbor_index; |
|---|
| 120 | unsigned char neighbor_orient; |
|---|
| 121 | unsigned char local_span; |
|---|
| 122 | unsigned char neighbor_span; |
|---|
| 123 | }; |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | struct DisplaceNeighbor |
|---|
| 127 | { |
|---|
| 128 | DisplaceSubNeighbor sub_neighbors[2]; |
|---|
| 129 | }; |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | struct DisplaceCornerNeighbor |
|---|
| 133 | { |
|---|
| 134 | unsigned short neighbor_indices[4]; |
|---|
| 135 | unsigned char neighbor_count; |
|---|
| 136 | }; |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | struct DisplaceInfo |
|---|
| 140 | { |
|---|
| 141 | osg::Vec3f start_position; |
|---|
| 142 | int disp_vert_start; |
|---|
| 143 | int disp_tri_start; |
|---|
| 144 | int power; |
|---|
| 145 | int min_tesselation; |
|---|
| 146 | float smooth_angle; |
|---|
| 147 | int surface_contents; |
|---|
| 148 | unsigned short map_face; |
|---|
| 149 | int lightmap_alpha_start; |
|---|
| 150 | int lightmap_sample_pos_start; |
|---|
| 151 | DisplaceNeighbor edge_neighbors[4]; |
|---|
| 152 | DisplaceCornerNeighbor corner_neighbors[4]; |
|---|
| 153 | unsigned int allowed_verts[10]; |
|---|
| 154 | }; |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | struct DisplacedVertex |
|---|
| 158 | { |
|---|
| 159 | osg::Vec3f displace_vec; |
|---|
| 160 | float displace_dist; |
|---|
| 161 | float alpha_blend; |
|---|
| 162 | }; |
|---|
| 163 | |
|---|
| 164 | |
|---|
| 165 | class VBSPData : public osg::Referenced |
|---|
| 166 | { |
|---|
| 167 | protected: |
|---|
| 168 | |
|---|
| 169 | typedef std::vector<std::string> EntityList; |
|---|
| 170 | EntityList entity_list; |
|---|
| 171 | |
|---|
| 172 | typedef std::vector<Model> ModelList; |
|---|
| 173 | ModelList model_list; |
|---|
| 174 | |
|---|
| 175 | typedef std::vector<Plane> PlaneList; |
|---|
| 176 | PlaneList plane_list; |
|---|
| 177 | |
|---|
| 178 | typedef std::vector<osg::Vec3f> VertexList; |
|---|
| 179 | VertexList vertex_list; |
|---|
| 180 | |
|---|
| 181 | typedef std::vector<Edge> EdgeList; |
|---|
| 182 | EdgeList edge_list; |
|---|
| 183 | |
|---|
| 184 | typedef std::vector<int> SurfEdgeList; |
|---|
| 185 | SurfEdgeList surface_edge_list; |
|---|
| 186 | |
|---|
| 187 | typedef std::vector<Face> FaceList; |
|---|
| 188 | FaceList face_list; |
|---|
| 189 | |
|---|
| 190 | typedef std::vector<TexInfo> TexInfoList; |
|---|
| 191 | TexInfoList texinfo_list; |
|---|
| 192 | |
|---|
| 193 | typedef std::vector<TexData> TexDataList; |
|---|
| 194 | TexDataList texdata_list; |
|---|
| 195 | |
|---|
| 196 | typedef std::vector<std::string> TexDataStringList; |
|---|
| 197 | TexDataStringList texdata_string_list; |
|---|
| 198 | |
|---|
| 199 | typedef std::vector<DisplaceInfo> DisplaceInfoList; |
|---|
| 200 | DisplaceInfoList dispinfo_list; |
|---|
| 201 | |
|---|
| 202 | typedef std::vector<DisplacedVertex> DisplacedVertexList; |
|---|
| 203 | DisplacedVertexList displaced_vertex_list; |
|---|
| 204 | |
|---|
| 205 | typedef std::vector<std::string> StaticPropModelList; |
|---|
| 206 | StaticPropModelList static_prop_model_list; |
|---|
| 207 | |
|---|
| 208 | typedef std::vector<StaticProp> StaticPropList; |
|---|
| 209 | StaticPropList static_prop_list; |
|---|
| 210 | |
|---|
| 211 | typedef std::vector< osg::ref_ptr<osg::StateSet> > StateSetList; |
|---|
| 212 | StateSetList state_set_list; |
|---|
| 213 | |
|---|
| 214 | virtual ~VBSPData(); |
|---|
| 215 | |
|---|
| 216 | public: |
|---|
| 217 | |
|---|
| 218 | VBSPData(); |
|---|
| 219 | |
|---|
| 220 | void addEntity(std::string & newEntity); |
|---|
| 221 | const int getNumEntities() const; |
|---|
| 222 | const std::string & getEntity(int index) const; |
|---|
| 223 | |
|---|
| 224 | void addModel(Model & newModel); |
|---|
| 225 | const int getNumModels() const; |
|---|
| 226 | const Model & getModel(int index) const; |
|---|
| 227 | |
|---|
| 228 | void addPlane(Plane & newPlane); |
|---|
| 229 | const int getNumPlanes() const; |
|---|
| 230 | const Plane & getPlane(int index) const; |
|---|
| 231 | |
|---|
| 232 | void addVertex(osg::Vec3f & newVertex); |
|---|
| 233 | const int getNumVertices() const; |
|---|
| 234 | const osg::Vec3f & getVertex(int index) const; |
|---|
| 235 | |
|---|
| 236 | void addEdge(Edge & newEdge); |
|---|
| 237 | const int getNumEdges() const; |
|---|
| 238 | const Edge & getEdge(int index) const; |
|---|
| 239 | |
|---|
| 240 | void addSurfaceEdge(int & newSurfEdge); |
|---|
| 241 | const int getNumSurfaceEdges() const; |
|---|
| 242 | const int getSurfaceEdge(int index) const; |
|---|
| 243 | |
|---|
| 244 | void addFace(Face & newFace); |
|---|
| 245 | const int getNumFaces() const; |
|---|
| 246 | const Face & getFace(int index) const; |
|---|
| 247 | |
|---|
| 248 | void addTexInfo(TexInfo & newTexInfo); |
|---|
| 249 | const int getNumTexInfos() const; |
|---|
| 250 | const TexInfo & getTexInfo(int index) const; |
|---|
| 251 | |
|---|
| 252 | void addTexData(TexData & newTexData); |
|---|
| 253 | const int getNumTexDatas() const; |
|---|
| 254 | const TexData & getTexData(int index) const; |
|---|
| 255 | |
|---|
| 256 | void addTexDataString(std::string & newTexDataString); |
|---|
| 257 | const int getNumTexDataStrings() const; |
|---|
| 258 | const std::string & getTexDataString(int index) const; |
|---|
| 259 | |
|---|
| 260 | void addDispInfo(DisplaceInfo & newDispInfo); |
|---|
| 261 | const int getNumDispInfos() const; |
|---|
| 262 | const DisplaceInfo & getDispInfo(int index) const; |
|---|
| 263 | |
|---|
| 264 | void addDispVertex(DisplacedVertex & newDispVert); |
|---|
| 265 | const int getNumDispVertices() const; |
|---|
| 266 | const DisplacedVertex & getDispVertex(int index) const; |
|---|
| 267 | |
|---|
| 268 | void addStaticPropModel(std::string & newModel); |
|---|
| 269 | const int getNumStaticPropModels() const; |
|---|
| 270 | const std::string & getStaticPropModel(int index) const; |
|---|
| 271 | |
|---|
| 272 | void addStaticProp(StaticPropV4 & newProp); |
|---|
| 273 | void addStaticProp(StaticProp & newProp); |
|---|
| 274 | const int getNumStaticProps() const; |
|---|
| 275 | const StaticProp & getStaticProp(int index) const; |
|---|
| 276 | |
|---|
| 277 | void addStateSet(osg::StateSet * stateSet); |
|---|
| 278 | const int getNumStateSets() const; |
|---|
| 279 | osg::StateSet * getStateSet(int index) const; |
|---|
| 280 | }; |
|---|
| 281 | |
|---|
| 282 | |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | #endif |
|---|