Exemple #1
0
/*======== double calculate_dot() ==========
  Inputs:   struct matrix *points
	int i
  Returns: The dot product of a surface normal and
	a view vector

  calculates the dot product of the surface normal to
  triangle points[i], points[i+1], points[i+2] and a
  view vector (use <0, 0, -1> to start.

  04/17/12 16:38:34
  jonalf
  ====================*/
double calculate_dot( struct matrix *points, int i ) {

  vector normal;
	vector view;
  double dot;

  calculate_surface_normal(points, i, normal);

	//set up view vector
	view[X] = 0;
	view[Y] = 0;
	view[Z] = -1;

	//calculate dot product
	dot = dot_product(normal, view);

	return dot;
}
Exemple #2
0
color calculate_I(struct matrix *polygons, screen s, color c, int i){
  color Ia, Id, Is;
  int li;
  calculate_surface_normal(polygons, i);

  for(li=0; li<=light_index; li++){
    normalize_light(polygons, i, li);
  }

  Ia = calculate_Ia();
  Id = calculate_Id(polygons, s, c, i);
  Is = calculate_Is(polygons, s, c, i);
  //printf("Ia: r:%d, g:%d, b:%d\n",Ia.red,Ia.green,Ia.blue);
  //printf("Id: r:%d, g:%d, b:%d\n",Id.red,Id.green,Id.blue);
  //printf("Is: r:%d, g:%d, b:%d\n\n",Is.red,Is.green,Is.blue);

  c.red = Ia.red + Id.red + Is.red;
  c.green = Ia.green + Id.green + Is.green;
  c.blue = Ia.blue + Id.blue + Is.blue;

  return c;
}