ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/entity.h
(Generate patch)

Comparing libgender/entity.h (file contents):
Revision 1.8 by root, Sun Oct 3 05:10:45 2004 UTC vs.
Revision 1.13 by root, Mon Oct 4 02:06:57 2004 UTC

11 11
12using namespace std; 12using namespace std;
13 13
14struct entity_base { 14struct entity_base {
15 struct entity_base *parent; 15 struct entity_base *parent;
16 sector orig;
16 vector<octant *> o; 17 vector<octant *> o;
17 box bbox; 18 box bbox;
18 19
19 virtual void update_bbox (); 20 virtual void update_bbox ();
20 virtual void show (const sector &sec) { }; 21 virtual void show () { world.add (this); };
21 void hide (); 22 void hide ();
23 void display (draw_context &ctx);
22 virtual void draw (draw_context &ctx) = 0; 24 virtual void draw (draw_context &ctx) = 0;
23 void try_draw (draw_context &ctx) { if (ctx.may_draw (this)) draw (ctx); } 25
26 entity_base ();
24 virtual ~entity_base () 27 virtual ~entity_base ();
25 {
26 hide ();
27 };
28}; 28};
29 29
30struct entity_container : entity_base, protected vector<entity_base *> { 30struct 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) { push_back (e); e->parent = this; }
32 void update_bbox (); 32 void update_bbox ();
33 void show (const sector &sec); 33 void show ();
34 void draw (draw_context &ctx); 34 void draw (draw_context &ctx);
35 ~entity_container (); 35 ~entity_container ();
36}; 36};
37 37
38struct entity_filter : entity_base { 38struct entity_filter : entity_base {
53 } 53 }
54 54
55 entity_base *content () { return e; }; 55 entity_base *content () { return e; };
56 56
57 void update_bbox (); 57 void update_bbox ();
58 void show (const sector &sec); 58 void show ();
59 void draw (draw_context &ctx); 59 void draw (draw_context &ctx);
60 ~entity_filter (); 60 ~entity_filter ();
61}; 61};
62 62
63struct entity : entity_filter { 63struct entity : entity_filter {
64 sector sec;
65
66 void show (const sector &sec);
67 void show ();
68 void draw (draw_context &ctx);
69}; 64};
70
71#if 0
72struct entity_affine : entity_filter {
73 GLfloat m[4][4];
74
75 void draw (draw_context &ctx);
76};
77#endif
78 65
79struct vertex1d { 66struct vertex1d {
80 colour c; // colour 67 colour c; // colour
81 point p; // vertex 68 point p; // vertex
82}; 69};
89 vertex2d () { }; 76 vertex2d () { };
90 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) { };
91}; 78};
92 79
93struct entity_opengl : entity_base { 80struct entity_opengl : entity_base {
81 GLuint list;
82
83 entity_opengl ();
84 ~entity_opengl ();
94}; 85};
95 86
96template<GLenum type> 87template<GLenum type>
97struct entity_opengl1d : entity_opengl, vector<vertex1d> { 88struct entity_opengl1d : entity_opengl, vector<vertex1d> {
98 void update_bbox (); 89 void update_bbox ();
99 void show (const sector &sec);
100 void draw (draw_context &ctx); 90 void draw (draw_context &ctx);
101}; 91};
102 92
103template<GLenum type> 93template<GLenum type>
104struct entity_opengl2d : entity_opengl, vector<vertex2d> { 94struct entity_opengl2d : entity_opengl {
105 material m; 95 material m;
106 96
107 void update_bbox (); 97 void set (const vector<vertex2d> &v);
108 void show (const sector &sec);
109 void draw (draw_context &ctx); 98 void draw (draw_context &ctx);
99
110}; 100};
111 101
112typedef entity_opengl1d<GL_POINTS> entity_points; 102typedef entity_opengl1d<GL_POINTS> entity_points;
113typedef entity_opengl1d<GL_LINES> entity_lines; 103typedef entity_opengl1d<GL_LINES> entity_lines;
114typedef entity_opengl1d<GL_LINE_STRIP> entity_line_strip; 104typedef entity_opengl1d<GL_LINE_STRIP> entity_line_strip;
118typedef entity_opengl2d<GL_TRIANGLE_FAN> entity_triangle_fan; 108typedef entity_opengl2d<GL_TRIANGLE_FAN> entity_triangle_fan;
119typedef entity_opengl2d<GL_QUADS> entity_quads; 109typedef entity_opengl2d<GL_QUADS> entity_quads;
120typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip; 110typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip;
121typedef entity_opengl2d<GL_POLYGON> entity_polygon; 111typedef entity_opengl2d<GL_POLYGON> entity_polygon;
122 112
113struct 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
123struct entity_anim : entity_transform {
124 GLfloat vx, vy, vz;
125 void draw (draw_context &ctx);
126};
127
123#endif 128#endif
124 129
125 130
126 131

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines