#ifndef __MARCHER_H__ #define __MARCHER_H__ #include "images/images.h" #include "src/point.h" #include "src/rays.h" // define pi if not available #ifndef M_PI #define M_PI 3.14159265358979323846 #endif struct __mycam; struct __myobject; struct __myscene; typedef struct __mycam { Point location; Point direction; unsigned int fov; } Camera; Camera camera_new(Point direction, unsigned int fov); void camera_set_looking_at(Camera *cam, Point origin, Point thing); // Scene objects have a position, some args, and a distance calculation function // the distance calc function has the following signature: // double distanceTo(Point myLocation, double * myArgs, Point externalPoint) // where myLocation is this.location, myArgs is this.args and externalPoint is the point from wich we want to know the distance // the get_color function takes args: point_hit, direction_hit, myArgs, MyLocation, MyColor typedef struct __myobject { Point location; double * args; double (*distance)(Point, struct __myobject *); Color (*get_color)(Point, Point, struct __myobject *); Color color; struct __myscene* scene; } SceneObject; typedef struct __perfopts { int speed_cutoff; int max_steps; double threshold; } PerformanceOptimizations; typedef struct __myscene { unsigned int width; unsigned int height; SceneObject * objects; int object_count; int allocated_space; // performance opts PerformanceOptimizations perf_opts; // colors etc Color background; } Scene; Image* render_scene(Scene *scene, Camera *camera, unsigned int threads); Scene scene_new(unsigned int width, unsigned int height, int obj_count); void scene_add_obj(Scene* scene, SceneObject object); void scene_destroy(Scene scene); #include "src/camera.c" #include "src/scene.c" #endif