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

Comparing libgender/entity.h (file contents):
Revision 1.5 by root, Sun Oct 3 02:38:33 2004 UTC vs.
Revision 1.11 by root, Sun Oct 3 22:46:03 2004 UTC

5 5
6#include <vector> 6#include <vector>
7 7
8#include "util.h" 8#include "util.h"
9#include "oct.h" 9#include "oct.h"
10#include "view.h"
10 11
11using namespace std; 12using namespace std;
12 13
13struct entity_base { 14struct entity_base {
14 struct entity_base *parent; 15 struct entity_base *parent;
16 sector orig;
15 vector<octant *> o; 17 vector<octant *> o;
16 box bbox; 18 box bbox;
17 19
18 virtual void update_bbox (); 20 virtual void update_bbox ();
19 virtual void show (const sector &sec) { }; 21 virtual void show () { world.add (this); };
20 void hide (); 22 void hide ();
23 void display (draw_context &ctx);
21 virtual void draw (const draw_context &ctx) = 0; 24 virtual void draw (draw_context &ctx) = 0;
25
26 entity_base ();
22 virtual ~entity_base () 27 virtual ~entity_base ();
23 {
24 hide ();
25 };
26}; 28};
27 29
28struct entity_container : entity_base, protected vector<entity_base *> { 30struct entity_container : entity_base, protected vector<entity_base *> {
29 void add (entity_base *e) { push_back (e); e->parent = this; } 31 void add (entity_base *e) { push_back (e); e->parent = this; }
30 void update_bbox (); 32 void update_bbox ();
31 void show (const sector &sec); 33 void show ();
32 void draw (const draw_context &ctx); 34 void draw (draw_context &ctx);
33 ~entity_container (); 35 ~entity_container ();
34}; 36};
35 37
36struct entity_filter : entity_base { 38struct entity_filter : entity_base {
37protected: 39protected:
51 } 53 }
52 54
53 entity_base *content () { return e; }; 55 entity_base *content () { return e; };
54 56
55 void update_bbox (); 57 void update_bbox ();
56 void show (const sector &sec); 58 void show ();
57 void draw (const draw_context &ctx); 59 void draw (draw_context &ctx);
58 ~entity_filter (); 60 ~entity_filter ();
59}; 61};
60 62
61struct entity : entity_filter { 63struct entity : entity_filter {
62 sector sec;
63
64 void show (const sector &sec);
65 void show ();
66 void draw (const draw_context &ctx);
67};
68
69struct entity_affine : entity_filter {
70 //matrix m;
71}; 64};
72 65
73struct vertex1d { 66struct vertex1d {
74 colour c; // colour 67 colour c; // colour
75 point p; // vertex 68 point p; // vertex
76}; 69};
77 70
78struct vertex2d { 71struct vertex2d {
79 colour c; // colour
80 point p; // vertex 72 point p; // vertex
81 vec3 n; // normal 73 vec3 n; // normal
82 texc t; // texture 74 texc t; // texture
83 75
84 vertex2d () { }; 76 vertex2d () { };
85 vertex2d (colour c, point p, vec3 n, texc t = texc()) : c(c), p(p), n(n), t(t) { }; 77 vertex2d (point p, vec3 n, texc t = texc()) : p(p), n(n), t(t) { };
78};
79
80struct entity_opengl : entity_base {
86}; 81};
87 82
88template<GLenum type> 83template<GLenum type>
89struct entity_opengl1d : entity_base, vector<vertex1d> { 84struct entity_opengl1d : entity_opengl, vector<vertex1d> {
90 void update_bbox (); 85 void update_bbox ();
91 void show (const sector &sec);
92 void draw (const draw_context &ctx); 86 void draw (draw_context &ctx);
93}; 87};
94 88
95template<GLenum type> 89template<GLenum type>
96struct entity_opengl2d : entity_base, vector<vertex2d> { 90struct entity_opengl2d : entity_opengl, vector<vertex2d> {
91 material m;
92 GLuint list;
93
97 void update_bbox (); 94 void update_bbox ();
98 void show (const sector &sec);
99 void draw (const draw_context &ctx); 95 void draw (draw_context &ctx);
96
97 entity_opengl2d ()
98 : list(0)
99 {
100 }
101
102 ~entity_opengl2d ()
103 {
104 if (list)
105 glDeleteLists (list, 1);
106 }
100}; 107};
101 108
102typedef entity_opengl1d<GL_POINTS> entity_points; 109typedef entity_opengl1d<GL_POINTS> entity_points;
103typedef entity_opengl1d<GL_LINES> entity_lines; 110typedef entity_opengl1d<GL_LINES> entity_lines;
104typedef entity_opengl1d<GL_LINE_STRIP> entity_line_strip; 111typedef entity_opengl1d<GL_LINE_STRIP> entity_line_strip;
108typedef entity_opengl2d<GL_TRIANGLE_FAN> entity_triangle_fan; 115typedef entity_opengl2d<GL_TRIANGLE_FAN> entity_triangle_fan;
109typedef entity_opengl2d<GL_QUADS> entity_quads; 116typedef entity_opengl2d<GL_QUADS> entity_quads;
110typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip; 117typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip;
111typedef entity_opengl2d<GL_POLYGON> entity_polygon; 118typedef entity_opengl2d<GL_POLYGON> entity_polygon;
112 119
113struct view { 120struct entity_transform : entity_filter {
114 point p; 121 gl_matrix m;
115 vec3 d, u;
116 float fov;
117 int w, h;
118 122
123 entity_transform ();
124
125 void update_bbox ();
126 void show ();
119 void draw (const draw_context &ctx); 127 void draw (draw_context &ctx);
120}; 128};
121 129
122#endif 130#endif
123 131
124 132

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines