From 9b4fadcd16d8671faa72b1ef95f41d36589804bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Luk=C3=A1=C5=A1=20Ji=C5=99i=C5=A1t=C4=9B?= Date: Wed, 27 Nov 2024 10:26:15 +0100 Subject: [PATCH] Add more complex scene to demonstrate miniRT I wanted to have a scene now, but .rt parsing needs to be implemented yet. --- src/main.c | 51 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/src/main.c b/src/main.c index 895cbe0..6f8eec6 100644 --- a/src/main.c +++ b/src/main.c @@ -193,7 +193,7 @@ void set_defaults(t_session *s) { t_camera cam; t_light light; - t_object plane; + t_object object; s->img.width = 1920; s->img.height = 1011; @@ -201,12 +201,16 @@ void set_defaults(t_session *s) ft_vec_init(&s->scene.lights, sizeof(t_light)); ft_vec_init(&s->scene.cameras, sizeof(t_camera)); light.color.x = 1; - light.color.y = 1; - light.color.z = 1; - light.position.x = 0; + light.color.y = 0; + light.color.z = 0; + light.position.x = 3; light.position.y = 0; - light.position.z = 1; - light.brightness = 0.5; + light.position.z = 0; + light.brightness = 0.4; + ft_vec_append(&s->scene.lights, &light); + light.color.x = 0; + light.color.z = 1; + light.position.y = 1; ft_vec_append(&s->scene.lights, &light); cam.position.x = 0; cam.position.y = 0; @@ -219,20 +223,31 @@ void set_defaults(t_session *s) cam.up_direction.z = 1; cam.field_of_view = 1.5; ft_vec_append(&s->scene.cameras, &cam); - plane.object.sphere.color.x = 1; - plane.object.sphere.color.y = 0; - plane.object.sphere.color.z = 0; - plane.object.sphere.center.x = 1; - plane.object.sphere.center.y = 0; - plane.object.sphere.center.z = 0; - plane.object.sphere.radius = 0.3; - plane.type = SPHERE; - ft_vec_append(&s->scene.objects, &plane); + object.object.sphere.color.x = 1; + object.object.sphere.color.y = 1; + object.object.sphere.color.z = 1; + object.object.sphere.center.x = 3; + object.object.sphere.center.y = 0.5; + object.object.sphere.center.z = -0.7; + object.object.sphere.radius = 0.3; + object.type = SPHERE; + ft_vec_append(&s->scene.objects, &object); + object.type = PLANE; + object.object.plane.color.x = 1; + object.object.plane.color.y = 1; + object.object.plane.color.z = 1; + object.object.plane.point.x = 0; + object.object.plane.point.y = 0; + object.object.plane.point.z = -1; + object.object.plane.normal.x = 0; + object.object.plane.normal.y = 0; + object.object.plane.normal.z = 1; + ft_vec_append(&s->scene.objects, &object); s->scene.current_camera = ft_vec_caccess(&s->scene.cameras, 0); s->scene.ambient_light.color.x = 1; - s->scene.ambient_light.color.y = 0; - s->scene.ambient_light.color.z = 0; - s->scene.ambient_light.brightness = 0.3; + s->scene.ambient_light.color.y = 1; + s->scene.ambient_light.color.z = 1; + s->scene.ambient_light.brightness = 0.01; } int main(void) -- 2.30.2