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

Comparing libgender/entity.h (file contents):
Revision 1.1 by root, Sat Oct 2 15:54:43 2004 UTC vs.
Revision 1.3 by root, Sun Oct 3 01:14:40 2004 UTC

19 soffs x, y, z; 19 soffs x, y, z;
20}; 20};
21 21
22struct point { 22struct point {
23 GLfloat x, y, z; 23 GLfloat x, y, z;
24
25 point () { };
26 point (GLfloat x, GLfloat y, GLfloat z) : x(x), y(y), z(z) { };
24}; 27};
25 28
26struct colour { 29struct colour {
27 GLfloat r, g, b; 30 GLfloat r, g, b;
31 colour (GLfloat r = 1., GLfloat g = 1., GLfloat b = 1.) : r(r), g(g), b(b) { };
28}; 32};
29 33
30struct vect { 34struct vec3 {
31 GLfloat x, y, z; 35 GLfloat x, y, z;
36 vec3 () { };
37 vec3 (GLfloat x, GLfloat y, GLfloat z) : x(x), y(y), z(z) { };
38
39 const vec3 operator -() const
40 { return vec3 (-x, -y, -z); }
32}; 41};
33 42
43const vec3 cross (const vec3 &a, const vec3 &b);
44GLfloat dot (const vec3 &a, const vec3 &b);
45
34struct texc { 46struct texc {
35 GLfloat u, v; 47 GLfloat s, t;
48 texc () { };
49 texc (GLfloat s, GLfloat t) : s(s), t(t) { };
36}; 50};
37 51
38struct box { 52struct box {
39 point a, b; 53 point a, b;
40 54
41 void reset () 55 void reset ()
42 { 56 {
43 a.x = a.y = a.z = GLFLOAT_MAX; 57 a = point (GLFLOAT_MAX, GLFLOAT_MAX, GLFLOAT_MAX);
44 b.x = b.y = b.z = GLFLOAT_MIN; 58 b = point (GLFLOAT_MIN, GLFLOAT_MIN, GLFLOAT_MIN);
45 } 59 }
46 60
47 void add (const box &o); 61 void add (const box &o);
48}; 62};
49 63
96 110
97struct entity : entity_filter { 111struct entity : entity_filter {
98 sector sec; 112 sector sec;
99 113
100 void show (const sector &sec); 114 void show (const sector &sec);
115 void show ();
101 void draw (); 116 void draw ();
102}; 117};
103 118
104struct entity_affine : entity_filter { 119struct entity_affine : entity_filter {
105 //matrix m; 120 //matrix m;
106}; 121};
107 122
108struct vertex1d { 123struct vertex1d {
109 point v; // vertex
110 colour c; // colour 124 colour c; // colour
125 point p; // vertex
111}; 126};
112 127
113struct vertex2d { 128struct vertex2d {
114 point v; // vertex
115 colour c; // colour 129 colour c; // colour
130 point p; // vertex
116 vect n; // normal 131 vec3 n; // normal
117 texc t; // texture 132 texc t; // texture
133
134 vertex2d () { };
135 vertex2d (colour c, point p, vec3 n, texc t = texc()) : c(c), p(p), n(n), t(t) { };
118}; 136};
119 137
120template<GLenum type> 138template<GLenum type>
121struct entity_opengl1d : entity_base, vector<vertex1d> { 139struct entity_opengl1d : entity_base, vector<vertex1d> {
122 void update_bbox (); 140 void update_bbox ();
131 void draw (); 149 void draw ();
132}; 150};
133 151
134typedef entity_opengl1d<GL_POINTS> entity_points; 152typedef entity_opengl1d<GL_POINTS> entity_points;
135typedef entity_opengl1d<GL_LINES> entity_lines; 153typedef entity_opengl1d<GL_LINES> entity_lines;
136typedef entity_opengl1d<GL_LINE_STRIP> entity_linestrip; 154typedef entity_opengl1d<GL_LINE_STRIP> entity_line_strip;
137typedef entity_opengl1d<GL_LINE_LOOP> entity_lineloop; 155typedef entity_opengl1d<GL_LINE_LOOP> entity_line_loop;
138typedef entity_opengl2d<GL_TRIANGLES> entity_triangles; 156typedef entity_opengl2d<GL_TRIANGLES> entity_triangles;
139typedef entity_opengl2d<GL_TRIANGLE_STRIP> entity_trianglestrip; 157typedef entity_opengl2d<GL_TRIANGLE_STRIP> entity_triangle_strip;
140typedef entity_opengl2d<GL_TRIANGLE_FAN> entity_trianglefan; 158typedef entity_opengl2d<GL_TRIANGLE_FAN> entity_triangle_fan;
141typedef entity_opengl2d<GL_QUADS> entity_quads; 159typedef entity_opengl2d<GL_QUADS> entity_quads;
142typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip; 160typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip;
143typedef entity_opengl2d<GL_POLYGON> entity_polygon; 161typedef entity_opengl2d<GL_POLYGON> entity_polygon;
162
163struct light {
164 point p;
165 colour c;
166 GLfloat intensity;
167 GLfloat radius;
168};
169
170struct draw_context {
171 enum { DEPTH, AMBIENT, LIGHTED } mode;
172 light *l;
173};
174
175struct view {
176 point p;
177 vec3 d, u;
178 float fov;
179 int w, h;
180
181 void draw (const draw_context &c);
182};
144 183
145#endif 184#endif
146 185
147 186
148 187

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines