00001
00002
00003 #ifndef __RT_RENDER_H
00004 #define __RT_RENDER_H
00005
00006 #include <esg/SceneGraphObject.h>
00007 #include <gra/framebuffer/FrameBuffer.h>
00008 #include <esg/Intersector.h>
00009 #include <gra/shader/Shader.h>
00010 #include <gra/render/Render.h>
00011 #include <esg/Intersector.h>
00012 #include <esg/explorer/RayIntExplorer.h>
00013
00014 using namespace esg;
00015
00016 namespace gra {
00017
00023 class GRA_EXPORT RTRender : public Render {
00024 public:
00025 enum PixelRend {
00026 CENTROID,
00027 CORNERS,
00028 CENTROID_AND_CORNERS,
00029 RANDOM,
00030 STRATIFIED_SAMPLING
00031 };
00032
00033 enum FBWriteMode {
00034 PER_PIXEL,
00035 PER_LINE
00036 };
00037
00038 protected:
00039 Intersector * _pIntersector;
00040 Color3f _background;
00041 PixelRend _pixelRendering;
00042 unsigned _raysPerPixel;
00043 FBWriteMode _fbWriteMode;
00044 unsigned _fbWriteElements;
00045
00046 protected:
00047 void _render_pixel_point(RayIntExplorer&,
00048 SceneGraphObject&,
00049 Shader&,
00050 const Vector3&,
00051 Vector3,
00052 Color3f&);
00053
00054 unsigned _render_pixel_centroid(RayIntExplorer&,
00055 SceneGraphObject&,
00056 Shader&,
00057 Camera&,
00058 const Vector3&,
00059 unsigned,
00060 unsigned,
00061 unsigned,
00062 unsigned,
00063 Color3f&);
00064
00065 unsigned _render_pixel_corners(RayIntExplorer&,
00066 SceneGraphObject&,
00067 Shader&,
00068 Camera&,
00069 const Vector3d&,
00070 const Vector3d&,
00071 const Vector3d&,
00072 unsigned,
00073 unsigned,
00074 unsigned,
00075 unsigned,
00076 Color3f*,
00077 Color3f&,
00078 Color3f&);
00079
00080 unsigned _render_pixel_randomly(RayIntExplorer&,
00081 SceneGraphObject&,
00082 Shader&,
00083 Camera&,
00084 const Vector3&,
00085 unsigned,
00086 unsigned,
00087 unsigned,
00088 unsigned,
00089 Color3f&);
00090
00091 unsigned _render_pixel_stratified(RayIntExplorer&,
00092 SceneGraphObject&,
00093 Shader&,
00094 Camera&,
00095 const Vector3d&,
00096 const Vector3d&,
00097 const Vector3d&,
00098 double,
00099 double,
00100 Color3f&);
00101
00108 virtual void _render (Shader& shader,
00109 FrameBuffer& fb,
00110 Camera& camera,
00111 Scene& scene);
00112
00113 public:
00123 RTRender (Intersector* i,
00124 int* setStopFlag,
00125 const Color3f& background = Color3f(.0,.0,.0),
00126 PixelRend pixelRend = CENTROID,
00127 unsigned raysPerPixel = 1,
00128 FBWriteMode fbWriteMode = PER_LINE,
00129 unsigned fbWriteElements = 1)
00130 : Render(setStopFlag),
00131 _pIntersector(i),
00132 _background(background),
00133 _pixelRendering(pixelRend),
00134 _raysPerPixel(raysPerPixel),
00135 _fbWriteMode(fbWriteMode),
00136 _fbWriteElements(fbWriteElements)
00137 {
00138 if (_fbWriteElements == 0) _fbWriteElements = 1;
00139 }
00140 };
00141
00142 }
00143
00144 #endif // __RT_RENDER_H