From 623fee395425ab33f14fb9cd8ffa790e362f59d7 Mon Sep 17 00:00:00 2001 From: Julian T Date: Fri, 21 Feb 2020 06:55:27 +0100 Subject: Added pgm drawing and got light ray tracing working Still needs correct light simulation and reflections --- scene.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 scene.h (limited to 'scene.h') diff --git a/scene.h b/scene.h new file mode 100644 index 0000000..1c6363b --- /dev/null +++ b/scene.h @@ -0,0 +1,52 @@ + +#ifndef SCENE_H +#define SCENE_H + +#include +#include +#include "vector.h" +#include "viewpoint.h" +#include "pgm.h" + +#define TYPE_SPHERE 1 +#define TYPE_PLANE 2 + +typedef struct { + vector_t *center; + COORD_T radius; +} sphere_t; + +typedef struct { + vector_t *start; + vector_t *norm; +} plane_t; + +typedef struct light_s{ + vector_t *pos; + color_t *col; + + struct light_s *next; +} light_t; + +// General object structure +typedef struct object_s{ + uint8_t type; + struct object_s *next; + + union { + sphere_t sph; + plane_t pl; + }; +} object_t; + +typedef struct { + viewpoint_t view; + object_t *objects; + light_t *lights; +} space_t; + +object_t *add_sphere(space_t *s, vector_t *c, COORD_T r); +object_t *add_plane(space_t *s, vector_t *start, vector_t *dir); +light_t *add_light(space_t *s, vector_t *pos, color_t *c); + +#endif -- cgit v1.2.3