include/material.h
branchpyrit
changeset 82 930a2d3ecaed
parent 81 9dbb9c8c115b
child 88 f7edb3b90816
equal deleted inserted replaced
81:9dbb9c8c115b 82:930a2d3ecaed
    49  * general colour map
    49  * general colour map
    50  */
    50  */
    51 class ColourMap
    51 class ColourMap
    52 {
    52 {
    53 public:
    53 public:
       
    54 	virtual ~ColourMap() {};
    54 	virtual Colour map(const Float &val) = 0;
    55 	virtual Colour map(const Float &val) = 0;
    55 };
    56 };
    56 
    57 
    57 /**
    58 /**
    58  * linear colour map
    59  * linear colour map
   104 	Vector3 center;
   105 	Vector3 center;
   105 	Float invsize;
   106 	Float invsize;
   106 public:
   107 public:
   107 	TextureMap(const Vector3 &acenter, const Float &size):
   108 	TextureMap(const Vector3 &acenter, const Float &size):
   108 		center(acenter), invsize(1./size) {};
   109 		center(acenter), invsize(1./size) {};
       
   110 	virtual ~TextureMap() {};
   109 	virtual void map(const Vector3 &point, Float &u, Float &v) = 0;
   111 	virtual void map(const Vector3 &point, Float &u, Float &v) = 0;
   110 };
   112 };
   111 
   113 
   112 /**
   114 /**
   113  * planar mapping
   115  * planar mapping
   255 		map->map(point, u,v);
   257 		map->map(point, u,v);
   256 		u = u - 0.5;
   258 		u = u - 0.5;
   257 		u -= floor(u);
   259 		u -= floor(u);
   258 		v = -(v - 0.5);
   260 		v = -(v - 0.5);
   259 		v -= floor(v);
   261 		v -= floor(v);
   260 		return pixmap->get(u*pixmap->getWidth(), v*pixmap->getHeight());
   262 		return pixmap->get((int)(u*pixmap->getWidth()), (int)(v*pixmap->getHeight()));
   261 	};
   263 	};
   262 };
   264 };
   263 
   265 
   264 /**
   266 /**
   265  * 2D checkers texture
   267  * 2D checkers texture