1 | #ifndef ENTITY_H |
1 | #ifndef ENTITY_H |
2 | #define ENTITY_H |
2 | #define ENTITY_H |
3 | |
3 | |
4 | #include <vector> |
4 | #include <vector> |
5 | |
5 | |
|
|
6 | #include <iostream> |
6 | #include "opengl.h" |
7 | #include "opengl.h" |
7 | |
8 | |
8 | #include "util.h" |
9 | #include "util.h" |
9 | #include "oct.h" |
10 | #include "oct.h" |
10 | #include "view.h" |
11 | #include "view.h" |
… | |
… | |
77 | void set (); |
78 | void set (); |
78 | }; |
79 | }; |
79 | |
80 | |
80 | struct geometry_sphere : geometry |
81 | struct geometry_sphere : geometry |
81 | { |
82 | { |
|
|
83 | material *m; |
82 | GLfloat radius; |
84 | GLfloat radius; |
83 | |
85 | |
84 | void update (); |
86 | void update (); |
85 | void draw (view &ctx); |
87 | void draw (view &ctx); |
86 | geometry_sphere (GLfloat radius) : radius(radius) { update (); }; |
88 | geometry_sphere (material *m, GLfloat radius) : m(m), radius(radius) { update (); }; |
|
|
89 | }; |
|
|
90 | |
|
|
91 | struct geometry_indexed_2d : geometry |
|
|
92 | { |
|
|
93 | material *m; |
|
|
94 | |
|
|
95 | GLenum type; |
|
|
96 | |
|
|
97 | vertex_buffer vb; |
|
|
98 | index_buffer ib; |
|
|
99 | |
|
|
100 | void draw (view &ctx); |
|
|
101 | |
|
|
102 | template <typename vertex, typename index> |
|
|
103 | geometry_indexed_2d (material *m, GLenum type, const vector<vertex> &v, const vector<index> &i) |
|
|
104 | : m(m), type(type) |
|
|
105 | { |
|
|
106 | vb.set (v); |
|
|
107 | ib.set (i); |
|
|
108 | |
|
|
109 | bbox.reset (); |
|
|
110 | for (typename vector<vertex>::const_iterator i = v.begin () ; i != v.end (); ++i) |
|
|
111 | bbox.add (i->v); |
|
|
112 | } |
|
|
113 | |
87 | }; |
114 | }; |
88 | |
115 | |
89 | ///////////////////////////////////////////////////////////////////////////// |
116 | ///////////////////////////////////////////////////////////////////////////// |
90 | |
117 | |
91 | struct geometry_filter : geometry |
118 | struct geometry_filter : geometry |
… | |
… | |
156 | |
183 | |
157 | entity (geometry *g = 0); |
184 | entity (geometry *g = 0); |
158 | ~entity (); |
185 | ~entity (); |
159 | }; |
186 | }; |
160 | |
187 | |
161 | struct light : entity |
188 | struct entity_moveable : entity |
162 | { |
189 | { |
163 | point p; |
190 | vec3 v; |
164 | colour c; |
191 | entity_moveable (geometry *g = 0) : entity (g) { } |
165 | GLfloat intensity; |
192 | |
166 | GLfloat radius; |
193 | void perform_step (double t); |
|
|
194 | }; |
|
|
195 | |
|
|
196 | struct entity_light : entity |
|
|
197 | { |
|
|
198 | light *lview; |
|
|
199 | }; |
|
|
200 | |
|
|
201 | ///////////////////////////////////////////////////////////////////////////// |
|
|
202 | // not the final API(!) |
|
|
203 | |
|
|
204 | struct skybox |
|
|
205 | { |
|
|
206 | texture *tex[6]; |
|
|
207 | |
|
|
208 | skybox ( |
|
|
209 | const char *left, |
|
|
210 | const char *front, |
|
|
211 | const char *right, |
|
|
212 | const char *back, |
|
|
213 | const char *top, |
|
|
214 | const char *bottom |
|
|
215 | ); |
|
|
216 | |
|
|
217 | ~skybox (); |
|
|
218 | |
|
|
219 | void draw (view &ctx); |
167 | }; |
220 | }; |
168 | |
221 | |
169 | ///////////////////////////////////////////////////////////////////////////// |
222 | ///////////////////////////////////////////////////////////////////////////// |
170 | // |
223 | // |
171 | // VERY EXPERIMENTAL HEIGHTMAP |
224 | // VERY EXPERIMENTAL HEIGHTMAP |