Group should work now.
This commit is contained in:
@@ -58,7 +58,7 @@ public:
|
||||
|
||||
void updateTransform();
|
||||
Tuple worldToObject(Tuple point) { return this->inverseTransform * point; };
|
||||
Tuple normalToWorld(Tuple normalVector) { return (this->transposedInverseTransform * normalVector).normalise(); };
|
||||
Tuple normalToWorld(Tuple normalVector);
|
||||
|
||||
void setTransform(Matrix transform);
|
||||
void setMaterial(Material material) { this->material = material; };
|
||||
|
||||
@@ -24,6 +24,7 @@ Intersect::Intersect()
|
||||
Intersect::~Intersect()
|
||||
{
|
||||
/* Free stuff */
|
||||
free(this->list);
|
||||
}
|
||||
|
||||
void Intersect::add(Intersection i)
|
||||
|
||||
@@ -18,7 +18,7 @@ Pattern::Pattern(Colour a, Colour b): a(a), b(b)
|
||||
|
||||
Colour Pattern::patternAtObject(Shape *object, Tuple worldPoint)
|
||||
{
|
||||
Tuple objectPoint = object->inverseTransform * worldPoint;
|
||||
Tuple objectPoint = object->worldToObject(worldPoint);
|
||||
Tuple patternPoint = this->inverseTransform * objectPoint;
|
||||
|
||||
return this->patternAt(patternPoint);
|
||||
|
||||
@@ -27,18 +27,25 @@ Intersect Shape::intersect(Ray r)
|
||||
return this->localIntersect(this->invTransform(r));
|
||||
};
|
||||
|
||||
Tuple Shape::normalAt(Tuple point)
|
||||
Tuple Shape::normalToWorld(Tuple normalVector)
|
||||
{
|
||||
Tuple local_point = this->inverseTransform * point;
|
||||
|
||||
Tuple local_normal = this->localNormalAt(local_point);
|
||||
|
||||
Tuple world_normal = this->transposedInverseTransform * local_normal;
|
||||
Tuple world_normal = this->transposedInverseTransform * normalVector;
|
||||
|
||||
/* W may get wrong, so hack it. This is perfectly normal as we are using a 4x4 matrix instead of a 3x3 */
|
||||
world_normal.w = 0;
|
||||
|
||||
return world_normal.normalise();
|
||||
};
|
||||
|
||||
Tuple Shape::normalAt(Tuple point)
|
||||
{
|
||||
Tuple local_point = this->worldToObject(point);
|
||||
|
||||
Tuple local_normal = this->localNormalAt(local_point);
|
||||
|
||||
Tuple world_normal = this->normalToWorld(local_normal);
|
||||
|
||||
return world_normal;
|
||||
}
|
||||
|
||||
void Shape::updateTransform()
|
||||
|
||||
Reference in New Issue
Block a user