rendered paste bodyColor lightPoint(Object *obj, Vector *hitPt, Vector *norm, Scene *scene) {
// Set temp color to black
Color tempCol;
tempCol.x = 0;
tempCol.y = 0;
tempCol.z = 0;
Hit tempHit;
Ray *shadow;
shadow = malloc(sizeof(Ray));
// Find lights
node_t *node = scene->lights->head;
while (node != NULL) {
assert(node->data);
Object *temp = (Object *)(node->data);
// Add ambient light coloring
tempCol.x += temp->ambient.x + obj->ambient.x;
tempCol.y += temp->ambient.y + obj->ambient.y;
tempCol.z += temp->ambient.z + obj->ambient.z;
// "Shadow ray"
shadow->p.x = hitPt->x;
shadow->p.y = hitPt->y;
shadow->p.z = hitPt->z;
Vector *temp2 = (Vector *)temp->priv; // prevent dereference error
shadow->dir.x = temp2->x;
shadow->dir.y = temp2->y;
shadow->dir.z = temp2->z;
shadow->dir = v3Diff(temp2, hitPt); // Light location - hit point
shadow->dir = v3Unitvec(&shadow->dir); // Set the direction as a unit vector
/* Check for a hit */
tempHit = intersectObjects(scene, shadow);
if(tempHit.obj == NULL) {
tempCol.x += obj->diffuse.x;
tempCol.y += obj->diffuse.y;
tempCol.z += obj->diffuse.z;
} // if
node = node->next;
} // while
free(shadow);
return tempCol;
} // lightPoint