-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58d8494
commit 697f422
Showing
4 changed files
with
65 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: sdiego <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/02/26 14:12:41 by sdiego #+# #+# */ | ||
/* Updated: 2020/09/24 20:59:54 by sdiego ### ########.fr */ | ||
/* Updated: 2020/09/25 19:43:07 by sdiego ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -448,6 +448,7 @@ t_color uv_patter_at(t_pattern checkers, double u, double v); | |
t_vec spherical_map(t_vec p); | ||
t_texturemap texture_map(t_pattern checkers, t_vec (*spherical_map)(t_vec)); | ||
t_color pattern_at(t_texturemap pattern, t_vec point); | ||
t_vec planar_map(t_vec p); | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: sdiego <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/02/26 14:12:33 by sdiego #+# #+# */ | ||
/* Updated: 2020/09/24 21:15:05 by sdiego ### ########.fr */ | ||
/* Updated: 2020/09/25 19:58:38 by sdiego ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -537,21 +537,16 @@ int i = 0; | |
exit(0); | ||
*/ | ||
|
||
//CH 11// | ||
// | ||
|
||
|
||
//background ball | ||
w.s[0] = set_sphere(); | ||
w.s[0].m.pattern = 1; | ||
w.s[0].m.p = uv_checkers(20, 10, color(0, 0.5, 0), color(1, 1, 1)); | ||
w.s[0].m.new_pattern_at = &pattern_at; | ||
w.s[0].m.texturemap = texture_map(w.s[0].m.p, &spherical_map); | ||
w.s[0].m.ambient = 0.1; | ||
w.s[0].m.specular = 0.4; | ||
w.s[0].m.diffuse = 0.6; | ||
w.s[0].m.shininess = 10; | ||
|
||
// Texture mapping | ||
// planar checkers pattern | ||
w.pl[0] = set_plane(); | ||
w.pl[0].m.pattern = 1; | ||
w.pl[0].m.p = uv_checkers(2, 2, color(0, 0.5, 0), color(1, 1, 1)); | ||
w.pl[0].m.new_pattern_at = &pattern_at; | ||
w.pl[0].m.texturemap = texture_map(w.pl[0].m.p, &planar_map); | ||
w.pl[0].m.ambient = 0.1; | ||
w.pl[0].m.specular = 0; | ||
w.pl[0].m.diffuse = 0.9; | ||
|
||
//light | ||
w.light_obj = 1; | ||
|
@@ -560,33 +555,19 @@ int i = 0; | |
t_vec v2 = set_v_p(0, 1, 0, 0); | ||
w.light[0] = point_light(color(1, 1, 1), corner); | ||
|
||
w.s_obj = 1; | ||
//w.pl_obj = 1; | ||
//w.cub_obj = 1; | ||
w.pl_obj = 1; | ||
w.max_obj = 4; | ||
w.ar_count = 0; | ||
|
||
int i = 0; | ||
while (i < w.pl_obj) | ||
{ | ||
push_obj((void*)(&w.pl[i]), &normal_at_pl, &intersect_pl, &w, &w.pl[i].m, &w.pl[i].transform); | ||
i++; | ||
} | ||
i = 0; | ||
while (i < w.s_obj) | ||
{ | ||
push_obj((void*)(&w.s[i]), &normal_at_sp, &intersect_sp, &w, &w.s[i].m, &w.s[i].transform); | ||
i++; | ||
} | ||
|
||
i = 0; | ||
while (i < w.cub_obj) | ||
{ | ||
push_obj((void*)(&w.cub[i]), &normal_at_cube, &intersect_cube, &w, &w.cub[i].m, &w.cub[i].transform); | ||
i++; | ||
} | ||
|
||
t_camera c = camera(WIN_W, WIN_H, 0.5); | ||
c.transform = view_transform(set_v_p(0, 0, -5, 1), set_v_p(0, 0, 0, 1), set_v_p(0, 1, 0, 0)); | ||
c.transform = view_transform(set_v_p(1, 2, -5, 1), set_v_p(0, 0, 0, 1), set_v_p(0, 1, 0, 0)); | ||
|
||
|
||
/* | ||
|
@@ -684,6 +665,38 @@ int i = 0; | |
exit(0); | ||
*/ | ||
|
||
/* | ||
t_vec p = set_v_p(0.25, 0, 0.5, 1); | ||
t_vec uv = planar_map(p); | ||
printf("u = %f\nv = %f\n\n", uv.c[0], uv.c[1]); | ||
p = set_v_p(0.25, 0, -0.25, 1); | ||
uv = planar_map(p); | ||
printf("u = %f\nv = %f\n\n", uv.c[0], uv.c[1]); | ||
p = set_v_p(0.25, 0.5, -0.25, 1); | ||
uv = planar_map(p); | ||
printf("u = %f\nv = %f\n\n", uv.c[0], uv.c[1]); | ||
p = set_v_p(1.25, 0, 0.5, 1); | ||
uv = planar_map(p); | ||
printf("u = %f\nv = %f\n\n", uv.c[0], uv.c[1]); | ||
p = set_v_p(0.25, 0, -1.75, 1); | ||
uv = planar_map(p); | ||
printf("u = %f\nv = %f\n\n", uv.c[0], uv.c[1]); | ||
p = set_v_p(1, 0, -1, 1); | ||
uv = planar_map(p); | ||
printf("u = %f\nv = %f\n\n", uv.c[0], uv.c[1]); | ||
p = set_v_p(0, 0, 0, 1); | ||
uv = planar_map(p); | ||
printf("u = %f\nv = %f\n\n", uv.c[0], uv.c[1]); | ||
exit(0); | ||
*/ | ||
|
||
|
||
/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: sdiego <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/03/15 14:28:16 by sdiego #+# #+# */ | ||
/* Updated: 2020/09/24 20:30:40 by sdiego ### ########.fr */ | ||
/* Updated: 2020/09/25 19:55:47 by sdiego ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -30,12 +30,23 @@ t_color uv_patter_at(t_pattern checkers, double u, double v) | |
|
||
u2 = floor(u * checkers.width); | ||
v2 = floor(v * checkers.height); | ||
if (fmod((u2 + v2), 2) == 0) | ||
if (realmod((u2 + v2), 2) == 0) | ||
return(checkers.a); | ||
else | ||
return(checkers.b); | ||
} | ||
|
||
t_vec planar_map(t_vec p) | ||
{ | ||
double u; | ||
double v; | ||
t_vec uv; | ||
|
||
u = realmod(p.c[0], 1); | ||
v = realmod(p.c[2], 1); | ||
uv = set_v_p(u, v, 0, 0); | ||
return (uv); | ||
} | ||
|
||
t_vec spherical_map(t_vec p) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: sdiego <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2020/03/27 19:29:04 by sdiego #+# #+# */ | ||
/* Updated: 2020/09/24 21:22:43 by sdiego ### ########.fr */ | ||
/* Updated: 2020/09/25 19:43:36 by sdiego ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -504,3 +504,6 @@ render(&sdl, c, w); | |
|
||
t_camera c = camera(WIN_W, WIN_H, 0.5); | ||
c.transform = view_transform(set_v_p(0, 0, -5, 1), set_v_p(0, 0, 0, 1), set_v_p(0, 1, 0, 0)); | ||
|
||
|
||
|