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 conteneur
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é
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Yacine ACHEROUFKEBIR
PAP_ray_tracing
Validations
22135f25
Valider
22135f25
rédigé
5 years ago
par
Lénaïc DURAND
Parcourir les fichiers
Options
Téléchargements
Plain Diff
Merge branch 'master' of git.iiens.net:acherouf2018/pap_ray_tracing
parents
027aa69c
4ed3602c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
main.cpp
+1
-1
1 ajout, 1 suppression
main.cpp
quad.cpp
+51
-31
51 ajouts, 31 suppressions
quad.cpp
ray3f.cpp
+1
-0
1 ajout, 0 suppression
ray3f.cpp
avec
53 ajouts
et
32 suppressions
main.cpp
+
1
−
1
Voir le fichier @
22135f25
...
...
@@ -167,7 +167,7 @@ int main()
shapes
[
2
]
=
new
Quad
(
white
,
Vector3f
(
width
/
2
,
height
,
depth
/
2
),
width
,
0
,
depth
);
//plafond
shapes
[
3
]
=
new
Quad
(
cyan
,
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
,
2
0
,
depth
-
20
),
40
,
40
,
40
);
//cube
shapes
[
5
]
=
new
Quad
(
red
,
Vector3f
(
50
,
5
0
,
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
,
-
1
),
Vector3f
(
0
,
0
,
1
));
//on met la caméra un peu en recul
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
quad.cpp
+
51
−
31
Voir le fichier @
22135f25
#include
"quad.h"
#include
<iostream>
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)
//x = x1;
y
=
Y
+
b
*
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
;
}
...
...
@@ -53,7 +55,7 @@ bool Quad::is_hit(const Ray3f ray)
x
=
X
+
a
*
t
;
//y = y2;
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
;
}
...
...
@@ -65,7 +67,7 @@ bool Quad::is_hit(const Ray3f ray)
x
=
X
+
a
*
t
;
y
=
Y
+
b
*
t
;
//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
;
}
...
...
@@ -77,7 +79,7 @@ bool Quad::is_hit(const Ray3f ray)
//x = x4;
y
=
Y
+
b
*
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
;
}
...
...
@@ -89,7 +91,7 @@ bool Quad::is_hit(const Ray3f ray)
x
=
X
+
a
*
t
;
//y = y5;
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
;
}
...
...
@@ -101,7 +103,7 @@ bool Quad::is_hit(const Ray3f ray)
x
=
X
+
a
*
t
;
y
=
Y
+
b
*
t
;
//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
;
}
...
...
@@ -131,7 +133,7 @@ Ray3f Quad::reflect(const Ray3f ray) const
//Calculs des coordonnées d'intersection avec les faces et vérification
float
t
,
x
,
y
,
z
;
float
t
,
x
,
y
,
z
;
Vector3f
hit
;
...
...
@@ -139,40 +141,65 @@ Ray3f Quad::reflect(const Ray3f ray) const
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
)
{
std
::
cout
<<
"a!=0 face 1 ou 4"
<<
std
::
endl
;
t
=
(
x1
-
X
)
/
a
;
//x = x1;
y
=
Y
+
b
*
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
N
=
hit
-
origin_
;
Vector3f
N
=
Vector3f
(
-
1
,
0
,
0
)
;
N
.
normalize
();
return
Ray3f
(
hit
,
I
-
(
I
*
N
)
*
N
);
}
}
//Face 2
if
(
b
!=
0
)
{
std
::
cout
<<
"b!=0 face 2"
<<
std
::
endl
;
t
=
(
y2
-
Y
)
/
b
;
x
=
X
+
a
*
t
;
//y = y2;
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
N
=
hit
-
origin_
;
Vector3f
N
=
Vector3f
(
0
,
1
,
0
)
;
N
.
normalize
();
return
Ray3f
(
hit
,
I
-
(
I
*
N
)
*
N
);
}
}
//Face 3
if
(
c
!=
0
)
{
std
::
cout
<<
"c!=0 face 3"
<<
std
::
endl
;
t
=
(
z3
-
Z
)
/
c
;
x
=
X
+
a
*
t
;
y
=
Y
+
b
*
t
;
...
...
@@ -180,40 +207,31 @@ 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
();
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
=
hit
-
origin_
;
N
.
normalize
();
}
}
//Face 5
if
(
b
!=
0
)
{
std
::
cout
<<
"b!=0 face 5"
<<
std
::
endl
;
t
=
(
y5
-
Y
)
/
b
;
x
=
X
+
a
*
t
;
//y = y5;
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
N
=
hit
-
origin_
;
Vector3f
N
=
Vector3f
(
0
,
-
1
,
0
)
;
N
.
normalize
();
return
Ray3f
(
hit
,
I
-
(
I
*
N
)
*
N
);
}
}
...
...
@@ -221,6 +239,7 @@ Ray3f Quad::reflect(const Ray3f ray) const
//Face 6
if
(
c
!=
0
)
{
std
::
cout
<<
"c!=0 face 6"
<<
std
::
endl
;
t
=
(
z6
-
Z
)
/
c
;
x
=
X
+
a
*
t
;
y
=
Y
+
b
*
t
;
...
...
@@ -228,12 +247,13 @@ 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
();
return
Ray3f
(
hit
,
I
-
(
I
*
N
)
*
N
);
}
}
return
Ray3f
(
hit
,
I
-
(
I
*
N
)
*
N
);
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
ray3f.cpp
+
1
−
0
Voir le fichier @
22135f25
...
...
@@ -6,6 +6,7 @@ Ray3f::Ray3f(const Vector3f & ori, const Vector3f & dir)
{
origin_
=
ori
;
direction_
=
dir
;
direction_
.
normalize
();
}
...
...
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