Continuing working on dumping the world

This commit is contained in:
Godzil
2020-02-28 09:29:09 +00:00
parent 8ceb68fdff
commit b4ae737b40
19 changed files with 164 additions and 22 deletions

View File

@@ -38,4 +38,16 @@ Intersect Sphere::localIntersect(Ray r)
Tuple Sphere::localNormalAt(Tuple point)
{
return (point - Point(0, 0, 0)).normalise();
}
void Sphere::dumpMe(FILE *fp)
{
fprintf(fp, "\"Type\": \"Sphere\",\n");
Tuple t = this->transformMatrix * Point(0, 0, 0);
fprintf(fp, "\"center\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
t.x, t.y, t.z);
t = this->transformMatrix * Point(1, 1, 1);
fprintf(fp, "\"radius\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
t.x, t.y, t.z);
Shape::dumpMe(fp);
}