Skip to content

Commit d46ca66

Browse files
author
moromin
committed
feat: add get texture color function to cone, cylinder and plane
1 parent d5378e5 commit d46ca66

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
images/geo_n.xpm filter=lfs diff=lfs merge=lfs -text

src/cone.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ static t_color cone_calc_color(t_object *const me_, t_vector cross_point)
127127
t_color c;
128128
if (me->super.info.flag & 1 << FLAG_CHECKER)
129129
c = ch_pattern_at(&me->super.info, calc_uv(me, cross_point));
130+
else if (me->super.info.flag & 1 << FLAG_TEXTURE)
131+
c = tx_color_at(&me->super.info, calc_uv(me, cross_point));
130132
else
131133
c = me->super.material.k_diffuse;
132134
c;

src/cylinder.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ t_vector cylinder_calc_bumpmap_normal(t_object *const me_, t_vector cross_point)
108108
const t_cylinder *me = (t_cylinder *)me_;
109109
const t_vector normal = ({
110110
const t_uv uv = calc_uv(me, cross_point);
111-
const t_vector tangent = get_vector_from_normal_map(1 - uv.u, 1 - uv.v, &me->super.info);
111+
const t_vector tangent = get_vector_from_normal_map(uv.u, uv.v, &me->super.info);
112112

113113
const t_vector n = object_calc_normal(me_, cross_point);
114114
const t_vector b = me->normal;
@@ -127,6 +127,8 @@ static t_color cylinder_calc_color(t_object *const me_, t_vector cross_point)
127127
t_color c;
128128
if (me->super.info.flag & 1 << FLAG_CHECKER)
129129
c = ch_pattern_at(&me->super.info, calc_uv(me, cross_point));
130+
else if (me->super.info.flag & 1 << FLAG_TEXTURE)
131+
c = tx_color_at(&me->super.info, calc_uv(me, cross_point));
130132
else
131133
c = me->super.material.k_diffuse;
132134
c;

src/plane.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ static t_color plane_calc_color(t_object *const me_, t_vector cross_point)
8484
t_color c;
8585
if (me->super.info.flag & 1 << FLAG_CHECKER)
8686
c = ch_pattern_at(&me->super.info, calc_uv(me, cross_point));
87+
else if (me->super.info.flag & 1 << FLAG_TEXTURE)
88+
c = tx_color_at(&me->super.info, calc_uv(me, cross_point));
8789
else
8890
c = me->super.material.k_specular;
8991
c;

0 commit comments

Comments
 (0)