Skip to content
Extraits de code Groupes Projets
Valider dce4c08b rédigé par DBA_3's avatar DBA_3
Parcourir les fichiers

quad

parent 20110619
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -142,19 +142,28 @@ Ray3f Quad::reflect(const Ray3f ray) const
//Face 1
if(a!=0 && Vector3f(1,0,0)*ray.direction()<0)
{
std::cout<<"face 1"<<std::endl;
t = (x1 - X) / a ;
//x = X;
y = y + b*t;
y = Y + b*t;
z = Z + c*t;
if (y5<=y && y<=y2 && z6<=z && z<=z3)
{
std::cout<<"face 1.2"<<std::endl;
Vector3f hit = ray.origin() + t*ray.direction();
Vector3f N = Vector3f(0,1,0);
Vector3f N = Vector3f(1,0,0);
N.normalize();
return Ray3f(hit, I-(I*N)*N);
std::cout<< "vecteur (I*N) " <<I*N<< std::endl;
std::cout<< "vecteur (I*N)*N " <<(I*N)*N<< std::endl;
std::cout<< "vecteur I " <<I<< std::endl;
std::cout<< "vecteur N " <<N<< std::endl;
return Ray3f(hit, I-2*(I*N)*N);
}
}
......@@ -163,16 +172,20 @@ Ray3f Quad::reflect(const Ray3f ray) const
//Face 2
if(b!=0 && Vector3f(0,1,0)*ray.direction()<0)
{
std::cout<<"face 2"<<std::endl;
t = (y2 - Y) / b ;
x = X + a*t;
//y = y2;
z = Z + c*t;
if (x4<=x && x<=x1 && z6<=z && z<=z3)
{
std::cout<<"face 2.2"<<std::endl;
Vector3f hit = ray.origin() + t*ray.direction();
Vector3f N = Vector3f(0,1,0);
N.normalize();
return Ray3f(hit, I-(I*N)*N);
return Ray3f(hit, I-2*(I*N)*N);
}
}
......@@ -181,16 +194,19 @@ Ray3f Quad::reflect(const Ray3f ray) const
//Face 3
if(c!=0 && Vector3f(0,0,1)*ray.direction()<0)
{
std::cout<<"face 3"<<std::endl;
t = (z3 - Z) / c ;
x = X + a*t;
y = Y + b*t;
//z = z3;
if (x4<=x && x<=x1 && y5<=y && y<=y2)
{
std::cout<<"face 3.2"<<std::endl;
Vector3f hit = ray.origin() + t*ray.direction();
Vector3f N = Vector3f(0,0,1);
N.normalize();
return Ray3f(hit, I-(I*N)*N);
return Ray3f(hit, I-2*(I*N)*N);
}
}
......@@ -198,16 +214,18 @@ Ray3f Quad::reflect(const Ray3f ray) const
//Face 4
if(a!=0 && Vector3f(-1,0,0)*ray.direction()<0)
{
std::cout<<"face 4"<<std::endl;
t = (x4 - X) / a ;
//x = X;
y = y + b*t;
y = Y + b*t;
z = Z + c*t;
if (y5<=y && y<=y2 && z6<=z && z<=z3)
{
std::cout<<"face 4.2"<<std::endl;
Vector3f hit = ray.origin() + t*ray.direction();
Vector3f N = Vector3f(0,1,0);
Vector3f N = Vector3f(-1,0,0);
N.normalize();
return Ray3f(hit, I-(I*N)*N);
return Ray3f(hit, I-2*(I*N)*N);
}
}
......@@ -217,16 +235,18 @@ Ray3f Quad::reflect(const Ray3f ray) const
//Face 5
if(b!=0 && Vector3f(0,-1,0)*ray.direction()<0)
{
std::cout<<"face 5"<<std::endl;
t = (y5 - Y) / b ;
x = X + a*t;
//y = y5;
z = Z + c*t;
if (x4<=x && x<=x1 && z6<=z && z<=z3)
{
std::cout<<"face 5.2"<<std::endl;
Vector3f hit = ray.origin() + t*ray.direction();
Vector3f N = Vector3f(0,-1,0);
N.normalize();
return Ray3f(hit, I-(I*N)*N);
return Ray3f(hit, I-2*(I*N)*N);
}
}
......@@ -234,20 +254,23 @@ Ray3f Quad::reflect(const Ray3f ray) const
//Face 6
if(c!=0 && Vector3f(0,0,-1)*ray.direction()<0)
{
std::cout<<"face 6"<<std::endl;
t = (z6 - Z) / c ;
x = X + a*t;
y = Y + b*t;
//z = z6;
if (x4<=x && x<=x1 && y5<=y && y<=y2)
{
std::cout<<"face 6.2"<<std::endl;
Vector3f hit = ray.origin() + t*ray.direction();
Vector3f N = Vector3f(0,0,-1);
N.normalize();
return Ray3f(hit, I-(I*N)*N);
return Ray3f(hit, I-2*(I*N)*N);
}
}
return(Ray3f(Vector3f(0,0,0),Vector3f(1,0,0)));
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter