/******************************************************************/ /* Lighting functions, Project 6, CS345 */ /******************************************************************/ #include #include #include #include #include #include #include #include #include "raytrace.h" material* makeMaterial(GLfloat r, GLfloat g, GLfloat b, GLfloat amb) { material* m; /* allocate memory */ m = (material*) malloc(sizeof(material)); /* put stuff in it */ m->c.r = r; m->c.g = g; m->c.b = b; m->amb = amb; return(m); } /* LIGHTING CALCULATIONS */ /* shade */ /* color of point p with normal vector n and material m returned in c */ void shade(point* p,vector* n,material* m, color* c) { /* so far, just finds ambient component of color */ c->r = m->amb * m->c.r; c->g = m->amb * m->c.g; c->b = m->amb * m->c.b; /* clamp color values to 1.0 */ if (c->r > 1.0) c->r = 1.0; if (c->g > 1.0) c->g = 1.0; if (c->b > 1.0) c->b = 1.0; }