From: Lukas Jiriste Date: Sat, 23 Nov 2024 12:04:55 +0000 (+0100) Subject: Add a simple scene for debugging X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=c0baaeb61ef6da6d9e28356600ebb34f4c8af772;p=42%2FminiRT.git Add a simple scene for debugging --- diff --git a/inc/miniRT.h b/inc/miniRT.h index f40ed49..3ccfb8c 100644 --- a/inc/miniRT.h +++ b/inc/miniRT.h @@ -90,7 +90,7 @@ typedef struct s_scene t_vec objects; t_vec lights; t_vec cameras; - t_camera *current_camera; + const t_camera *current_camera; } t_scene; typedef struct s_ray diff --git a/src/main.c b/src/main.c index 8e4f55e..28f9b8a 100644 --- a/src/main.c +++ b/src/main.c @@ -190,8 +190,48 @@ void cleanup(t_session *s) void set_defaults(t_session *s) { + t_camera cam; + t_light light; + t_object plane; + s->img.width = 1920; s->img.height = 1011; + ft_vec_init(&s->scene.objects, sizeof(t_object)); + 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.position.y = 0; + light.position.z = 1; + light.brightness = 0.5; + ft_vec_append(&s->scene.lights, &light); + cam.position.x = 0; + cam.position.y = 0; + cam.position.z = 0; + cam.orientation.x = 1; + cam.orientation.y = 0; + cam.orientation.z = 0; + cam.up_direction.x = 0; + cam.up_direction.y = 0; + 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); + 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; } int main(void)