diff options
author | Julian T <julian@jtle.dk> | 2020-02-21 06:55:27 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-02-21 06:55:27 +0100 |
commit | 623fee395425ab33f14fb9cd8ffa790e362f59d7 (patch) | |
tree | c70b64e13fd5e00c2317fa40ee4b8cd786e635d5 /scene.h | |
parent | 63a84080f9f0e3d719d5470e370584a5eff18a47 (diff) |
Added pgm drawing and got light ray tracing working
Still needs correct light simulation and reflections
Diffstat (limited to 'scene.h')
-rw-r--r-- | scene.h | 52 |
1 files changed, 52 insertions, 0 deletions
@@ -0,0 +1,52 @@ + +#ifndef SCENE_H +#define SCENE_H + +#include <stdbool.h> +#include <stdint.h> +#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 |