… | |
… | |
6 | #include "oct.h" |
6 | #include "oct.h" |
7 | #include "view.h" |
7 | #include "view.h" |
8 | |
8 | |
9 | #include <GL/glext.h> |
9 | #include <GL/glext.h> |
10 | |
10 | |
|
|
11 | entity_base::entity_base () |
|
|
12 | { |
|
|
13 | orig.x = orig.y = orig.z = 0; |
|
|
14 | } |
|
|
15 | |
|
|
16 | entity_base::~entity_base () |
|
|
17 | { |
|
|
18 | hide (); |
|
|
19 | } |
|
|
20 | |
11 | void entity_base::update_bbox () |
21 | void entity_base::update_bbox () |
12 | { |
22 | { |
13 | if (parent) |
23 | if (parent) |
14 | parent->update_bbox (); |
24 | parent->update_bbox (); |
15 | } |
25 | } |
… | |
… | |
20 | (*i)->remove (this); |
30 | (*i)->remove (this); |
21 | |
31 | |
22 | o.clear (); |
32 | o.clear (); |
23 | } |
33 | } |
24 | |
34 | |
|
|
35 | void entity_base::display (draw_context &ctx) |
|
|
36 | { |
|
|
37 | if (ctx.may_draw (this)) |
|
|
38 | { |
|
|
39 | glPushMatrix (); |
|
|
40 | glTranslated (-orig.x, -orig.y, -orig.z); |
|
|
41 | draw (ctx); |
|
|
42 | glPopMatrix (); |
|
|
43 | } |
|
|
44 | } |
|
|
45 | |
|
|
46 | ///////////////////////////////////////////////////////////////////////////// |
|
|
47 | |
25 | void entity_filter::update_bbox () |
48 | void entity_filter::update_bbox () |
26 | { |
49 | { |
27 | bbox = e->bbox; |
50 | bbox = e->bbox; |
28 | entity_base::update_bbox (); |
51 | entity_base::update_bbox (); |
29 | } |
52 | } |
30 | |
53 | |
31 | void entity_filter::show (const sector &sec) |
54 | void entity_filter::show () |
32 | { |
55 | { |
33 | world.add (sec, this); |
56 | world.add (orig, this); |
34 | |
57 | |
35 | e->show (sec); |
58 | e->show (); |
36 | } |
59 | } |
37 | |
60 | |
38 | void entity_filter::draw (draw_context &ctx) |
61 | void entity_filter::draw (draw_context &ctx) |
39 | { |
62 | { |
40 | e->try_draw (ctx); |
63 | e->display (ctx); |
41 | } |
64 | } |
42 | |
65 | |
43 | entity_filter::~entity_filter () |
66 | entity_filter::~entity_filter () |
44 | { |
67 | { |
45 | delete e; |
68 | delete e; |
46 | } |
69 | } |
47 | |
70 | |
48 | void entity::show (const sector &sec) |
71 | ///////////////////////////////////////////////////////////////////////////// |
49 | { |
|
|
50 | show (); |
|
|
51 | } |
|
|
52 | |
|
|
53 | void entity::show () |
|
|
54 | { |
|
|
55 | e->show (this->sec); |
|
|
56 | } |
|
|
57 | |
|
|
58 | void entity::draw (draw_context &ctx) |
|
|
59 | { |
|
|
60 | glPushMatrix (); |
|
|
61 | glTranslated (-sec.x, -sec.y, -sec.z); |
|
|
62 | e->try_draw (ctx); |
|
|
63 | glPopMatrix (); |
|
|
64 | } |
|
|
65 | |
72 | |
66 | void entity_container::update_bbox () |
73 | void entity_container::update_bbox () |
67 | { |
74 | { |
68 | bbox.reset (); |
75 | bbox.reset (); |
69 | |
76 | |
… | |
… | |
72 | (*i)->update_bbox (); |
79 | (*i)->update_bbox (); |
73 | bbox.add ((*i)->bbox); |
80 | bbox.add ((*i)->bbox); |
74 | } |
81 | } |
75 | } |
82 | } |
76 | |
83 | |
77 | void entity_container::show (const sector &sec) |
84 | void entity_container::show () |
78 | { |
85 | { |
79 | world.add (sec, this); |
86 | world.add (orig, this); |
80 | |
87 | |
81 | for (iterator i = end (); i-- != begin (); ) |
88 | for (iterator i = end (); i-- != begin (); ) |
82 | (*i)->show (sec); |
89 | (*i)->show (); |
83 | } |
90 | } |
84 | |
91 | |
85 | void entity_container::draw (draw_context &ctx) |
92 | void entity_container::draw (draw_context &ctx) |
86 | { |
93 | { |
87 | for (iterator i = end (); i-- != begin (); ) |
94 | for (iterator i = end (); i-- != begin (); ) |
88 | (*i)->try_draw (ctx); |
95 | (*i)->display (ctx); |
89 | } |
96 | } |
90 | |
97 | |
91 | entity_container::~entity_container () |
98 | entity_container::~entity_container () |
92 | { |
99 | { |
93 | hide (); |
100 | hide (); |
… | |
… | |
95 | for (iterator i = end (); i-- != begin (); ) |
102 | for (iterator i = end (); i-- != begin (); ) |
96 | delete *i; |
103 | delete *i; |
97 | |
104 | |
98 | clear (); |
105 | clear (); |
99 | } |
106 | } |
|
|
107 | |
|
|
108 | ///////////////////////////////////////////////////////////////////////////// |
100 | |
109 | |
101 | template class entity_opengl1d<GL_POINTS>; |
110 | template class entity_opengl1d<GL_POINTS>; |
102 | template class entity_opengl1d<GL_LINES>; |
111 | template class entity_opengl1d<GL_LINES>; |
103 | template class entity_opengl1d<GL_LINE_STRIP>; |
112 | template class entity_opengl1d<GL_LINE_STRIP>; |
104 | template class entity_opengl1d<GL_LINE_LOOP>; |
113 | template class entity_opengl1d<GL_LINE_LOOP>; |
… | |
… | |
185 | } |
194 | } |
186 | |
195 | |
187 | glCallList (list); |
196 | glCallList (list); |
188 | } |
197 | } |
189 | |
198 | |
190 | template<GLenum type> |
|
|
191 | void entity_opengl1d<type>::show (const sector &sec) |
|
|
192 | { |
|
|
193 | world.add (sec, this); |
|
|
194 | } |
|
|
195 | |
199 | |
196 | template<GLenum type> |
|
|
197 | void entity_opengl2d<type>::show (const sector &sec) |
|
|
198 | { |
|
|
199 | world.add (sec, this); |
|
|
200 | } |
|
|
201 | |
200 | |
202 | |
|
|