#ifndef _SPHERE_HH_
#define _SPHERE_HH_
-#include "color.hh"
#include "element.hh"
*/
class sphere : public element
{
-public:
-
- color_t material;
vec_t origin;
scal_t radius;
- sphere(vec_t o, scal_t r = S(1.0), color_t color = COLOR_WHITE) :
- origin(o), radius(r), material(color)
+public:
+
+ sphere(vec_t o, scal_t r = S(1.0)) :
+ origin(o), radius(r)
{}
virtual ~sphere()
return true;
}
- virtual color_t color(vec_t point) const
+ virtual vec_t txcoord(vec_t point) const
{
- return material;
+ vec_t uv = VEC_ZERO;
+
+ scal_t theta = scal_atan2(point.z, point.x);
+ scal_t phi = asin(point.y / radius);
+
+ uv.x = theta / (S(2.0) * M_PI) + S(0.5);
+ uv.y = phi / M_PI + S(0.5);
+
+ return uv;
}
};