added getNormalAt() to Shape & Sphere, trying to get basic lighting

git-svn-id: svn://anubis/fart/trunk@44 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop committed 2009-01-23 18:09:27 +00:00
1 parent 801f61f48c
commit 761925220b
6 files changed
+23 -7

No files matched your search

+2
View File
@@ -4,6 +4,7 @@
#include "util/Solver.h"
#include "util/Ray.h"
#include "util/Vector.h"
#include "util/Transform.h"
class Shape
@@ -12,6 +13,7 @@ class Shape
virtual Solver::Result intersect(const Ray & ray) = 0;
void setTransform(const Transform & t) { m_transform = t; }
Transform & getTransform() { return m_transform; }
virtual Vector getNormalAt(const Vector & pt) = 0;
protected:
Transform m_transform;
+6
View File
@@ -34,3 +34,9 @@ Solver::Result Sphere::intersect(const Ray & ray)
}
return res;
}
Vector Sphere::getNormalAt(const Vector & pt)
{
Vector normal = pt;
return normal.normalize();
}
+1
View File
@@ -9,6 +9,7 @@ class Sphere : public Shape
public:
Sphere(double radius);
Solver::Result intersect(const Ray & ray);
Vector getNormalAt(const Vector & pt);
private:
double m_radius;