Trying to make the dump a bit more usefull and slightly less cluttered
This commit is contained in:
@@ -214,7 +214,20 @@ void OBJFile::dumpMe(FILE * fp)
|
||||
fprintf(fp, "\"Objects\": {\n");
|
||||
this->baseGroup->dumpMe(fp);
|
||||
fprintf(fp, "},\n");
|
||||
|
||||
fprintf(fp, "\"Vertices\": {\n");
|
||||
for(i = 1; i < this->vertexCount + 1; i++)
|
||||
{
|
||||
fprintf(fp, "\"v[%d]\": { \"x\": %f, \"y\": %f, \"z\": %f },\n", i,
|
||||
this->vertices(i).x, this->vertices(i).y, this->vertices(i).z);
|
||||
}
|
||||
fprintf(fp, "},\n");
|
||||
fprintf(fp, "\"NormalVertices\": {\n");
|
||||
for(i = 1; i < this->vertexNormalCount + 1; i++)
|
||||
{
|
||||
fprintf(fp, "\"vn[%d]\": { \"x\": %f, \"y\": %f, \"z\": %f },\n", i,
|
||||
this->verticesNormal(i).x, this->verticesNormal(i).y, this->verticesNormal(i).z);
|
||||
}
|
||||
fprintf(fp, "},\n");
|
||||
Shape::dumpMe(fp);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,9 +91,12 @@ BoundingBox Shape::getBounds()
|
||||
|
||||
void Shape::dumpMe(FILE *fp)
|
||||
{
|
||||
fprintf(fp, "\"Material\": {\n");
|
||||
this->material.dumpMe(fp);
|
||||
fprintf(fp, "},\n");
|
||||
if (this->materialSet)
|
||||
{
|
||||
fprintf(fp, "\"Material\": {\n");
|
||||
this->material.dumpMe(fp);
|
||||
fprintf(fp, "},\n");
|
||||
}
|
||||
fprintf(fp, "\"DropShadow\": %d,\n", this->dropShadow);
|
||||
fprintf(fp, "\"BoundingBox\": {\n");
|
||||
this->getBounds().dumpMe(fp);
|
||||
|
||||
@@ -25,4 +25,18 @@ Tuple SmoothTriangle::localNormalAt(Tuple point, Intersection *hit)
|
||||
return (this->n2 * hit->u +
|
||||
this->n3 * hit->v +
|
||||
this->n1 * (1 - hit->u - hit->v)).normalise();
|
||||
}
|
||||
|
||||
void SmoothTriangle::dumpMe(FILE *fp)
|
||||
{
|
||||
Tuple t = this->n1;
|
||||
fprintf(fp, "\"n1\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
|
||||
t.x, t.y, t.z);
|
||||
t = this->n2;
|
||||
fprintf(fp, "\"n2\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
|
||||
t.x, t.y, t.z);
|
||||
t = this->n3;
|
||||
fprintf(fp, "\"n3\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
|
||||
t.x, t.y, t.z);
|
||||
Triangle::dumpMe(fp);
|
||||
}
|
||||
@@ -73,6 +73,8 @@ BoundingBox Triangle::getLocalBounds()
|
||||
void Triangle::dumpMe(FILE *fp)
|
||||
{
|
||||
fprintf(fp, "\"Type\": \"Triangle\",\n");
|
||||
|
||||
/* World points*/
|
||||
Tuple t = this->transformMatrix * this->p1;
|
||||
fprintf(fp, "\"p1\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
|
||||
t.x, t.y, t.z);
|
||||
@@ -82,5 +84,16 @@ void Triangle::dumpMe(FILE *fp)
|
||||
t = this->transformMatrix * this->p3;
|
||||
fprintf(fp, "\"p3\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
|
||||
t.x, t.y, t.z);
|
||||
|
||||
/* Local points */
|
||||
t = this->p1;
|
||||
fprintf(fp, "\"lp1\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
|
||||
t.x, t.y, t.z);
|
||||
t = this->p2;
|
||||
fprintf(fp, "\"lp2\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
|
||||
t.x, t.y, t.z);
|
||||
t = this->p3;
|
||||
fprintf(fp, "\"lp3\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
|
||||
t.x, t.y, t.z);
|
||||
Shape::dumpMe(fp);
|
||||
}
|
||||
Reference in New Issue
Block a user