From 63a84080f9f0e3d719d5470e370584a5eff18a47 Mon Sep 17 00:00:00 2001 From: Julian T Date: Wed, 19 Feb 2020 22:35:48 +0100 Subject: Viewpoint system and share/ray intersection working --- main.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 main.c (limited to 'main.c') diff --git a/main.c b/main.c new file mode 100644 index 0000000..0f64c57 --- /dev/null +++ b/main.c @@ -0,0 +1,41 @@ +#include +#include +#include + +#include "vector.h" +#include "viewpoint.h" +#include "ray.h" + +typedef struct { + viewpoint_t view; +} space_t; + +int main() +{ + printf("Starting\n"); + + space_t s; + + vector_set(&s.view.position, 10, 20, 10); + vector_set(&s.view.target, 0, 0, 0); + s.view.width = 100; + s.view.height = 100; + + viewpoint_init(&s.view); + + ray_t r; + r.start = &s.view.position; + viewpoint_ray(&s.view, &r.direction, 66, 33); + + vector_print(&r.direction); + + plane_t pl; + pl.start = vector_set(NULL, 0, 0, 12); + vector_set(&pl.norm, 6, 2, 0); + vector_scale_inv(&pl.norm, &pl.norm, vector_len(&pl.norm)); + vector_print(&pl.norm); + + printf("Intersect distance %f\n", ray_intersect_plane(&pl, &r)); + + +} -- cgit v1.2.3