Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
P
PAP_ray_tracing
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Déploiement
Releases
Registre de conteneurs
Registre de modèles
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Yacine ACHEROUFKEBIR
PAP_ray_tracing
Validations
4ed3602c
Valider
4ed3602c
rédigé
Il y a 5 ans
par
DBA_3
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
is_hit
parent
902290eb
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
quad.cpp
+47
-27
47 ajouts, 27 suppressions
quad.cpp
avec
47 ajouts
et
27 suppressions
quad.cpp
+
47
−
27
Voir le fichier @
4ed3602c
#include
"quad.h"
#include
"quad.h"
#include
<iostream>
Quad
::
Quad
(
Material
matter
,
Vector3f
origin
,
float
width
,
float
height
,
float
depth
)
:
Shape
(
matter
)
Quad
::
Quad
(
Material
matter
,
Vector3f
origin
,
float
width
,
float
height
,
float
depth
)
:
Shape
(
matter
)
...
@@ -42,7 +44,7 @@ bool Quad::is_hit(const Ray3f ray)
...
@@ -42,7 +44,7 @@ bool Quad::is_hit(const Ray3f ray)
//x = x1;
//x = x1;
y
=
Y
+
b
*
t
;
y
=
Y
+
b
*
t
;
z
=
Z
+
c
*
t
;
z
=
Z
+
c
*
t
;
if
(
t
>
0
&&
y5
<=
y
&&
y
<=
y2
&&
z6
<=
z
&&
z
3
<=
z
)
if
(
Vector3f
(
1
,
0
,
0
)
*
ray
.
direction
()
<
0
&&
t
>
0
&&
y5
<=
y
&&
y
<=
y2
&&
z6
<=
z
&&
z
<=
z
3
)
return
true
;
return
true
;
}
}
...
@@ -53,7 +55,7 @@ bool Quad::is_hit(const Ray3f ray)
...
@@ -53,7 +55,7 @@ bool Quad::is_hit(const Ray3f ray)
x
=
X
+
a
*
t
;
x
=
X
+
a
*
t
;
//y = y2;
//y = y2;
z
=
Z
+
c
*
t
;
z
=
Z
+
c
*
t
;
if
(
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
z6
<=
z
&&
z
3
<=
z
)
if
(
Vector3f
(
0
,
1
,
0
)
*
ray
.
direction
()
<
0
&&
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
z6
<=
z
&&
z
<=
z
3
)
return
true
;
return
true
;
}
}
...
@@ -65,7 +67,7 @@ bool Quad::is_hit(const Ray3f ray)
...
@@ -65,7 +67,7 @@ bool Quad::is_hit(const Ray3f ray)
x
=
X
+
a
*
t
;
x
=
X
+
a
*
t
;
y
=
Y
+
b
*
t
;
y
=
Y
+
b
*
t
;
//z = z3;
//z = z3;
if
(
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
y5
<=
y
&&
y
<=
y2
)
if
(
Vector3f
(
0
,
0
,
1
)
*
ray
.
direction
()
<
0
&&
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
y5
<=
y
&&
y
<=
y2
)
return
true
;
return
true
;
}
}
...
@@ -77,7 +79,7 @@ bool Quad::is_hit(const Ray3f ray)
...
@@ -77,7 +79,7 @@ bool Quad::is_hit(const Ray3f ray)
//x = x4;
//x = x4;
y
=
Y
+
b
*
t
;
y
=
Y
+
b
*
t
;
z
=
Z
+
c
*
t
;
z
=
Z
+
c
*
t
;
if
(
t
>
0
&&
y5
<=
y
&&
y
<=
y2
&&
z6
<=
z
&&
z
3
<=
z
)
if
(
Vector3f
(
-
1
,
0
,
0
)
*
ray
.
direction
()
<
0
&&
t
>
0
&&
y5
<=
y
&&
y
<=
y2
&&
z6
<=
z
&&
z
<=
z
3
)
return
true
;
return
true
;
}
}
...
@@ -89,7 +91,7 @@ bool Quad::is_hit(const Ray3f ray)
...
@@ -89,7 +91,7 @@ bool Quad::is_hit(const Ray3f ray)
x
=
X
+
a
*
t
;
x
=
X
+
a
*
t
;
//y = y5;
//y = y5;
z
=
Z
+
c
*
t
;
z
=
Z
+
c
*
t
;
if
(
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
z6
<=
z
&&
z
3
<=
z
)
if
(
Vector3f
(
0
,
-
1
,
0
)
*
ray
.
direction
()
<
0
&&
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
z6
<=
z
&&
z
<=
z
3
)
return
true
;
return
true
;
}
}
...
@@ -101,7 +103,7 @@ bool Quad::is_hit(const Ray3f ray)
...
@@ -101,7 +103,7 @@ bool Quad::is_hit(const Ray3f ray)
x
=
X
+
a
*
t
;
x
=
X
+
a
*
t
;
y
=
Y
+
b
*
t
;
y
=
Y
+
b
*
t
;
//z = z6;
//z = z6;
if
(
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
y5
<=
y
&&
y
<=
y2
)
if
(
Vector3f
(
0
,
0
,
-
1
)
*
ray
.
direction
()
<
0
&&
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
y5
<=
y
&&
y
<=
y2
)
return
true
;
return
true
;
}
}
...
@@ -139,40 +141,65 @@ Ray3f Quad::reflect(const Ray3f ray) const
...
@@ -139,40 +141,65 @@ Ray3f Quad::reflect(const Ray3f ray) const
Vector3f
I
=
ray
.
direction
();
Vector3f
I
=
ray
.
direction
();
//Face 1
std
::
cout
<<
"a="
<<
a
<<
std
::
endl
;
std
::
cout
<<
"b="
<<
a
<<
std
::
endl
;
std
::
cout
<<
"c="
<<
a
<<
std
::
endl
;
//Face 1 et 4
if
(
a
!=
0
)
if
(
a
!=
0
)
{
{
std
::
cout
<<
"a!=0 face 1 ou 4"
<<
std
::
endl
;
t
=
(
x1
-
X
)
/
a
;
t
=
(
x1
-
X
)
/
a
;
//x = x1;
//x = x1;
y
=
Y
+
b
*
t
;
y
=
Y
+
b
*
t
;
z
=
Z
+
c
*
t
;
z
=
Z
+
c
*
t
;
if
(
t
>
0
&&
y5
<=
y
&&
y
<=
y2
&&
z6
<=
z
&&
z3
<=
z
)
t
=
(
x4
-
X
)
/
a
;
//x = x4;
y
=
Y
+
b
*
t
;
z
=
Z
+
c
*
t
;
if
(
y5
<=
y
&&
y
<=
y2
&&
z6
<=
z
&&
z
<=
z3
)
{
{
Vector3f
hit
=
ray
.
origin
()
+
t
*
ray
.
direction
();
Vector3f
hit
=
ray
.
origin
()
+
t
*
ray
.
direction
();
Vector3f
N
=
Vector3f
(
1
,
0
,
0
);
Vector3f
N
=
Vector3f
(
-
1
,
0
,
0
);
N
.
normalize
();
N
.
normalize
();
return
Ray3f
(
hit
,
I
-
(
I
*
N
)
*
N
);
}
}
}
}
//Face 2
//Face 2
if
(
b
!=
0
)
if
(
b
!=
0
)
{
{
std
::
cout
<<
"b!=0 face 2"
<<
std
::
endl
;
t
=
(
y2
-
Y
)
/
b
;
t
=
(
y2
-
Y
)
/
b
;
x
=
X
+
a
*
t
;
x
=
X
+
a
*
t
;
//y = y2;
//y = y2;
z
=
Z
+
c
*
t
;
z
=
Z
+
c
*
t
;
if
(
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
z6
<=
z
&&
z
3
<=
z
)
if
(
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
z6
<=
z
&&
z
<=
z
3
)
{
{
Vector3f
hit
=
ray
.
origin
()
+
t
*
ray
.
direction
();
Vector3f
hit
=
ray
.
origin
()
+
t
*
ray
.
direction
();
Vector3f
N
=
Vector3f
(
0
,
1
,
0
);
Vector3f
N
=
Vector3f
(
0
,
1
,
0
);
N
.
normalize
();
N
.
normalize
();
return
Ray3f
(
hit
,
I
-
(
I
*
N
)
*
N
);
}
}
}
}
//Face 3
//Face 3
if
(
c
!=
0
)
if
(
c
!=
0
)
{
{
std
::
cout
<<
"c!=0 face 3"
<<
std
::
endl
;
t
=
(
z3
-
Z
)
/
c
;
t
=
(
z3
-
Z
)
/
c
;
x
=
X
+
a
*
t
;
x
=
X
+
a
*
t
;
y
=
Y
+
b
*
t
;
y
=
Y
+
b
*
t
;
...
@@ -182,38 +209,29 @@ Ray3f Quad::reflect(const Ray3f ray) const
...
@@ -182,38 +209,29 @@ Ray3f Quad::reflect(const Ray3f ray) const
Vector3f
hit
=
ray
.
origin
()
+
t
*
ray
.
direction
();
Vector3f
hit
=
ray
.
origin
()
+
t
*
ray
.
direction
();
Vector3f
N
=
Vector3f
(
0
,
0
,
1
);
Vector3f
N
=
Vector3f
(
0
,
0
,
1
);
N
.
normalize
();
N
.
normalize
();
return
Ray3f
(
hit
,
I
-
(
I
*
N
)
*
N
);
}
}
}
}
//Face 4
if
(
a
!=
0
)
{
t
=
(
x4
-
X
)
/
a
;
//x = x4;
y
=
Y
+
b
*
t
;
z
=
Z
+
c
*
t
;
if
(
t
>
0
&&
y5
<=
y
&&
y
<=
y2
&&
z6
<=
z
&&
z3
<=
z
)
{
Vector3f
hit
=
ray
.
origin
()
+
t
*
ray
.
direction
();
Vector3f
N
=
Vector3f
(
-
1
,
0
,
0
);
N
.
normalize
();
}
}
//Face 5
//Face 5
if
(
b
!=
0
)
if
(
b
!=
0
)
{
{
std
::
cout
<<
"b!=0 face 5"
<<
std
::
endl
;
t
=
(
y5
-
Y
)
/
b
;
t
=
(
y5
-
Y
)
/
b
;
x
=
X
+
a
*
t
;
x
=
X
+
a
*
t
;
//y = y5;
//y = y5;
z
=
Z
+
c
*
t
;
z
=
Z
+
c
*
t
;
if
(
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
z6
<=
z
&&
z
3
<=
z
)
if
(
t
>
0
&&
x4
<=
x
&&
x
<=
x1
&&
z6
<=
z
&&
z
<=
z
3
)
{
{
Vector3f
hit
=
ray
.
origin
()
+
t
*
ray
.
direction
();
Vector3f
hit
=
ray
.
origin
()
+
t
*
ray
.
direction
();
Vector3f
N
=
Vector3f
(
0
,
-
1
,
0
);
Vector3f
N
=
Vector3f
(
0
,
-
1
,
0
);
N
.
normalize
();
N
.
normalize
();
return
Ray3f
(
hit
,
I
-
(
I
*
N
)
*
N
);
}
}
}
}
...
@@ -221,6 +239,7 @@ Ray3f Quad::reflect(const Ray3f ray) const
...
@@ -221,6 +239,7 @@ Ray3f Quad::reflect(const Ray3f ray) const
//Face 6
//Face 6
if
(
c
!=
0
)
if
(
c
!=
0
)
{
{
std
::
cout
<<
"c!=0 face 6"
<<
std
::
endl
;
t
=
(
z6
-
Z
)
/
c
;
t
=
(
z6
-
Z
)
/
c
;
x
=
X
+
a
*
t
;
x
=
X
+
a
*
t
;
y
=
Y
+
b
*
t
;
y
=
Y
+
b
*
t
;
...
@@ -230,10 +249,11 @@ Ray3f Quad::reflect(const Ray3f ray) const
...
@@ -230,10 +249,11 @@ Ray3f Quad::reflect(const Ray3f ray) const
Vector3f
hit
=
ray
.
origin
()
+
t
*
ray
.
direction
();
Vector3f
hit
=
ray
.
origin
()
+
t
*
ray
.
direction
();
Vector3f
N
=
Vector3f
(
0
,
0
,
-
1
);
Vector3f
N
=
Vector3f
(
0
,
0
,
-
1
);
N
.
normalize
();
N
.
normalize
();
return
Ray3f
(
hit
,
I
-
(
I
*
N
)
*
N
);
}
}
}
}
return
Ray3f
(
hit
,
I
-
(
I
*
N
)
*
N
);
}
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter