#include "view.h"

Shading *newShading(red,green,blue)
/*returns a shading with the given diffuse reflectivity values*/
REAL red,green,blue;
{
	Shading *shade;
	
	shade = Malloc(Shading,1);
	shade->reflection.red = red;
	shade->reflection.green = green;
	shade->reflection.blue = blue;
	
	/*unless it is overwritten later the colour is the same
	  as the reflectivity*/
	shade->colour.red = red;
	shade->colour.green = green;
	shade->colour.blue = blue;
	
	shade->noOfLights = 0;
	
	return(shade);
}


Lighting *newLighting(ambient)
Light *ambient;
{
	Lighting *lighting;
	
	lighting = Malloc(Lighting,1);
	lighting->ambient = *ambient;
	lighting->noOfLights = 0;
	
	return(lighting);
}

void changeAmbientLighting(lighting,ambient)
Lighting *lighting;
Light *ambient;
{
	lighting->ambient = *ambient;
}

void addLightToLighting(lighting,light)
Lighting *lighting;
Light *light;
{
	lighting->light[lighting->noOfLights] = *light;
	++lighting->noOfLights;
}

void setDirectionOfLight(light,x,y,z)
Light *light;
REAL x,y,z;
{
	MAKEVector(light->direction,x,y,z);
}

void setIntensityOfLight(light,red,green,blue)
Light *light;
REAL red,green,blue;
{
	light->intensity.red = red;
	light->intensity.green = green;
	light->intensity.blue = blue;
}

void setPositionOfLight(light,x,y,z)
Light *light;
REAL x,y,z;
{
	light->position.x = x;
	light->position.y = y;
	light->position.z = z;
}
