Start working on dumping the world (to a JSON file) for debug purposes.

This commit is contained in:
Godzil
2020-02-27 18:03:08 +00:00
parent 2926166ce6
commit c369d2fe2d
15 changed files with 116 additions and 0 deletions

View File

@@ -66,4 +66,23 @@ Colour Material::lighting(Light light, Tuple point, Tuple eyeVector, Tuple norma
finalColour = emissiveColour + ambientColour + diffuseColour + specularColour;
return Colour(finalColour.x, finalColour.y, finalColour.z);
}
void Material::dumpMe(FILE *fp)
{
fprintf(fp, "\"Colour\": {\"red\": %f, \"green\": %f, \"blue\": %f},\n", this->colour.x, this->colour.y, this->colour.z);
fprintf(fp, "\"Ambient\": %f,\n", this->ambient);
fprintf(fp, "\"Diffuse\": %f,\n", this->diffuse);
fprintf(fp, "\"Specular\": %f,\n", this->specular);
fprintf(fp, "\"Shininess\": %f,\n", this->shininess);
fprintf(fp, "\"Reflective\": %f,\n", this->reflective);
fprintf(fp, "\"Transparency\": %f,\n", this->transparency);
fprintf(fp, "\"Emissive\": %f,\n", this->emissive);
fprintf(fp, "\"RefractiveIndex\": %f,\n", this->refractiveIndex);
if (this->pattern)
{
fprintf(fp, "\"Pattern\": {\n", this->emissive);
this->pattern->dumpMe(fp);
fprintf(fp, "},\n");
}
}

View File

@@ -73,4 +73,12 @@ BoundingBox Shape::getBounds()
ret.min = this->objectToWorld(Point(-1, -1, -1));
ret.max = this->objectToWorld(Point(1, 1, 1));
return ret;
}
void Shape::dumpMe(FILE *fp)
{
fprintf(fp, "\"Material\": {\n");
this->material.dumpMe(fp);
fprintf(fp, "},\n");
fprintf(fp, "\"DropShadow\": %d,\n", this->dropShadow);
}