… | |
… | |
28 | |
28 | |
29 | ///////////////////////////////////////////////////////////////////////////// |
29 | ///////////////////////////////////////////////////////////////////////////// |
30 | |
30 | |
31 | const vec3 normalize (const vec3 &v) |
31 | const vec3 normalize (const vec3 &v) |
32 | { |
32 | { |
33 | GLfloat s = abs (v); |
33 | GLfloat s = norm (v); |
34 | |
34 | |
35 | if (!s) |
35 | if (!s) |
36 | return v; |
36 | return v; |
37 | |
37 | |
38 | s = 1. / s; |
38 | s = 1. / s; |
… | |
… | |
80 | GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c, s, c; |
80 | GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c, s, c; |
81 | |
81 | |
82 | s = (GLfloat) sinf (angle * DEG2RAD); |
82 | s = (GLfloat) sinf (angle * DEG2RAD); |
83 | c = (GLfloat) cosf (angle * DEG2RAD); |
83 | c = (GLfloat) cosf (angle * DEG2RAD); |
84 | |
84 | |
85 | const GLfloat mag = abs (axis); |
85 | const GLfloat mag = norm (axis); |
86 | |
86 | |
87 | if (mag <= 1.0e-4) |
87 | if (mag <= 1.0e-4) |
88 | return matrix (1); |
88 | return matrix (1); |
89 | |
89 | |
90 | matrix m; |
90 | matrix m; |
… | |
… | |
156 | ///////////////////////////////////////////////////////////////////////////// |
156 | ///////////////////////////////////////////////////////////////////////////// |
157 | |
157 | |
158 | plane::plane (GLfloat a, GLfloat b, GLfloat c, GLfloat d) |
158 | plane::plane (GLfloat a, GLfloat b, GLfloat c, GLfloat d) |
159 | : n (vec3 (a,b,c)) |
159 | : n (vec3 (a,b,c)) |
160 | { |
160 | { |
161 | GLfloat s = 1. / abs (n); |
161 | GLfloat s = 1. / norm (n); |
162 | |
162 | |
163 | n = n * s; |
163 | n = n * s; |
164 | this->d = d * s; |
164 | this->d = d * s; |
165 | } |
165 | } |
166 | |
166 | |
… | |
… | |
225 | |
225 | |
226 | void render_text (GLint x, GLint y, const char *str) |
226 | void render_text (GLint x, GLint y, const char *str) |
227 | { |
227 | { |
228 | glRasterPos2i (x, y); |
228 | glRasterPos2i (x, y); |
229 | |
229 | |
|
|
230 | #if 0 |
230 | while (!*str) |
231 | while (!*str) |
231 | glutBitmapCharacter (GLUT_BITMAP_HELVETICA_18, *str++); |
232 | glutBitmapCharacter (GLUT_BITMAP_HELVETICA_18, *str++); |
|
|
233 | #endif |
232 | } |
234 | } |
233 | |
235 | |
234 | namespace gl { |
236 | namespace gl { |
235 | |
237 | |
236 | void draw_box (const view &ctx, const sector &a, const sector &b) |
238 | void draw_bbox (const view &ctx, const sector &a, const sector &b) |
237 | { |
239 | { |
238 | static GLint verts[] = { |
240 | static GLint verts[] = { |
239 | 0x8000, 0x8004, 0x8006, 0x8002, // -x |
241 | 0x8000, 0x8004, 0x8006, 0x8002, // -x |
240 | 0x8001, 0x8003, 0x8007, 0x8005, // +x |
242 | 0x8001, 0x8003, 0x8007, 0x8005, // +x |
241 | 0x8000, 0x8001, 0x8005, 0x8004, // -y |
243 | 0x8000, 0x8001, 0x8005, 0x8004, // -y |
… | |
… | |
244 | 0x8004, 0x8005, 0x8007, 0x8006, // +z |
246 | 0x8004, 0x8005, 0x8007, 0x8006, // +z |
245 | 0 |
247 | 0 |
246 | }; |
248 | }; |
247 | |
249 | |
248 | glBegin (GL_QUADS); |
250 | glBegin (GL_QUADS); |
|
|
251 | point pa(a), pb(b); |
249 | |
252 | |
250 | for (GLint *v = verts; *v; v++) |
253 | for (GLint *v = verts; *v; v++) |
251 | { |
254 | { |
252 | GLint mask = *v; |
255 | GLint mask = *v; |
253 | |
256 | |
254 | glVertex3i (mask & 1 ? b.x : a.x, |
257 | glVertex3f (mask & 1 ? pb.x : pa.x, |
255 | mask & 2 ? b.y : a.y, |
258 | mask & 2 ? pb.y : pa.y, |
256 | mask & 4 ? b.z : a.z); |
259 | mask & 4 ? pb.z : pa.z); |
257 | } |
260 | } |
258 | |
261 | |
259 | glEnd (); |
262 | glEnd (); |
260 | } |
263 | } |
261 | |
264 | |