… | |
… | |
11 | |
11 | |
12 | using namespace std; |
12 | using namespace std; |
13 | |
13 | |
14 | struct entity_base { |
14 | struct entity_base { |
15 | struct entity_base *parent; |
15 | struct entity_base *parent; |
|
|
16 | sector orig; |
16 | vector<octant *> o; |
17 | vector<octant *> o; |
17 | box bbox; |
18 | box bbox; |
18 | |
19 | |
19 | virtual void update_bbox (); |
20 | virtual void update_bbox (); |
20 | virtual void show (const sector &sec) { }; |
21 | virtual void show () { world.add (orig, this); }; |
21 | void hide (); |
22 | void hide (); |
|
|
23 | void display (draw_context &ctx); |
22 | virtual void draw (draw_context &ctx) = 0; |
24 | virtual void draw (draw_context &ctx) = 0; |
23 | void try_draw (draw_context &ctx) { if (ctx.may_draw (this)) draw (ctx); } |
25 | |
|
|
26 | entity_base (); |
24 | virtual ~entity_base () |
27 | virtual ~entity_base (); |
25 | { |
|
|
26 | hide (); |
|
|
27 | }; |
|
|
28 | }; |
28 | }; |
29 | |
29 | |
30 | struct entity_container : entity_base, protected vector<entity_base *> { |
30 | struct entity_container : entity_base, protected vector<entity_base *> { |
31 | void add (entity_base *e) { push_back (e); e->parent = this; } |
31 | void add (entity_base *e) { push_back (e); e->parent = this; } |
32 | void update_bbox (); |
32 | void update_bbox (); |
33 | void show (const sector &sec); |
33 | void show (); |
34 | void draw (draw_context &ctx); |
34 | void draw (draw_context &ctx); |
35 | ~entity_container (); |
35 | ~entity_container (); |
36 | }; |
36 | }; |
37 | |
37 | |
38 | struct entity_filter : entity_base { |
38 | struct entity_filter : entity_base { |
… | |
… | |
53 | } |
53 | } |
54 | |
54 | |
55 | entity_base *content () { return e; }; |
55 | entity_base *content () { return e; }; |
56 | |
56 | |
57 | void update_bbox (); |
57 | void update_bbox (); |
58 | void show (const sector &sec); |
58 | void show (); |
59 | void draw (draw_context &ctx); |
59 | void draw (draw_context &ctx); |
60 | ~entity_filter (); |
60 | ~entity_filter (); |
61 | }; |
61 | }; |
62 | |
62 | |
63 | struct entity : entity_filter { |
63 | struct entity : entity_filter { |
64 | sector sec; |
|
|
65 | |
|
|
66 | void show (const sector &sec); |
|
|
67 | void show (); |
|
|
68 | void draw (draw_context &ctx); |
|
|
69 | }; |
64 | }; |
70 | |
65 | |
71 | #if 0 |
66 | #if 0 |
72 | struct entity_affine : entity_filter { |
67 | struct entity_affine : entity_filter { |
73 | GLfloat m[4][4]; |
68 | GLfloat m[4][4]; |
… | |
… | |
94 | }; |
89 | }; |
95 | |
90 | |
96 | template<GLenum type> |
91 | template<GLenum type> |
97 | struct entity_opengl1d : entity_opengl, vector<vertex1d> { |
92 | struct entity_opengl1d : entity_opengl, vector<vertex1d> { |
98 | void update_bbox (); |
93 | void update_bbox (); |
99 | void show (const sector &sec); |
|
|
100 | void draw (draw_context &ctx); |
94 | void draw (draw_context &ctx); |
101 | }; |
95 | }; |
102 | |
96 | |
103 | template<GLenum type> |
97 | template<GLenum type> |
104 | struct entity_opengl2d : entity_opengl, vector<vertex2d> { |
98 | struct entity_opengl2d : entity_opengl, vector<vertex2d> { |
105 | material m; |
99 | material m; |
106 | GLuint list; |
100 | GLuint list; |
107 | |
101 | |
108 | void update_bbox (); |
102 | void update_bbox (); |
109 | void show (const sector &sec); |
|
|
110 | void draw (draw_context &ctx); |
103 | void draw (draw_context &ctx); |
111 | |
104 | |
112 | entity_opengl2d () |
105 | entity_opengl2d () |
113 | : list(0) |
106 | : list(0) |
114 | { |
107 | { |