… | |
… | |
15 | struct entity_base *parent; |
15 | struct entity_base *parent; |
16 | sector orig; |
16 | sector orig; |
17 | vector<octant *> o; |
17 | vector<octant *> o; |
18 | box bbox; |
18 | box bbox; |
19 | |
19 | |
20 | virtual void update_bbox (); |
20 | virtual void update (); |
21 | virtual void show () { world.add (this); }; |
21 | virtual void show () { world.add (this); }; |
22 | void hide (); |
22 | void hide (); |
23 | void display (draw_context &ctx); |
23 | void display (draw_context &ctx); |
24 | virtual void draw (draw_context &ctx) = 0; |
24 | virtual void draw (draw_context &ctx) = 0; |
25 | |
25 | |
… | |
… | |
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) |
31 | void add (entity_base *e) |
32 | { |
32 | { |
33 | push_back (e); |
33 | push_back (e); |
34 | e->parent = this; |
34 | e->parent = this; |
35 | update_bbox (); |
35 | update (); |
36 | } |
36 | } |
37 | |
37 | |
38 | void update_bbox (); |
38 | void update (); |
39 | void show (); |
39 | void show (); |
40 | void draw (draw_context &ctx); |
40 | void draw (draw_context &ctx); |
41 | ~entity_container (); |
41 | ~entity_container (); |
42 | }; |
42 | }; |
43 | |
43 | |
… | |
… | |
48 | |
48 | |
49 | void set (entity_base *e) |
49 | void set (entity_base *e) |
50 | { |
50 | { |
51 | this->e = e; |
51 | this->e = e; |
52 | e->parent = this; |
52 | e->parent = this; |
53 | update_bbox (); |
53 | update (); |
54 | } |
54 | } |
55 | |
55 | |
56 | void remove () |
56 | void remove () |
57 | { |
57 | { |
58 | this->e->parent = 0; |
58 | this->e->parent = 0; |
59 | this->e = 0; |
59 | this->e = 0; |
60 | } |
60 | } |
61 | |
61 | |
62 | entity_base *content () { return e; }; |
62 | entity_base *content () { return e; }; |
63 | |
63 | |
64 | void update_bbox (); |
64 | void update (); |
65 | void show (); |
65 | void show (); |
66 | void draw (draw_context &ctx); |
66 | void draw (draw_context &ctx); |
67 | ~entity_filter (); |
67 | ~entity_filter (); |
68 | }; |
68 | }; |
69 | |
69 | |
… | |
… | |
91 | ~entity_opengl (); |
91 | ~entity_opengl (); |
92 | }; |
92 | }; |
93 | |
93 | |
94 | template<GLenum type> |
94 | template<GLenum type> |
95 | struct entity_opengl1d : entity_opengl, vector<vertex1d> { |
95 | struct entity_opengl1d : entity_opengl, vector<vertex1d> { |
96 | void update_bbox (); |
96 | void update (); |
97 | void draw (draw_context &ctx); |
97 | void draw (draw_context &ctx); |
98 | }; |
98 | }; |
99 | |
99 | |
100 | template<GLenum type> |
100 | template<GLenum type> |
101 | struct entity_opengl2d : entity_opengl { |
101 | struct entity_opengl2d : entity_opengl { |
… | |
… | |
115 | typedef entity_opengl2d<GL_QUADS> entity_quads; |
115 | typedef entity_opengl2d<GL_QUADS> entity_quads; |
116 | typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip; |
116 | typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip; |
117 | typedef entity_opengl2d<GL_POLYGON> entity_polygon; |
117 | typedef entity_opengl2d<GL_POLYGON> entity_polygon; |
118 | |
118 | |
119 | struct entity_transform : entity_filter { |
119 | struct entity_transform : entity_filter { |
|
|
120 | protected: |
120 | gl_matrix m; |
121 | gl_matrix m; |
|
|
122 | void renormalize (); |
|
|
123 | public: |
121 | |
124 | |
122 | entity_transform (); |
125 | entity_transform (); |
123 | |
126 | |
124 | void update_bbox (); |
127 | void update (); |
125 | void show (); |
128 | void show (); |
126 | void draw (draw_context &ctx); |
129 | void draw (draw_context &ctx); |
|
|
130 | void set_matrix (const gl_matrix &xfrm); |
|
|
131 | void update (const gl_matrix &xfrm); |
127 | }; |
132 | }; |
128 | |
133 | |
129 | struct entity_anim : entity_transform { |
134 | struct entity_anim : entity_transform { |
130 | GLfloat vx, vy, vz; |
135 | GLfloat vx, vy, vz; |
131 | void draw (draw_context &ctx); |
136 | void draw (draw_context &ctx); |