sources:


website:
more info here


screenshot:
studies/grafik2/Computergrafik-Code6/Aufgabe17/cgraytracer.h
download file

  1 #ifndef CG_HEIGHTFIELD_H
  2 #define CG_HEIGHTFIELD_H
  3
  4 #include "util.h"
  5 #include "cgapplication.h"
  6 #include <time.h>
  7
  8 // Ray Tracer Class
  9 class CGRayTracer : public CGApplication {
 10 public:
 11
 12     // CGRayTracer, ~CGRayTracer
 13     CGRayTracer(unsigned int x, unsigned int y);
 14     virtual ~CGRayTracer();
 15
 16     virtual void onInit();
 17     virtual void onDraw();       
 18     virtual void onIdle();
 19     virtual void onKey(unsigned char key);   
 20     virtual void onSize(unsigned int newWidth, unsigned int newHeight);
 21    
 22     // createImage
 23     void createImage(int width, int height);
 24     void writeImage(char* fileName);
 25
 26     // use shadows
 27     bool shadows_;
 28     // max recursion depth
 29     int maxDepth_;
 30     int nTests_;
 31
 32 private:             
 33     // phongIlluminationColor
 34     Color phongIlluminationColor(
 35         const Vector& point,
 36         const Vector& normal,
 37         Material* material)
;
 38
 39     // writePPMPixel
 40     void writePPMPixel(const Color& c);
 41
 42     // rayTrace
 43     Color rayTrace(const Ray& r, int nDepth=1);
 44
 45     // add an object to the scene
 46     void AddObject(Shape* shape, Material* material);
 47
 48     // shape and material array
 49     int shapeSize_;
 50     Shape** shape_;
 51     Material** material_;
 52
 53     // light array
 54     int lightSize_;
 55     Light** light_;
 56
 57     // camera
 58     Camera* camera_;
 59
 60     // dimension of viewport
 61     int width_;
 62     int height_;
 63
 64     // memory buffer
 65     unsigned int imagex_, imagey_;
 66     Color* image_;
 67     int detail_;
 68     bool antialias_;
 69
 70     // file
 71     ofstream* out_;
 72
 73     // timer
 74     clock_t start_;
 75 };
 76
 77 #endif // CG_HeightField_H
 78
 79
 80