Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snowman
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VILLAUME Lucas
snowman
Commits
31cf66ad
Commit
31cf66ad
authored
1 year ago
by
Lucas Villaume
Browse files
Options
Downloads
Patches
Plain Diff
détail bonhomme
parent
2895ec73
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
envmap.jpg
+0
-0
0 additions, 0 deletions
envmap.jpg
tinyraytracer.cpp
+63
-8
63 additions, 8 deletions
tinyraytracer.cpp
with
63 additions
and
8 deletions
envmap.jpg
100755 → 100644
+
0
−
0
View replaced file @
2895ec73
View file @
31cf66ad
3.24 MiB
|
W:
|
H:
242 KiB
|
W:
|
H:
2-up
Swipe
Onion skin
This diff is collapsed.
Click to expand it.
tinyraytracer.cpp
+
63
−
8
View file @
31cf66ad
...
...
@@ -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
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment