--- libgender/entity.h 2004/10/03 22:46:03 1.11 +++ libgender/entity.h 2004/10/04 23:44:53 1.16 @@ -17,7 +17,7 @@ vector o; box bbox; - virtual void update_bbox (); + virtual void update (); virtual void show () { world.add (this); }; void hide (); void display (draw_context &ctx); @@ -28,8 +28,14 @@ }; struct entity_container : entity_base, protected vector { - void add (entity_base *e) { push_back (e); e->parent = this; } - void update_bbox (); + void add (entity_base *e) + { + push_back (e); + e->parent = this; + update (); + } + + void update (); void show (); void draw (draw_context &ctx); ~entity_container (); @@ -44,6 +50,7 @@ { this->e = e; e->parent = this; + update (); } void remove () @@ -54,7 +61,7 @@ entity_base *content () { return e; }; - void update_bbox (); + void update (); void show (); void draw (draw_context &ctx); ~entity_filter (); @@ -78,32 +85,24 @@ }; struct entity_opengl : entity_base { + GLuint list; + + entity_opengl (); + ~entity_opengl (); }; template struct entity_opengl1d : entity_opengl, vector { - void update_bbox (); + void update (); void draw (draw_context &ctx); }; template -struct entity_opengl2d : entity_opengl, vector { +struct entity_opengl2d : entity_opengl { material m; - GLuint list; - void update_bbox (); + void set (const vector &v); void draw (draw_context &ctx); - - entity_opengl2d () - : list(0) - { - } - - ~entity_opengl2d () - { - if (list) - glDeleteLists (list, 1); - } }; typedef entity_opengl1d entity_points; @@ -118,13 +117,23 @@ typedef entity_opengl2d entity_polygon; struct entity_transform : entity_filter { +protected: gl_matrix m; + void renormalize (); +public: entity_transform (); - void update_bbox (); + void update (); void show (); void draw (draw_context &ctx); + void set_matrix (const gl_matrix &xfrm); + void update (const gl_matrix &xfrm); +}; + +struct entity_anim : entity_transform { + GLfloat vx, vy, vz; + void draw (draw_context &ctx); }; #endif