--- libgender/entity.h 2004/10/03 03:17:09 1.6 +++ libgender/entity.h 2004/10/05 03:39:47 1.17 @@ -7,29 +7,37 @@ #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_bbox (); - virtual void show (const sector &sec) { }; + virtual void update (); + virtual void show () { world.add (this); }; void hide (); - virtual void draw (const draw_context &ctx) = 0; - virtual ~entity_base () - { - 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; } - void update_bbox (); - void show (const sector &sec); - void draw (const draw_context &ctx); + void add (entity_base *e) + { + push_back (e); + e->parent = this; + update (); + } + + void update (); + void show (); + void draw (draw_context &ctx); ~entity_container (); }; @@ -42,6 +50,7 @@ { this->e = e; e->parent = this; + update (); } void remove () @@ -52,22 +61,13 @@ entity_base *content () { return e; }; - void update_bbox (); - void show (const sector &sec); - void draw (const draw_context &ctx); + void update (); + void show (); + void draw (draw_context &ctx); ~entity_filter (); }; struct entity : entity_filter { - sector sec; - - void show (const sector &sec); - void show (); - void draw (const draw_context &ctx); -}; - -struct entity_affine : entity_filter { - //matrix m; }; struct vertex1d { @@ -85,22 +85,24 @@ }; struct entity_opengl : entity_base { + GLuint list; + + entity_opengl (); + ~entity_opengl (); }; template struct entity_opengl1d : entity_opengl, vector { - void update_bbox (); - void show (const sector &sec); - void draw (const draw_context &ctx); + void update (); + void draw (draw_context &ctx); }; template -struct entity_opengl2d : entity_opengl, vector { +struct entity_opengl2d : entity_opengl { material m; - void update_bbox (); - void show (const sector &sec); - void draw (const draw_context &ctx); + void set (const vector &v); + void draw (draw_context &ctx); }; typedef entity_opengl1d entity_points; @@ -114,13 +116,24 @@ typedef entity_opengl2d entity_quad_strip; typedef entity_opengl2d entity_polygon; -struct view { - point p; - vec3 d, u; - float fov; - int w, h; +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); +}; - void draw (const draw_context &ctx); +struct entity_anim : entity_transform { + GLfloat vx, vy, vz; + void draw (draw_context &ctx); }; #endif