Skip to content
Snippets Groups Projects
Commit 31cf66ad authored by Lucas Villaume's avatar Lucas Villaume
Browse files

détail bonhomme

parent 2895ec73
No related branches found
No related tags found
No related merge requests found
envmap.jpg

3.24 MiB | W: | H:

envmap.jpg

242 KiB | W: | H:

envmap.jpg
envmap.jpg
envmap.jpg
envmap.jpg
  • 2-up
  • Swipe
  • Onion skin
......@@ -20,7 +20,7 @@ std::vector<Vec3f> envmap;
struct Light {
Light(const Vec3f &p, const float i) : position(p), intensity(i) {}
Vec3f position;
float intensity;
float intensity;
};
struct Material {
......@@ -97,7 +97,7 @@ Vec3f cast_ray(const Vec3f &orig, const Vec3f &dir, const std::vector<Sphere> &s
if (depth>4 || !scene_intersect(orig, dir, spheres, point, N, material)) {
int latitude = acos(dir.y)/M_PI*envmap_height; //latitudinal mapping
int i = (int)((atan2(dir.z, dir.x)/M_PI + 0.5)*(envmap_width))+latitude*envmap_width;
int i = (int)((atan2(dir.z, dir.x)/M_PI + 0.3)*(envmap_width))+latitude*envmap_width;
return envmap[i]; // background color
}
......@@ -175,21 +175,76 @@ int main() {
Material mirror(1.0, Vec4f(0.0, 10.0, 0.8, 0.0), Vec3f(1.0, 1.0, 1.0), 1425.);
Material black_rock(1.0, Vec4f(0.0, 0.0, 0.0, 0.0), Vec3f(0.0, 0.0, 0.0), 100.);
Material snow(1.3, Vec4f(0.9, 0.1, 0.0, 0.0), Vec3f(1.0, 1.0, 1.0), 50.);
Material carrot(1.3, Vec4f(0.9, 0.1, 0.0, 0.0), Vec3f(1.0, 0.5, 0.0), 50.);
Material wood(1.3, Vec4f(0.6, 0.4, 0.0, 0.0), Vec3f(0.3, 0.15, 0.0), 50.);
Material grey_wool(1.3, Vec4f(0.6, 0.0, 0.0, 0.0), Vec3f(0.3, 0.3, 0.3), 50.);
std::vector<Sphere> spheres;
//*******Scene********//
//Corps du bonhomme de neige
spheres.push_back(Sphere(Vec3f(0, -1.7, -15), 2.3, snow));
spheres.push_back(Sphere(Vec3f(0, 1.9, -15), 1.9, snow));
spheres.push_back(Sphere(Vec3f(0, 4.6, -15), 1.5, snow));
//Yeux du bonhomme de neige
spheres.push_back(Sphere(Vec3f(-0.5, 4.8, -13.5), 0.15, black_rock));
spheres.push_back(Sphere(Vec3f(0.5, 4.8, -13.5), 0.15, black_rock));
spheres.push_back(Sphere(Vec3f(-0.5, 4.9, -13.6), 0.15, black_rock));
spheres.push_back(Sphere(Vec3f(0.5, 4.9, -13.6), 0.15, black_rock));
//Nez du bonhomme de neige
for (int i = 0; i < 10; ++i) {
spheres.push_back(Sphere(Vec3f(0, 4.5, -13.8 + 0.2*i), 0.3 - 0.02*i, carrot));
}
//Sourire du bonhomme de neige
float deb_angle = -M_PI;
float fin_angle = 0;
float nb_sphere = 7;
float rayon = 0.6;
float angleIncrement = (fin_angle - deb_angle) / (nb_sphere - 1); // Calcul de l'incrémentation d'angle entre chaque sphère
for (int i = 0; i < nb_sphere; ++i) {
float angle = deb_angle + i * angleIncrement; // Calcul de l'angle pour cette sphère
float x = rayon * cos(angle); // Calcul des coordonnées x et z en fonction de l'angle
float y = rayon * sin(angle) + 4.3; // Calcul de la coordonnée y en fonction de l'angle
spheres.push_back(Sphere(Vec3f(x, y, -13.65+0.13*sin(angle)), 0.1, black_rock)); // Ajout de la sphère à la liste
}
//Bras du bonhomme de neige
for (int i = 0; i < 20; ++i) {
spheres.push_back(Sphere(Vec3f(-1.5-0.1*i, 2.5-0.05*i, -14.2+0.1*i), 0.2, wood)); //Bras droit
spheres.push_back(Sphere(Vec3f(1.5+0.1*i, 2.5-0.05*i, -14.2+0.1*i), 0.2, wood)); //Bras gauche
}
//Boutons du bonhomme de neige
float deb_bouton = 3;
float fin_bouton = 0.7;
float nb_bouton = 4;
float espace_bouton = (deb_bouton - fin_bouton) / (nb_bouton - 1);
for (int i = 0; i < nb_bouton; ++i) {
spheres.push_back(Sphere(Vec3f(0, deb_bouton - i * espace_bouton, -13), 0.13, black_rock));
}
//Bonnet du bonhomme de neige
spheres.push_back(Sphere(Vec3f(0, 5.5, -15), 1.3, grey_wool));
deb_angle = 0;
fin_angle = M_PI;
nb_sphere = 100;
rayon = 1.3;
angleIncrement = (fin_angle - deb_angle) / (nb_sphere - 1); // Calcul de l'incrémentation d'angle entre chaque sphère
for (int i = 0; i < nb_sphere; ++i) {
float angle = deb_angle + i * angleIncrement; // Calcul de l'angle pour cette sphère
float x = rayon * cos(angle); // Calcul des coordonnées x et z en fonction de l'angle
float z = rayon * sin(angle) - 14.8; // Calcul de la coordonnée y en fonction de l'angle
spheres.push_back(Sphere(Vec3f(x, 5.35, z), 0.15, grey_wool)); // Ajout de la sphère à la liste
}
//spheres.push_back(Sphere(Vec3f(-1.0, -1.5, -12), 2, glass));
//spheres.push_back(Sphere(Vec3f( 1.5, -0.5, -18), 3, red_rubber));
//spheres.push_back(Sphere(Vec3f( 7, 5, -18), 4, mirror));
//*******Lumières********//
std::vector<Light> lights;
lights.push_back(Light(Vec3f(-20, 20, 20), 1.5));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment