#include <checker.h>
Inherits Material.
Inheritance diagram for Checker:
Public Member Functions | |
Checker (Material *m1, Material *m2, int nu, int nv) | |
Constructs a checkerboard material consisting of two sub-materials, one for odd and one for even squares. | |
virtual | ~Checker () |
Destructor. | |
Color | getBRDF (const Intersection &is, const Vector &L) |
Returns the BRDF at the intersection is for the light direction L. | |
float | getReflectivity (const Intersection &is) const |
Returns the reflectivity of the material in the range [0,1], where 0 means not reflective at all, and 1 gives a perfect mirror. | |
float | getTransparency (const Intersection &is) const |
Returns the transparency of the material in the range [0,1], where 0 is fully opaque, and 1 is fully transparent. | |
void | setReflectivity (float r) |
Sets the reflectivity of the material by setting the reflectivity of the two sub-materials. | |
void | setTransparency (float t) |
Sets the transparency of the material by setting the transparency of the two sub-materials. | |
virtual float | getIndexOfRefraction () const |
Returns the index of refraction for the material. | |
virtual void | setIndexOfRefraction (float n) |
Sets the index of refraction. Empty space is 1, denser materials higher. | |
Protected Member Functions | |
int | getType (const Intersection &is) const |
Returns the type of the checker at the intersection point, 0 or 1, where 0 is even squares and 1 is odd. | |
Protected Attributes | |
Material * | mMat [2] |
The two materials. | |
int | mNumU |
Number of squares along u. | |
int | mNumV |
Number of squares along v. | |
float | mReflectivity |
The reflectivity of the material. | |
float | mTransparency |
The transparency of the material. | |
float | mRefractionIndex |
Index of refraction for the material. |
This material takes pointers to two other materials in the constructor, and alternately chooses between them based on the texture coordinates. Hence, it gives a square pattern, where the odd/even squares are made of different materials. It can be used for creating checker boards. The reflectivity and transparency at an intersection point is determined by the material that is used for the square the ray hit. However, only one index of refraction is used for the entire material, and must be set on the Checker material instead of its sub-materials.