include/scene.h
branchpyrit
changeset 42 fbdeb3e04543
parent 40 929aad02c5f2
child 44 3763b26244f0
equal deleted inserted replaced
41:c1080cb5bd6d 42:fbdeb3e04543
    80 };
    80 };
    81 
    81 
    82 class Texture
    82 class Texture
    83 {
    83 {
    84 public:
    84 public:
       
    85 	virtual Colour evaluate(Vector3 point) = 0;
       
    86 };
       
    87 
       
    88 class Material
       
    89 {
       
    90 public:
    85 	Colour colour;
    91 	Colour colour;
    86 	Colour evaluate(Vector3 point)
       
    87 	{
       
    88 		Float sum = 0.0;
       
    89 		for (int i = 1; i < 5; i++)
       
    90 			sum += fabsf(perlin(point.x*i, point.y*i, point.z*i))/i;
       
    91 		Float value = sinf(point.x + sum)/2 + 0.5;
       
    92 		return Colour(value*colour.r, value*colour.g, value*colour.b);
       
    93 	};
       
    94 };
       
    95 
       
    96 class Material
       
    97 {
       
    98 public:
       
    99 	Float ambient, diffuse, specular, shininess; // Phong constants
    92 	Float ambient, diffuse, specular, shininess; // Phong constants
   100 	Float reflectivity; // how much reflective is the surface
    93 	Float reflectivity; // how much reflective is the surface
   101 	Float transmissivity, refract_index; // part of light which can be refracted; index of refraction
    94 	Float transmissivity, refract_index; // part of light which can be refracted; index of refraction
   102 	Texture texture;
    95 	Texture *texture;
   103 
    96 
   104 	Material(const Colour &acolour) {
    97 	Material(const Colour &acolour): colour(acolour), texture(NULL)
   105 		texture.colour = acolour;
    98 	{
   106 		ambient = 0.2;
    99 		ambient = 0.2;
   107 		diffuse = 0.8;
   100 		diffuse = 0.8;
   108 		specular = 0.2;
   101 		specular = 0.2;
   109 		shininess = 0.5;
   102 		shininess = 0.5;
   110 		reflectivity = 0.2;
   103 		reflectivity = 0.2;