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
027aa69c
Valider
027aa69c
rédigé
Il y a 5 ans
par
Lénaïc DURAND
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
ajout de libpng
parent
ed87d410
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
6
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
6 fichiers modifiés
0.png
+0
-0
0 ajout, 0 suppression
0.png
Makefile
+1
-1
1 ajout, 1 suppression
Makefile
main
+0
-0
0 ajout, 0 suppression
main
main.cpp
+12
-9
12 ajouts, 9 suppressions
main.cpp
scene.cpp
+68
-2
68 ajouts, 2 suppressions
scene.cpp
scene.h
+1
-1
1 ajout, 1 suppression
scene.h
avec
82 ajouts
et
13 suppressions
0.png
0 → 100644
+
0
−
0
Voir le fichier @
027aa69c
9,66 ko
Ce diff est replié.
Cliquez pour l'agrandir.
Makefile
+
1
−
1
Voir le fichier @
027aa69c
...
@@ -13,7 +13,7 @@ sphere.o: sphere.h
...
@@ -13,7 +13,7 @@ sphere.o: sphere.h
scene.o
:
scene.h
scene.o
:
scene.h
main
:
$(OBJ)
main
:
$(OBJ)
$(
CC
)
-o
$@
$^
$(
CC
)
-o
$@
$^
-lpng
clean
:
clean
:
rm
*
.o main
rm
*
.o main
\ No newline at end of file
Ce diff est replié.
Cliquez pour l'agrandir.
main
+
0
−
0
Voir le fichier @
027aa69c
Aucun aperçu pour ce type de fichier
Ce diff est replié.
Cliquez pour l'agrandir.
main.cpp
+
12
−
9
Voir le fichier @
027aa69c
...
@@ -144,6 +144,9 @@ int main()
...
@@ -144,6 +144,9 @@ int main()
Material
red
(
255
,
0
,
0
,
0
);
Material
red
(
255
,
0
,
0
,
0
);
Material
green
(
0
,
255
,
0
,
0
);
Material
green
(
0
,
255
,
0
,
0
);
Material
blue
(
0
,
0
,
255
,
0
);
Material
blue
(
0
,
0
,
255
,
0
);
Material
yellow
(
255
,
255
,
0
,
0
);
Material
magenta
(
255
,
0
,
255
,
0
);
Material
cyan
(
0
,
255
,
255
,
0
);
Material
white
(
255
,
255
,
255
,
0
);
Material
white
(
255
,
255
,
255
,
0
);
Material
grey
(
122
,
122
,
122
,
0
);
Material
grey
(
122
,
122
,
122
,
0
);
Material
black
(
0
,
0
,
0
,
0
);
Material
black
(
0
,
0
,
0
,
0
);
...
@@ -159,24 +162,24 @@ int main()
...
@@ -159,24 +162,24 @@ int main()
|
|
x <----X z*/
x <----X z*/
Shape
*
shapes
[
nb_shapes
];
Shape
*
shapes
[
nb_shapes
];
shapes
[
0
]
=
new
Quad
(
grey
,
Vector3f
(
width
/
2
,
height
/
2
,
depth
),
width
,
height
,
0
);
//mur du fond
shapes
[
0
]
=
new
Quad
(
yellow
,
Vector3f
(
width
/
2
,
height
/
2
,
depth
),
width
,
height
,
0
);
//mur du fond
shapes
[
1
]
=
new
Quad
(
grey
,
Vector3f
(
width
,
height
/
2
,
depth
/
2
),
0
,
height
,
depth
);
//mur gauche
shapes
[
1
]
=
new
Quad
(
magenta
,
Vector3f
(
width
,
height
/
2
,
depth
/
2
),
0
,
height
,
depth
);
//mur gauche
shapes
[
2
]
=
new
Quad
(
grey
,
Vector3f
(
width
/
2
,
height
,
depth
/
2
),
width
,
0
,
depth
);
//plafond
shapes
[
2
]
=
new
Quad
(
white
,
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
[
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
[
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
(
width
/
4
,
20
,
depth
-
20
),
40
,
40
,
40
);
//cube
shapes
[
6
]
=
new
Sphere
(
blue
,
Vector3f
(
3
/
4
*
width
,
20
,
depth
/
2
),
40
);
//sphere
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
));
Camera
camera
(
Vector3f
(
width
/
2
,
height
/
2
,
-
1
),
Vector3f
(
0
,
0
,
1
));
//on met la caméra un peu en recul
Ray3f
source
(
Vector3f
(
width
/
2
,
height
,
depth
/
2
),
Vector3f
(
0
,
-
1
,
0
));
Ray3f
source
(
Vector3f
(
width
/
2
,
height
,
depth
/
2
),
Vector3f
(
0
,
-
1
,
0
));
//lumière au plafonc
Scene
scene
(
camera
,
shapes
,
source
);
Scene
scene
(
camera
,
shapes
,
source
);
//----------CALCUL ET SAUVEGARDE DE L'IMAGE----------
//----------CALCUL ET SAUVEGARDE DE L'IMAGE----------
std
::
cout
<<
"Création de l'image..."
;
std
::
cout
<<
"Création de l'image..."
<<
std
::
endl
;
std
::
string
filename
=
"0.png"
;
std
::
string
filename
=
"0.png"
;
scene
.
render
(
640
,
480
,
filename
.
c_str
());
scene
.
render
(
width
,
height
,
640
,
480
,
nb_shapes
,
(
char
*
)
filename
.
c_str
());
std
::
cout
<<
"
i
mage sauvegardée"
<<
std
::
endl
;
std
::
cout
<<
"
I
mage sauvegardée"
<<
std
::
endl
;
//----------LIBERATION DE LA MEMOIRE----------
//----------LIBERATION DE LA MEMOIRE----------
for
(
int
i
=
0
;
i
<
nb_shapes
;
i
++
)
for
(
int
i
=
0
;
i
<
nb_shapes
;
i
++
)
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
scene.cpp
+
68
−
2
Voir le fichier @
027aa69c
#include
"scene.h"
#include
"scene.h"
#include
<png.h>
...
@@ -46,9 +47,74 @@ Ray3f Scene::source() const
...
@@ -46,9 +47,74 @@ Ray3f Scene::source() const
}
}
void
Scene
::
render
(
int
width
,
int
height
,
const
char
*
filename
)
void
Scene
::
render
(
int
width
,
int
height
,
int
nb_pixel_row
,
int
nb_pixel_col
,
int
nb_shapes
,
char
*
filename
)
{
FILE
*
f
=
fopen
(
filename
,
"wb"
);
if
(
!
f
)
throw
"Echec de la création du fichier"
;
png_structp
png_ptr
=
png_create_write_struct
(
PNG_LIBPNG_VER_STRING
,
NULL
,
NULL
,
NULL
);
if
(
!
png_ptr
)
{
fclose
(
f
);
throw
"Echec allocation png_ptr"
;
}
png_infop
info_ptr
=
png_create_info_struct
(
png_ptr
);
if
(
!
info_ptr
)
{
fclose
(
f
);
png_destroy_write_struct
(
&
png_ptr
,
(
png_infopp
)
NULL
);
throw
"Echec allocation info_ptr"
;
}
png_init_io
(
png_ptr
,
f
);
//Set header
png_set_IHDR
(
png_ptr
,
info_ptr
,
nb_pixel_row
,
nb_pixel_col
,
8
,
PNG_COLOR_TYPE_RGB
,
PNG_INTERLACE_NONE
,
PNG_COMPRESSION_TYPE_BASE
,
PNG_FILTER_TYPE_BASE
);
//Set text
png_text
title_text
;
title_text
.
compression
=
PNG_TEXT_COMPRESSION_NONE
;
title_text
.
text
=
filename
;
png_set_text
(
png_ptr
,
info_ptr
,
&
title_text
,
0
);
png_write_info
(
png_ptr
,
info_ptr
);
//Mémoire allouée pour une ligne de pixels (rgb => 3 bytes par pixel)
png_bytep
row
=
(
png_bytep
)
png_malloc
(
png_ptr
,
3
*
nb_pixel_row
*
sizeof
(
png_byte
));
float
pw
=
width
/
nb_pixel_row
;
float
ph
=
height
/
nb_pixel_col
;
for
(
int
i
=
0
;
i
<
nb_pixel_row
;
i
++
)
{
for
(
int
j
=
0
;
j
<
nb_pixel_col
;
j
++
)
{
Vector3f
Pij
(
i
*
pw
,
j
*
ph
,
0
);
//point de la grille par laquelle on regarde
Ray3f
camera_to_grid
(
camera_
.
position
(),
Pij
-
camera_
.
position
());
row
[
3
*
i
]
=
0
;
row
[
3
*
i
+
1
]
=
0
;
row
[
3
*
i
+
2
]
=
0
;
for
(
int
k
=
0
;
k
<
nb_shapes
;
k
++
)
{
if
(
shapes_
[
k
]
->
is_hit
(
camera_to_grid
))
{
{
row
[
3
*
i
]
=
shapes_
[
k
]
->
matter
().
r
();
row
[
3
*
i
+
1
]
=
shapes_
[
k
]
->
matter
().
g
();
row
[
3
*
i
+
2
]
=
shapes_
[
k
]
->
matter
().
b
();
}
}
}
png_write_row
(
png_ptr
,
row
);
}
png_write_end
(
png_ptr
,
NULL
);
fclose
(
f
);
}
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
scene.h
+
1
−
1
Voir le fichier @
027aa69c
...
@@ -21,7 +21,7 @@ class Scene
...
@@ -21,7 +21,7 @@ class Scene
Shape
*
*
shapes
()
const
;
Shape
*
*
shapes
()
const
;
Ray3f
source
()
const
;
Ray3f
source
()
const
;
void
render
(
int
width
,
int
height
,
const
char
*
filename
);
void
render
(
int
width
,
int
height
,
int
nb_pixel_row
,
int
nb_pixel_col
,
int
nb_shapes
,
char
*
filename
);
};
};
...
...
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