diff --git a/main.cpp b/main.cpp index 5eb62496578493add945984ae09b34bdd5b0841b..e32606afd5c64b0171138c25737558669e3ffd3e 100644 --- a/main.cpp +++ b/main.cpp @@ -164,7 +164,7 @@ int main() shapes[2] = new Quad(grey, Vector3f(width/2, height, depth/2), width, 0, depth); //plafond shapes[3] = new Quad(grey, Vector3f(0, height/2, depth/2), 0, height, depth); //mur droit shapes[4] = new Quad(grey, Vector3f(width/2, 0, depth/2), width, 0, depth); //sol - shapes[5] = new Quad(red, Vector3f(width/4, 20, depth-20), 40, 40, 40); //cube + shapes[5] = new Quad(red, Vector3f(50, 50, 50), 5, 5, 5); //cube shapes[6] = new Sphere(blue, Vector3f(3/4*width, 20, depth/2), 40); //sphere Camera camera(Vector3f(width/2, height/2, 0), Vector3f(0, 0, 1)); diff --git a/quad.cpp b/quad.cpp index a5189d2fd01ee2f5f79856f7ea5b15cfbce2d267..9c35b44f55ca7f35b939e61d39bb8491fef59af0 100644 --- a/quad.cpp +++ b/quad.cpp @@ -149,7 +149,7 @@ Ray3f Quad::reflect(const Ray3f ray) const if (t>0 && y5<=y && y<=y2 && z6<=z && z3<=z) { Vector3f hit = ray.origin() + t*ray.direction(); - Vector3f N = hit-origin_; + Vector3f N = Vector3f(1,0,0); N.normalize(); } } @@ -164,7 +164,7 @@ Ray3f Quad::reflect(const Ray3f ray) const if (t>0 && x4<=x && x<=x1 && z6<=z && z3<=z) { Vector3f hit = ray.origin() + t*ray.direction(); - Vector3f N = hit-origin_; + Vector3f N = Vector3f(0,1,0); N.normalize(); } } @@ -180,7 +180,7 @@ Ray3f Quad::reflect(const Ray3f ray) const if (t>0 && x4<=x && x<=x1 && y5<=y && y<=y2) { Vector3f hit = ray.origin() + t*ray.direction(); - Vector3f N = hit-origin_; + Vector3f N = Vector3f(0,0,1); N.normalize(); } } @@ -196,7 +196,7 @@ Ray3f Quad::reflect(const Ray3f ray) const if (t>0 && y5<=y && y<= y2 && z6<=z && z3<=z) { Vector3f hit = ray.origin() + t*ray.direction(); - Vector3f N = hit-origin_; + Vector3f N = Vector3f(-1,0,0); N.normalize(); } } @@ -212,7 +212,7 @@ Ray3f Quad::reflect(const Ray3f ray) const if (t>0 && x4<=x && x<=x1 && z6<=z && z3<=z) { Vector3f hit = ray.origin() + t*ray.direction(); - Vector3f N = hit-origin_; + Vector3f N = Vector3f(0,-1,0); N.normalize(); } } @@ -228,7 +228,7 @@ Ray3f Quad::reflect(const Ray3f ray) const if (t>0 && x4<=x && x<=x1 && y5<=y && y<=y2) { Vector3f hit = ray.origin() + t*ray.direction(); - Vector3f N = hit-origin_; + Vector3f N = Vector3f(0,0,-1); N.normalize(); } } diff --git a/ray3f.cpp b/ray3f.cpp index 6a1dcf9678319baba64049dfa7eb3faa1d291cef..5279ca7d370c8b42c8c7e65ad6ff4ceb905c495f 100644 --- a/ray3f.cpp +++ b/ray3f.cpp @@ -6,6 +6,7 @@ Ray3f::Ray3f(const Vector3f & ori, const Vector3f & dir) { origin_ = ori; direction_ = dir; + direction_.normalize(); }