altEngine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bsp.h
Go to the documentation of this file.
1 #include "include.h"
2 
3 #ifndef BSP_H
4 #define BSP_H
5 
6 class mLight2;
7 
8 class Bsp
9 {
10  void change_axis();
11  inline int find_leaf(const vec3 &position);
12  void sort_leaf(vector<int> *leaf_list, int node_index, const vec3 &position, leaf_t *frameLeaf, bool order);
13  inline int cluster_visible(int visCluster, int testCluster);
14  void tessellate(int level, bspvertex_t control[], vertex_t **vertex_array, int &numVerts,
15  int **index_array, int &numIndexes, vec2 &texcoord, vec2 &lightcoord, vec2 &size);
16  inline void render_face(face_t *face, Graphics &gfx, int stage, bool lightmap, bool shader);
17  inline void render_patch(face_t *face, Graphics &gfx, int stage, bool lightmap, bool shader);
18  inline void render_billboard(face_t *face, Graphics &gfx, int stage, bool lightmap, bool shader);
19  void gen_renderlists(int leaf, vector<surface_t *> &surface_list, vec3 &position);
20  void add_list(vector<surface_t *> &surface_list, bool blend_flag, int i);
21  void set_blend_mode(Graphics &gfx, faceinfo_t &face);
22  void set_tcmod(mLight2 &mlight2, faceinfo_t &face, int tick_num, float time);
23  //void draw_line_box(int *min, int *max);
24  //void draw_box(int *min, int *max);
25 public:
26  Bsp();
27  void CreateShadowVolumes(Graphics &gfx, vec3 &light_pos, int current_light, vertex_t *shadow_vertex, unsigned int *shadow_index, int &num_index);
28  void hitscan(vec3 &origin, vec3 &dir, float &distance);
29  bool is_point_in_brush(int brush_index, vec3 &point, vec3 &oldpoint, float *depth, plane_t *plane, content_flag_t &flag, float &water_depth, bool debug);
30  bool vis_test(vec3 &x, vec3 &y, int &leaf_a, int &leaf_b);
31  bool leaf_test(vec3 &x, vec3 &y);
32  void generate_meshes(Graphics &gfx);
33  const char *get_entities();
34  void render(vec3 &position, Graphics &gfx, vector<surface_t *> &surface_list, mLight2 &mlight2, int tick_num);
35  void render_model(unsigned int index, Graphics &gfx);
36  void render_sky(Graphics &gfx, mLight2 &mlight2, int tick_num, vector<surface_t *> surface_list);
37  vec3 model_origin(unsigned int index);
38 
39  bool load(char *map, char **pk3list, int num_pk3);
40  void load_textures(Graphics &gfx, vector<surface_t *> &surface_list, char **pk3_list, int num_pk3, int anisotropic);
41  void load_from_shader(char *name, vector<surface_t *> &surface_list, texture_t *texObj, Graphics &gfx, char **pk3_list, int num_pk3, int anisotropic);
42  void load_from_file(char *filename, texture_t &texObj, Graphics &gfx, char **pk3_list, int num_pk3, int anisotropic);
43 
44 
45  void unload(Graphics &gfx);
46  void CalculateTangentArray(bspvertex_t *vertex, int num_vert, int *index, int num_index, vec4 *tangent);
47  void CreateTangentArray(vertex_t *vertex, bspvertex_t *bsp_vertex, int num_vert, vec4 *tangent);
48 
49  bool collision_detect(vec3 &point, vec3 &oldpoint, plane_t *plane, float *depth, float &water_depth,
50  vector<surface_t *> &surface_list, bool debug, vec3 &clip, const vec3 &velocity, int &model_trigger, int &model_platform, content_flag_t &flag);
51 
52 
53  vec3 trace(vec3 &start, vec3 &end, vec3 &normal);
54  void check_node(int node_index, float start_amount, float end_amount, vec3 &start, vec3 &end);
55  void check_brush(brush_t *brush, vec3 &start, vec3 &end);
56 
57  bool on_ground;
58  bool collision;
60  float trace_result;
61 
62 
63  bool loaded;
64  bool quake1;
66  char map_name[64];
69 
70  unsigned int skybox_index;
71  unsigned int skybox_vertex;
74 
75  vector<faceinfo_t> face_list; // sorted front to back
76  vector<faceinfo_t> blend_list; // sorted back to front
79  int lastIndex;
80 
81  int model_type[128];
85 
86  unsigned int portal_tex; // hack
87 
88  bool enable_fog;
93  bool enable_sky;
95  unsigned int max_stage;
96 private:
99 
101 
102 // int last_leaf;
103 
104  // keeping this around because it seems like data.vertex is getting corrupted.
106 
107  //for bezier patches
111 
112  //gpu objects
113  unsigned int map_index_vbo;
114  unsigned int map_vertex_vbo;
115 
118  int sky_face;
119 };
120 
121 #endif