Add a parameter for shapes to not drop shadow.
This commit is contained in:
@@ -40,6 +40,7 @@ public:
|
|||||||
Matrix transformMatrix;
|
Matrix transformMatrix;
|
||||||
Matrix inverseTransform;
|
Matrix inverseTransform;
|
||||||
Material material;
|
Material material;
|
||||||
|
bool dropShadow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Shape(ShapeType = SHAPE_NONE);
|
Shape(ShapeType = SHAPE_NONE);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
Shape::Shape(ShapeType type)
|
Shape::Shape(ShapeType type)
|
||||||
{
|
{
|
||||||
|
this->dropShadow = true;
|
||||||
this->type = type;
|
this->type = type;
|
||||||
this->transformMatrix = Matrix4().identity();
|
this->transformMatrix = Matrix4().identity();
|
||||||
this->inverseTransform = this->transformMatrix.inverse();
|
this->inverseTransform = this->transformMatrix.inverse();
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ Intersect World::intersect(Ray r)
|
|||||||
|
|
||||||
Tuple World::shadeHit(Computation comps, uint32_t depthCount)
|
Tuple World::shadeHit(Computation comps, uint32_t depthCount)
|
||||||
{
|
{
|
||||||
/* TODO: Add support for more than one light */
|
|
||||||
uint32_t lightIndex;
|
uint32_t lightIndex;
|
||||||
|
|
||||||
Tuple surface = Colour(0, 0, 0);
|
Tuple surface = Colour(0, 0, 0);
|
||||||
@@ -136,20 +135,25 @@ Tuple World::colourAt(Ray r, uint32_t depthCount)
|
|||||||
|
|
||||||
bool World::isShadowed(Tuple point, uint32_t light)
|
bool World::isShadowed(Tuple point, uint32_t light)
|
||||||
{
|
{
|
||||||
/* TODO: Add support for more than one light */
|
|
||||||
|
|
||||||
Tuple v = this->lightList[light]->position - point;
|
Tuple v = this->lightList[light]->position - point;
|
||||||
double distance = v.magnitude();
|
double distance = v.magnitude();
|
||||||
Tuple direction = v.normalise();
|
Tuple direction = v.normalise();
|
||||||
|
|
||||||
Ray r = Ray(point, direction);
|
Ray r = Ray(point, direction);
|
||||||
Intersection h = this->intersect(r).hit();
|
Intersect xs = this->intersect(r);
|
||||||
|
|
||||||
if (!h.nothing() && (h.t < distance))
|
int i;
|
||||||
|
for(i = 0; i < xs.count(); i++)
|
||||||
|
{
|
||||||
|
Intersection h = xs[i];
|
||||||
|
|
||||||
|
if (h.t < 0) continue;
|
||||||
|
|
||||||
|
if ((h.object->dropShadow == true) && (h.t < distance))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user