src/rcrt/tracing/SuperMetaTracer.cpp

Go to the documentation of this file.
00001 #include "SuperMetaTracer.h"
00002 
00003 namespace rcrt
00004 {
00005 
00006 SuperMetaTracer::SuperMetaTracer(TracingStrategy* trac):TracingStrategy(trac->getScene()),tracer(trac)
00007 {
00008 }
00009 
00010 SuperMetaTracer::~SuperMetaTracer()
00011 {
00012 }
00013 
00014 
00015 RGBColor SuperMetaTracer::trace(Ray& r) const
00016 {
00017         return tracer->trace(r);
00018 }
00019 
00020 Image SuperMetaTracer::trace(Camera* cam, const int& x0, const int& y0,
00021                 const int& x1, const int& y1) const
00022 {
00023         //do simple 4 sample rotated grid sampling
00024         int resX = x1-x0+1;
00025         int resY = y1-y0+1;
00026         float triangles = 0;
00027         Image img(resX, resY);
00028 
00029         for(int x=x0; x <= x1; x++){
00030                 for(int y=y0; y <= y1; y++){
00031                         // primary ray to trace
00032                 Ray ray1 = cam->getRay(Point2D(x+0.125,y+0.375));
00033                 Ray ray2 = cam->getRay(Point2D(x+0.625,y+0.125));
00034                 Ray ray3 = cam->getRay(Point2D(x+0.875,y+0.625));
00035                 Ray ray4 = cam->getRay(Point2D(x+0.375,y+0.875));
00036                 // ray trace the scene
00037                 const RGBColor col1(tracer->trace(ray1));
00038                 const RGBColor col2(tracer->trace(ray2));
00039                 const RGBColor col3(tracer->trace(ray3));
00040                 const RGBColor col4(tracer->trace(ray4));
00041                 
00042                 const RGBColor avg(((col1 + col2 + col3 + col4) / 4).clamped());
00043                 
00044                 img.setPixel(avg, x-x0, y-y0);
00045 
00046                 triangles += ray1.tris + ray2.tris + ray3.tris + ray4.tris;
00047                 }
00048         }
00049         
00050         float triPray = triangles/(resX*resY*4);
00051         std::cout << "        average Triangle-Intersections per ray: " << triPray << std::endl;
00052         return img;
00053         
00054 }
00055 
00056 }

Generated on Thu Jan 31 19:26:20 2008 for RenderingCompetitionRayTracer by  doxygen 1.5.3