X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=sphere.hh;h=5ee9d0fe1dc376cc3077506d305c8113f1f736ac;hb=9f13ae5fe777dd4f7a9302f6dcf3e0d99a1ce65d;hp=cbacac9e5fedf590f9e66c0bdf3d1e4d04c696d4;hpb=a737ad45e690daa3b39b8885e2b6574d2ea48833;p=chaz%2Frasterize diff --git a/sphere.hh b/sphere.hh index cbacac9..5ee9d0f 100644 --- a/sphere.hh +++ b/sphere.hh @@ -8,7 +8,6 @@ #ifndef _SPHERE_HH_ #define _SPHERE_HH_ -#include "color.hh" #include "element.hh" @@ -20,14 +19,13 @@ namespace rt { */ 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() @@ -61,9 +59,17 @@ public: 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; } };