Add a simple scene for debugging
authorLukas Jiriste <ljiriste@student.42prague.com>
Sat, 23 Nov 2024 12:04:55 +0000 (13:04 +0100)
committerLukas Jiriste <ljiriste@student.42prague.com>
Sat, 23 Nov 2024 12:06:33 +0000 (13:06 +0100)
inc/miniRT.h
src/main.c

index f40ed49dde31a7427bfcbb35729be3697f488621..3ccfb8c045382951f16bc2bf1ed594a36263d0a3 100644 (file)
@@ -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
index 8e4f55eeeb1774a23e7a88eb1089aa89d983705f..28f9b8ab902a9eb844773bfa63c4ea9f550e34ba 100644 (file)
@@ -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)