16 inline void progressBar( std::ostream& output,
17 const double currentValue,
const double maximumValue)
19 static const int PROGRESSBARWIDTH = 60;
20 static int myProgressBarRotation = 0;
21 static int myProgressBarCurrent = 0;
23 double fraction = currentValue /maximumValue;
26 int dotz =
static_cast<int>(floor(fraction * PROGRESSBARWIDTH));
27 if (dotz > PROGRESSBARWIDTH) dotz = PROGRESSBARWIDTH;
30 if (dotz == myProgressBarCurrent)
return;
31 myProgressBarCurrent = dotz;
32 myProgressBarRotation++;
38 for ( ; ii < dotz;ii++) output<<
"#";
40 for ( ; ii < PROGRESSBARWIDTH;ii++) output<<
" ";
41 static const char* rotation_string =
"|\\-/";
42 myProgressBarRotation %= 4;
43 output <<
"] " << rotation_string[myProgressBarRotation]
44 <<
" " << (int)(fraction*100)<<
"/100\r";
75 void setViewBox(
Point3 origin,
85 void setResolution(
int width,
int height )
95 std::cout <<
"Rendering into image ... might take a while." << std::endl;
97 for (
int y = 0; y < myHeight; ++y )
100 progressBar( std::cout, ty, 1.0 );
105 for (
int x = 0; x < myWidth; ++x )
108 Vector3 dir = (1.0f - tx) * dirL + tx * dirR;
111 image.
at( x, y ) = result.
clamp();
114 std::cout <<
"Done." << std::endl;
130 if ( ri >= 0.0f )
return result;
131 return Color( 1.0, 1.0, 1.0 );
Classe générique pour représenter des images 2D.
Value at(int i, int j) const
float Real
the type for representing a real number.
PointVector< Real, 3 > Point3
The type for representing a 3d vector;.
PointVector< Real, 3 > Vector3
The type for representing a 3d point.
Color & clamp()
Garantees that color channels are between 0 and 1.
This structure takes care of rendering a scene.
Scene * ptrScene
The scene to render.
Color trace(const Ray &ray)
Point3 myOrigin
The origin of the camera in space.
void render(Image2D< Color > &image, int max_depth)
The main rendering routine.
Real rayIntersection(const Ray &ray, GraphicalObject *&object, Point3 &p)