… | |
… | |
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_bbox (); |
21 | virtual void show () { world.add (orig, 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 | |
26 | entity_base (); |
26 | entity_base (); |
… | |
… | |
61 | }; |
61 | }; |
62 | |
62 | |
63 | struct entity : entity_filter { |
63 | struct entity : entity_filter { |
64 | }; |
64 | }; |
65 | |
65 | |
66 | #if 0 |
|
|
67 | struct entity_affine : entity_filter { |
|
|
68 | GLfloat m[4][4]; |
|
|
69 | |
|
|
70 | void draw (draw_context &ctx); |
|
|
71 | }; |
|
|
72 | #endif |
|
|
73 | |
|
|
74 | struct vertex1d { |
66 | struct vertex1d { |
75 | colour c; // colour |
67 | colour c; // colour |
76 | point p; // vertex |
68 | point p; // vertex |
77 | }; |
69 | }; |
78 | |
70 | |
… | |
… | |
84 | vertex2d () { }; |
76 | vertex2d () { }; |
85 | vertex2d (point p, vec3 n, texc t = texc()) : p(p), n(n), t(t) { }; |
77 | vertex2d (point p, vec3 n, texc t = texc()) : p(p), n(n), t(t) { }; |
86 | }; |
78 | }; |
87 | |
79 | |
88 | struct entity_opengl : entity_base { |
80 | struct entity_opengl : entity_base { |
|
|
81 | GLuint list; |
|
|
82 | |
|
|
83 | entity_opengl (); |
|
|
84 | ~entity_opengl (); |
89 | }; |
85 | }; |
90 | |
86 | |
91 | template<GLenum type> |
87 | template<GLenum type> |
92 | struct entity_opengl1d : entity_opengl, vector<vertex1d> { |
88 | struct entity_opengl1d : entity_opengl, vector<vertex1d> { |
93 | void update_bbox (); |
89 | void update_bbox (); |
94 | void draw (draw_context &ctx); |
90 | void draw (draw_context &ctx); |
95 | }; |
91 | }; |
96 | |
92 | |
97 | template<GLenum type> |
93 | template<GLenum type> |
98 | struct entity_opengl2d : entity_opengl, vector<vertex2d> { |
94 | struct entity_opengl2d : entity_opengl { |
99 | material m; |
95 | material m; |
100 | GLuint list; |
|
|
101 | |
96 | |
102 | void update_bbox (); |
97 | void set (const vector<vertex2d> &v); |
103 | void draw (draw_context &ctx); |
98 | void draw (draw_context &ctx); |
104 | |
99 | |
105 | entity_opengl2d () |
|
|
106 | : list(0) |
|
|
107 | { |
|
|
108 | } |
|
|
109 | |
|
|
110 | ~entity_opengl2d () |
|
|
111 | { |
|
|
112 | if (list) |
|
|
113 | glDeleteLists (list, 1); |
|
|
114 | } |
|
|
115 | }; |
100 | }; |
116 | |
101 | |
117 | typedef entity_opengl1d<GL_POINTS> entity_points; |
102 | typedef entity_opengl1d<GL_POINTS> entity_points; |
118 | typedef entity_opengl1d<GL_LINES> entity_lines; |
103 | typedef entity_opengl1d<GL_LINES> entity_lines; |
119 | typedef entity_opengl1d<GL_LINE_STRIP> entity_line_strip; |
104 | typedef entity_opengl1d<GL_LINE_STRIP> entity_line_strip; |
… | |
… | |
123 | typedef entity_opengl2d<GL_TRIANGLE_FAN> entity_triangle_fan; |
108 | typedef entity_opengl2d<GL_TRIANGLE_FAN> entity_triangle_fan; |
124 | typedef entity_opengl2d<GL_QUADS> entity_quads; |
109 | typedef entity_opengl2d<GL_QUADS> entity_quads; |
125 | typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip; |
110 | typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip; |
126 | typedef entity_opengl2d<GL_POLYGON> entity_polygon; |
111 | typedef entity_opengl2d<GL_POLYGON> entity_polygon; |
127 | |
112 | |
|
|
113 | struct entity_transform : entity_filter { |
|
|
114 | gl_matrix m; |
|
|
115 | |
|
|
116 | entity_transform (); |
|
|
117 | |
|
|
118 | void update_bbox (); |
|
|
119 | void show (); |
|
|
120 | void draw (draw_context &ctx); |
|
|
121 | }; |
|
|
122 | |
|
|
123 | struct entity_anim : entity_transform { |
|
|
124 | GLfloat vx, vy, vz; |
|
|
125 | void draw (draw_context &ctx); |
|
|
126 | }; |
|
|
127 | |
128 | #endif |
128 | #endif |
129 | |
129 | |
130 | |
130 | |
131 | |
131 | |