Browse Source

Add random colour trees

place-stuff
rv3392 4 years ago
parent
commit
8fb10e8af3
  1. 2
      camera.c
  2. 13
      distfuncs.c
  3. 2
      main.c

2
camera.c

@ -28,7 +28,7 @@ double dsign(double yeet) { @@ -28,7 +28,7 @@ double dsign(double yeet) {
double manidist(struct vec *v)
{
// return v->elements[3];
return v->elements[3];
//double yeet = (SDL_GetTicks() / 10);
double yeet = 300;
v->elements[3] -= yeet;

13
distfuncs.c

@ -322,7 +322,12 @@ struct colour yeet_whit(struct ray *ray, struct object* obj) { @@ -322,7 +322,12 @@ struct colour yeet_whit(struct ray *ray, struct object* obj) {
}
struct colour yeet_green(struct ray *ray, struct object* obj) {
struct colour c = {.r = 0, .g = 255, .b = 0, .a = 255, .sp=CS_RGB};
struct colour c = {.r = 0, .g = (rand() % 127) + 127, .b = 0, .a = 255, .sp=CS_RGB};
return c;
}
struct colour yeet_brown(struct ray *ray, struct object* obj) {
struct colour c = {.r = 210, .g = 105, .b = 30, .sp=CS_RGB};
return c;
}
@ -335,11 +340,11 @@ struct colour yeet_green(struct ray *ray, struct object* obj) { @@ -335,11 +340,11 @@ struct colour yeet_green(struct ray *ray, struct object* obj) {
*/
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_green);
struct object trunk = new_object(position, rotation, scale, sdf_phat_vert_line, yeet_brown);
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_whit);
struct vec* leaf_pos = add_vec_ip(new_vec3(0, -1.5, 0), position);
struct object leaves = new_object(leaf_pos, rotation, scale, sdf_sphere, yeet_green);
leaves.base_col = (struct colour){.r = 0, .g = 255, .b = 0, .sp = CS_RGB};
tree[0] = trunk;

2
main.c

@ -151,7 +151,7 @@ void setup_camera_scene() @@ -151,7 +151,7 @@ void setup_camera_scene()
// struct object other_white_sphere = new_sphere(new_vec3(0.75, 0, 8), 0, 1);
const double lower_pos_bound = -5;
const double upper_pos_bound = -5;
const double upper_pos_bound = 5;
const int num_trees = 4;
struct object* scene_objects = malloc(2 * num_trees * sizeof(struct object));
for (int i = 0; i < 2 * num_trees; i+=2) {

Loading…
Cancel
Save