… | |
… | |
26 | entity_base (); |
26 | entity_base (); |
27 | virtual ~entity_base (); |
27 | virtual ~entity_base (); |
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) |
|
|
32 | { |
|
|
33 | push_back (e); |
|
|
34 | e->parent = this; |
|
|
35 | update_bbox (); |
|
|
36 | } |
|
|
37 | |
32 | void update_bbox (); |
38 | void update_bbox (); |
33 | void show (); |
39 | void show (); |
34 | void draw (draw_context &ctx); |
40 | void draw (draw_context &ctx); |
35 | ~entity_container (); |
41 | ~entity_container (); |
36 | }; |
42 | }; |
… | |
… | |
42 | |
48 | |
43 | void set (entity_base *e) |
49 | void set (entity_base *e) |
44 | { |
50 | { |
45 | this->e = e; |
51 | this->e = e; |
46 | e->parent = this; |
52 | e->parent = this; |
|
|
53 | update_bbox (); |
47 | } |
54 | } |
48 | |
55 | |
49 | void remove () |
56 | void remove () |
50 | { |
57 | { |
51 | this->e->parent = 0; |
58 | this->e->parent = 0; |
… | |
… | |
76 | vertex2d () { }; |
83 | vertex2d () { }; |
77 | vertex2d (point p, vec3 n, texc t = texc()) : p(p), n(n), t(t) { }; |
84 | vertex2d (point p, vec3 n, texc t = texc()) : p(p), n(n), t(t) { }; |
78 | }; |
85 | }; |
79 | |
86 | |
80 | struct entity_opengl : entity_base { |
87 | struct entity_opengl : entity_base { |
|
|
88 | GLuint list; |
|
|
89 | |
|
|
90 | entity_opengl (); |
|
|
91 | ~entity_opengl (); |
81 | }; |
92 | }; |
82 | |
93 | |
83 | template<GLenum type> |
94 | template<GLenum type> |
84 | struct entity_opengl1d : entity_opengl, vector<vertex1d> { |
95 | struct entity_opengl1d : entity_opengl, vector<vertex1d> { |
85 | void update_bbox (); |
96 | void update_bbox (); |
86 | void draw (draw_context &ctx); |
97 | void draw (draw_context &ctx); |
87 | }; |
98 | }; |
88 | |
99 | |
89 | template<GLenum type> |
100 | template<GLenum type> |
90 | struct entity_opengl2d : entity_opengl, vector<vertex2d> { |
101 | struct entity_opengl2d : entity_opengl { |
91 | material m; |
102 | material m; |
92 | GLuint list; |
|
|
93 | |
103 | |
94 | void update_bbox (); |
104 | void set (const vector<vertex2d> &v); |
95 | void draw (draw_context &ctx); |
105 | void draw (draw_context &ctx); |
96 | |
|
|
97 | entity_opengl2d () |
|
|
98 | : list(0) |
|
|
99 | { |
|
|
100 | } |
|
|
101 | |
|
|
102 | ~entity_opengl2d () |
|
|
103 | { |
|
|
104 | if (list) |
|
|
105 | glDeleteLists (list, 1); |
|
|
106 | } |
|
|
107 | }; |
106 | }; |
108 | |
107 | |
109 | typedef entity_opengl1d<GL_POINTS> entity_points; |
108 | typedef entity_opengl1d<GL_POINTS> entity_points; |
110 | typedef entity_opengl1d<GL_LINES> entity_lines; |
109 | typedef entity_opengl1d<GL_LINES> entity_lines; |
111 | typedef entity_opengl1d<GL_LINE_STRIP> entity_line_strip; |
110 | typedef entity_opengl1d<GL_LINE_STRIP> entity_line_strip; |
… | |
… | |
125 | void update_bbox (); |
124 | void update_bbox (); |
126 | void show (); |
125 | void show (); |
127 | void draw (draw_context &ctx); |
126 | void draw (draw_context &ctx); |
128 | }; |
127 | }; |
129 | |
128 | |
|
|
129 | struct entity_anim : entity_transform { |
|
|
130 | GLfloat vx, vy, vz; |
|
|
131 | void draw (draw_context &ctx); |
|
|
132 | }; |
|
|
133 | |
130 | #endif |
134 | #endif |
131 | |
135 | |
132 | |
136 | |
133 | |
137 | |