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.13 by root, Mon Oct 4 02:06:57 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 {
81 GLuint list;
82
83 entity_opengl ();
84 ~entity_opengl ();
86}; 85};
87 86
88template<GLenum type> 87template<GLenum type>
89struct entity_opengl1d : entity_base, vector<vertex1d> { 88struct entity_opengl1d : entity_opengl, vector<vertex1d> {
90 void update_bbox (); 89 void update_bbox ();
91 void show (const sector &sec);
92 void draw (const draw_context &ctx); 90 void draw (draw_context &ctx);
93}; 91};
94 92
95template<GLenum type> 93template<GLenum type>
96struct entity_opengl2d : entity_base, vector<vertex2d> { 94struct entity_opengl2d : entity_opengl {
97 void update_bbox (); 95 material m;
98 void show (const sector &sec); 96
97 void set (const vector<vertex2d> &v);
99 void draw (const draw_context &ctx); 98 void draw (draw_context &ctx);
99
100}; 100};
101 101
102typedef entity_opengl1d<GL_POINTS> entity_points; 102typedef entity_opengl1d<GL_POINTS> entity_points;
103typedef entity_opengl1d<GL_LINES> entity_lines; 103typedef entity_opengl1d<GL_LINES> entity_lines;
104typedef entity_opengl1d<GL_LINE_STRIP> entity_line_strip; 104typedef entity_opengl1d<GL_LINE_STRIP> entity_line_strip;
108typedef entity_opengl2d<GL_TRIANGLE_FAN> entity_triangle_fan; 108typedef entity_opengl2d<GL_TRIANGLE_FAN> entity_triangle_fan;
109typedef entity_opengl2d<GL_QUADS> entity_quads; 109typedef entity_opengl2d<GL_QUADS> entity_quads;
110typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip; 110typedef entity_opengl2d<GL_QUAD_STRIP> entity_quad_strip;
111typedef entity_opengl2d<GL_POLYGON> entity_polygon; 111typedef entity_opengl2d<GL_POLYGON> entity_polygon;
112 112
113struct view { 113struct entity_transform : entity_filter {
114 point p; 114 gl_matrix m;
115 vec3 d, u;
116 float fov;
117 int w, h;
118 115
116 entity_transform ();
117
118 void update_bbox ();
119 void show ();
119 void draw (const draw_context &ctx); 120 void draw (draw_context &ctx);
121};
122
123struct entity_anim : entity_transform {
124 GLfloat vx, vy, vz;
125 void draw (draw_context &ctx);
120}; 126};
121 127
122#endif 128#endif
123 129
124 130

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines