#ifndef ENTITY_H #define ENTITY_H #include #include #include "util.h" #include "oct.h" #include "view.h" using namespace std; struct entity_base { struct entity_base *parent; sector orig; vector o; box bbox; virtual void update (); virtual void show () { world.add (this); }; void hide (); void display (draw_context &ctx); virtual void draw (draw_context &ctx) = 0; entity_base (); virtual ~entity_base (); }; struct entity_container : entity_base, protected vector { void add (entity_base *e) { push_back (e); e->parent = this; update (); } void update (); void show (); void draw (draw_context &ctx); ~entity_container (); }; struct entity_filter : entity_base { protected: entity_base *e; public: void set (entity_base *e) { this->e = e; e->parent = this; update (); } void remove () { this->e->parent = 0; this->e = 0; } entity_base *content () { return e; }; void update (); void show (); void draw (draw_context &ctx); ~entity_filter (); }; struct entity : entity_filter { }; struct vertex1d { colour c; // colour point p; // vertex }; struct vertex2d { point p; // vertex vec3 n; // normal texc t; // texture vertex2d () { }; vertex2d (point p, vec3 n, texc t = texc()) : p(p), n(n), t(t) { }; }; struct entity_opengl : entity_base { GLuint list; entity_opengl (); ~entity_opengl (); }; template struct entity_opengl1d : entity_opengl, vector { void update (); void draw (draw_context &ctx); }; template struct entity_opengl2d : entity_opengl { material m; void set (const vector &v); void draw (draw_context &ctx); }; typedef entity_opengl1d entity_points; typedef entity_opengl1d entity_lines; typedef entity_opengl1d entity_line_strip; typedef entity_opengl1d entity_line_loop; typedef entity_opengl2d entity_triangles; typedef entity_opengl2d entity_triangle_strip; typedef entity_opengl2d entity_triangle_fan; typedef entity_opengl2d entity_quads; typedef entity_opengl2d entity_quad_strip; typedef entity_opengl2d entity_polygon; struct entity_transform : entity_filter { protected: matrix m; void renormalize (); public: entity_transform (); void update (); void show (); void draw (draw_context &ctx); void set_matrix (const matrix &xfrm); void update (const matrix &xfrm); }; struct entity_anim : entity_transform { GLfloat vx, vy, vz; void draw (draw_context &ctx); }; #endif