00001 // Filename: ribGraphicsWindow.h 00002 // Created by: drose (15Feb99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #ifndef RIBGRAPHICSWINDOW_H 00020 #define RIBGRAPHICSWINDOW_H 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // 00024 // A RIBGraphicsWindow, instead of actually being a window on some 00025 // raster display device, instead represents a file (or sequence of 00026 // files) on disk that will be filled with a RIB scene description 00027 // when the scene is "rendered" to the window. This RIB may 00028 // subsequently be used as input to a standalone renderer such as 00029 // prman or BMRT to generate one or more images. 00030 // 00031 // The output RIB filename as specified to the window is actually a 00032 // filename template, and may contain any of the following: 00033 // 00034 // %f This stands for the current frame number. The frame number 00035 // starts counting at zero when the window is created and 00036 // increments by one each time a frame is rendered. An optional 00037 // field width may appear after the %, printf-style. 00038 // 00039 // %t This stands for the window title. 00040 // 00041 // %% This stands for a single percent sign. 00042 // 00043 // If the RIB filename contains %f, a separate RIB file is generated 00044 // for each frame rendered; otherwise, all frames are written into a 00045 // single multi-frame RIB file. 00046 // 00047 // 00048 // The image filename may also be specified. If specified, a 00049 // "Display" command is written to the RIB file to output the image to 00050 // the indicated filename. If unspecified or empty, the "Display" 00051 // command is not written, and the renderer chooses the output 00052 // filename. The image filename may also contain any of the % 00053 // sequences described above. 00054 // 00055 //////////////////////////////////////////////////////////////////// 00056 00057 00058 #include <pandabase.h> 00059 00060 #include <graphicsWindow.h> 00061 #include <filename.h> 00062 00063 class RIBGraphicsPipe; 00064 00065 00066 //////////////////////////////////////////////////////////////////// 00067 // Class : RIBGraphicsWindow 00068 // Description : Represents a specific RIB file (or sequence of files) 00069 // that can be "rendered" to. Rendering to a RIB file 00070 // means writing out a scene description to the file. 00071 // 00072 // The filename of the RIB file is initially taken from 00073 // the name of the RIBGraphicsPipe used to create the 00074 // window, but it may subsequently be changed via 00075 // set_rib_filename_template(). The filename may 00076 // contain any of the % sequences described above. 00077 //////////////////////////////////////////////////////////////////// 00078 class RIBGraphicsWindow : public GraphicsWindow { 00079 public: 00080 00081 RIBGraphicsWindow(GraphicsPipe *pipe); 00082 RIBGraphicsWindow(GraphicsPipe *pipe, 00083 const GraphicsWindow::Properties &props); 00084 virtual ~RIBGraphicsWindow(void); 00085 00086 INLINE void set_rib_filename_template(const string &str); 00087 INLINE string get_rib_filename_template() const; 00088 INLINE string get_rib_filename() const; 00089 INLINE bool rib_per_frame() const; 00090 00091 INLINE void set_image_filename_template(const string &str); 00092 INLINE string get_image_filename_template() const; 00093 INLINE string get_image_filename() const; 00094 INLINE bool image_per_frame() const; 00095 00096 INLINE void set_texture_directory(const string &directory); 00097 INLINE string get_texture_directory() const; 00098 INLINE void set_texture_extension(const string &extension); 00099 INLINE string get_texture_extension() const; 00100 00101 void flush_file(); 00102 00103 virtual void begin_frame(); 00104 virtual void end_frame(); 00105 00106 virtual void make_current(void); 00107 virtual void unmake_current(void); 00108 00109 virtual TypeHandle get_gsg_type() const; 00110 static GraphicsWindow* make_RibGraphicsWindow(const FactoryParams ¶ms); 00111 00112 protected: 00113 void setup_window(GraphicsPipe *pipe); 00114 00115 void begin_file(); 00116 void end_file(); 00117 00118 string format_name(const string &name_template) const; 00119 static string format_integer(const string &format_spec, int number); 00120 static string format_string(const string &format_spec, const string &str); 00121 00122 static bool check_per_frame(const string &name_template); 00123 00124 string _rib_filename_template; 00125 string _image_filename_template; 00126 bool _rib_per_frame; 00127 bool _image_per_frame; 00128 00129 bool _file_begun; 00130 Filename _current_rib_filename; 00131 ofstream _file; 00132 00133 public: 00134 00135 static TypeHandle get_class_type(void); 00136 static void init_type(void); 00137 virtual TypeHandle get_type(void) const; 00138 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00139 00140 private: 00141 00142 static TypeHandle _type_handle; 00143 }; 00144 00145 #include "ribGraphicsWindow.I" 00146 00147 #endif