1
0
Fork 0
This commit is contained in:
MrDev023 2016-10-20 21:22:38 +02:00
parent 3f6ca06228
commit 719990fe39
5 changed files with 54 additions and 42 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
obj/*
main
main.exe

BIN
main

Binary file not shown.

Binary file not shown.

View file

@ -1,13 +1,7 @@
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <limits>
#include <algorithm>
using namespace std;
#include "raytracer.h"
using namespace std;
bool init(char* inputName, scene &myScene)
{
int nbMat, nbSphere, nbLight;

View file

@ -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 <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <limits>
#include <algorithm>
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<material> matTab;
std::vector<sphere> sphTab;
std::vector<light> 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<material> matTab;
vector<sphere> sphTab;
vector<light> lgtTab;
int sizex, sizey;
};
#endif