Browse Source

tree?

richal-scene-stuff
rv3392 4 years ago
parent
commit
5ca8e88f7b
  1. 27
      distfuncs.c
  2. 1
      distfuncs.h
  3. 15
      main.c

27
distfuncs.c

@ -242,4 +242,31 @@ struct object new_cone(struct vec* position, double rotation, double scale) { @@ -242,4 +242,31 @@ struct object new_cone(struct vec* position, double rotation, double scale) {
struct object new_vert_line(struct vec* position, double rotation, double scale) {
return new_object(position, rotation, scale, sdf_phat_vert_line, yeet_pho);
}
struct colour yeet_whit(struct ray *ray, struct object* obj) {
struct colour c = {.r = 200, .g = 200, .b = 200, .a = 255, .sp=CS_RGB};
return c;
}
/**
* The absolute jankiest way to make a tree but I couldn't think of anything
* better.
*
* Returns a pointer to the first element of an array of the components of the
* tree (trunk and leaves). Iterate over the array when adding to a scene.
*/
struct object* new_tree(struct vec* position, double rotation, double scale) {
struct object* tree = malloc(2 * sizeof(struct object));
struct object trunk = new_object(position, rotation, scale, sdf_phat_vert_line, yeet_pho);
trunk.base_col = (struct colour){.r = 210, .g = 105, .b = 30, .sp = CS_RGB};
struct vec* leaf_pos = add_vec_ip(new_vec3(0, -0.75, 0), position);
struct object leaves = new_object(leaf_pos, rotation, scale, sdf_sphere, yeet_pho);
leaves.base_col = (struct colour){.r = 0, .g = 255, .b = 0, .sp = CS_RGB};
tree[0] = trunk;
tree[1] = leaves;
return tree;
}

1
distfuncs.h

@ -6,6 +6,7 @@ struct object new_sphere(struct vec *, double, double); @@ -6,6 +6,7 @@ struct object new_sphere(struct vec *, double, double);
struct object new_cone(struct vec *, double, double);
struct object new_box(struct vec *, double, double);
struct object new_vert_line(struct vec *, double, double);
struct object* new_tree(struct vec *, double, double);
struct object new_object(struct vec *, double, double, double (*) (struct vec *),
struct colour (*)(struct ray *, struct object *));

15
main.c

@ -160,11 +160,6 @@ static int raymarch_threadfn(void *data) { @@ -160,11 +160,6 @@ static int raymarch_threadfn(void *data) {
}
struct colour yeet_whit(struct ray *ray, struct object* obj) {
struct colour c = {.r = 200, .g = 200, .b = 200, .a = 255, .sp=CS_RGB};
return c;
}
void setup_camera_scene()
{
//struct object white_sphere = new_object(new_vec3(0.75, 0, 8), 0, 1, sdf_box, yeet_whit);
@ -178,12 +173,14 @@ void setup_camera_scene() @@ -178,12 +173,14 @@ void setup_camera_scene()
camera->y->elements[1] = 1;
camera->z->elements[2] = 1;
struct object white_sphere = new_sphere(new_vec3(-0.75, 0, 8), 0, 1);
struct object other_white_sphere = new_sphere(new_vec3(0.75, 0, 8), 0, 1);
// struct object white_sphere = new_box(new_vec3(-0.75, 0, 8), 0, 1);
// struct object other_white_sphere = new_sphere(new_vec3(0.75, 0, 8), 0, 1);
struct object* tree = new_tree(new_vec3(0, 0, 5), 0, 1);
struct object* scene_objects = malloc(2 * sizeof(struct object));
scene_objects[1] = white_sphere;
scene_objects[0] = other_white_sphere;
scene_objects[0] = tree[0];
scene_objects[1] = tree[1];
scene_object = new_scene(2, scene_objects);
scene_object.sol.pos.dimension = 3;

Loading…
Cancel
Save