diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f5006b8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +obj/* +main +main.exe \ No newline at end of file diff --git a/main b/main deleted file mode 100755 index d665e19..0000000 Binary files a/main and /dev/null differ diff --git a/obj/main.o b/obj/main.o deleted file mode 100644 index 27b8fe6..0000000 Binary files a/obj/main.o and /dev/null differ diff --git a/src/main.cpp b/src/main.cpp index 6e487a3..7e16817 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,13 +1,7 @@ -#include -#include -#include -#include -#include -#include -using namespace std; - #include "raytracer.h" +using namespace std; + bool init(char* inputName, scene &myScene) { int nbMat, nbSphere, nbLight; diff --git a/src/raytracer.h b/src/raytracer.h index c8ff91d..3efc6d6 100644 --- a/src/raytracer.h +++ b/src/raytracer.h @@ -1,18 +1,53 @@ +#ifndef RAYTRACER_H +#define RAYTRACER_H - -struct point { - float x, y, z; -}; - -istream & operator >> ( istream &inputFile, point& p ) { - return inputFile >> p.x >> p.y >> p.z ; -} +#include +#include +#include +#include +#include +#include struct vecteur { float x, y, z; }; -istream & operator >> ( istream &inputFile, vecteur& v ) { +struct point { + float x, y, z; +}; + +struct ray { + point start; + vecteur dir; +}; + +struct material { + float red, green, blue, reflection; +}; + +struct sphere { + point pos; + float size; + int material; +}; + +struct light { + point pos; + float red, green, blue; +}; + +struct scene { + std::vector matTab; + std::vector sphTab; + std::vector lgtTab; + int sizex, sizey; +}; + +std::istream & operator >> ( std::istream &inputFile, point& p ) { + return inputFile >> p.x >> p.y >> p.z ; +} + +std::istream & operator >> ( std::istream &inputFile, vecteur& v ) { return inputFile >> v.x >> v.y >> v.z ; } @@ -46,38 +81,18 @@ float operator * (const vecteur&v1, const vecteur &v2 ) { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; } -struct material { - float red, green, blue, reflection; -}; -istream & operator >> ( istream &inputFile, material& mat ) { +std::istream & operator >> ( std::istream &inputFile, material& mat ) { return inputFile >> mat.red >> mat.green >> mat.blue >> mat.reflection; } -struct sphere { - point pos; - float size; - int material; -}; -istream & operator >> ( istream &inputFile, sphere& sph ) { +std::istream & operator >> ( std::istream &inputFile, sphere& sph ) { return inputFile >> sph.pos >> sph.size >> sph.material; } -struct light { - point pos; - float red, green, blue; -}; -istream & operator >> ( istream &inputFile, light& lig ) { +std::istream & operator >> ( std::istream &inputFile, light& lig ) { return inputFile >> lig.pos >> lig.red >> lig.green >> lig.blue; } -struct ray { - point start; - vecteur dir; -}; -struct scene { - vector matTab; - vector sphTab; - vector lgtTab; - int sizex, sizey; -}; \ No newline at end of file + +#endif \ No newline at end of file