Add more complex scene to demonstrate miniRT
authorLukáš Jiřiště <jiriste@icpf.cas.cz>
Wed, 27 Nov 2024 09:26:15 +0000 (10:26 +0100)
committerLukáš Jiřiště <jiriste@icpf.cas.cz>
Wed, 27 Nov 2024 09:26:15 +0000 (10:26 +0100)
I wanted to have a scene now, but .rt parsing needs to be implemented
yet.

src/main.c

index 895cbe054947f2135d6e5e0042f104790863ceaf..6f8eec61aaa27d2f78e5c4017a8dd4b953e628b7 100644 (file)
@@ -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)