00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef __GNUC__
00029 #pragma interface
00030 #endif
00031
00032 #ifndef _util_render_render_h
00033 #define _util_render_render_h
00034
00035 #include <util/class/class.h>
00036 #include <util/render/appearance.h>
00037 #include <util/render/material.h>
00038 #include <util/render/transform.h>
00039 #include <util/render/stack.h>
00040
00041 class RenderedObject;
00042 class AnimatedObject;
00043 class RenderedObjectSet;
00044 class RenderedSphere;
00045 class RenderedPolygons;
00046 class RenderedPolylines;
00047
00048 class Render: public DescribedClass {
00049 protected:
00050 Ref<Material> default_material_;
00051 Ref<Appearance> default_appearance_;
00052 Ref<Transform> default_transform_;
00053
00054 Stack<Ref<Material> > material_stack_;
00055 Stack<Ref<Appearance> > appearance_stack_;
00056 Stack<Ref<Transform> > transform_stack_;
00057
00058 virtual void push_material(const Ref<Material>& m);
00059 virtual void push_appearance(const Ref<Appearance>& a);
00060 virtual void push_transform(const Ref<Transform>& t);
00061 virtual Ref<Material> pop_material();
00062 virtual Ref<Appearance> pop_appearance();
00063 virtual Ref<Transform> pop_transform();
00064
00065 public:
00066 Render();
00067 Render(const Ref<KeyVal>&);
00068 virtual ~Render();
00069
00070 Ref<Material> default_material() { return default_material_; }
00071 Ref<Appearance> default_appearance() { return default_appearance_; }
00072 Ref<Transform> default_transform() { return default_transform_; }
00073 void default_material(const Ref<Material>& m) { default_material_ = m; }
00074 void default_appearance(const Ref<Appearance>& a) {default_appearance_ = a;}
00075 void default_transform(const Ref<Transform>& t) {default_transform_ = t;}
00076
00077 virtual void clear() = 0;
00078
00079 virtual void render(const Ref<RenderedObject>&);
00080 virtual void animate(const Ref<AnimatedObject> &);
00081
00082 virtual void set(const Ref<RenderedObjectSet>&);
00083 virtual void sphere(const Ref<RenderedSphere>&);
00084 virtual void polygons(const Ref<RenderedPolygons>&) = 0;
00085 virtual void polylines(const Ref<RenderedPolylines>&) = 0;
00086 };
00087
00088
00089 class FileRender: public Render {
00090 protected:
00091 char* filename_;
00092 char* basename_;
00093 std::streambuf *sbuf_;
00094 int delete_sbuf_;
00095 int depth_;
00096
00097 char *get_filename(const char *objectname);
00098 void open_sbuf(const char *objectname);
00099 void close_sbuf();
00100 public:
00101 FileRender(const char * filename);
00102 FileRender(std::ostream &o = ExEnv::out());
00103 FileRender(const Ref<KeyVal>&);
00104 virtual ~FileRender();
00105
00106 void clear();
00107
00108 virtual void set_filename(const char *name);
00109 virtual void set_basename(const char *name);
00110 virtual const char *file_extension();
00111 };
00112
00113
00114 #endif
00115
00116
00117
00118
00119