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

@@ -9,6 +9,8 @@
#include <world.h>
#include <light.h>
#include <shape.h>
#include <stdio.h>
#include <string.h>
#define MIN_ALLOC (2)
@@ -197,4 +199,32 @@ Colour World::refractedColour(Computation comps, uint32_t depthCount)
Tuple hitColour = this->colourAt(refractedRay, depthCount - 1) * comps.material->transparency;
return Colour(hitColour.x, hitColour.y, hitColour.z);
}
void World::dumpMe(FILE *fp)
{
int i;
/* JSON Opening */
fprintf(fp, "{\n");
fprintf(fp, "\"Lights\": {\n");
for(i = 0; i < this->lightCount; i++)
{
fprintf(fp, "\"%d\": {\n", i);
//this->lightList[i]->dumpMe(fp);
fprintf(fp, "},\n");
}
fprintf(fp, "},\n");
fprintf(fp, "\"Objects\": {\n");
for(i = 0; i < this->objectCount; i++)
{
fprintf(fp, "\"%d\": {\n", i);
this->objectList[i]->dumpMe(fp);
fprintf(fp, "},\n");
}
fprintf(fp, "},\n");
/* JSON Closing */
fprintf(fp, "}\n");
}