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

@@ -10,6 +10,7 @@
#define DORAYME_BOUNDINGBOX_H
#include <renderstat.h>
#include <stdio.h>
struct BoundingBox
{
@@ -118,6 +119,16 @@ public:
return false;
}
void dumpMe(FILE *fp)
{
Tuple t = this->min;
fprintf(fp, "\"min\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
t.x, t.y, t.z);
t = this->max;
fprintf(fp, "\"max\": { \"x\": %f, \"y\": %f, \"z\": %f}, \n",
t.x, t.y, t.z);
}
};
#endif /* DORAYME_BOUNDINGBOX_H */

View File

@@ -13,6 +13,7 @@
#include <ray.h>
#include <intersect.h>
#include <renderstat.h>
#include <stdio.h>
class Cone : public Shape {
protected:
@@ -31,6 +32,8 @@ public:
Cone() : minCap(-INFINITY), maxCap(INFINITY), isClosed(false), Shape(SHAPE_CONE) { stats.addCone(); };
BoundingBox getBounds();
bool haveFiniteBounds() { return !(isinf(this->minCap) || isinf(this->maxCap)); };
void dumpMe(FILE *fp);
};
#endif /* DORAYME_CONE_H */

View File

@@ -13,6 +13,7 @@
#include <ray.h>
#include <intersect.h>
#include <renderstat.h>
#include <stdio.h>
class Cube : public Shape {
private:
@@ -24,6 +25,8 @@ private:
public:
Cube() : Shape(SHAPE_CUBE) { stats.addCube(); };
void dumpMe(FILE *fp);
};
#endif /* DORAYME_CUBE_H */

View File

@@ -13,6 +13,7 @@
#include <ray.h>
#include <intersect.h>
#include <renderstat.h>
#include <stdio.h>
class Cylinder : public Shape {
private:
@@ -32,6 +33,8 @@ public:
BoundingBox getBounds();
bool haveFiniteBounds() { return !(isinf(this->minCap) || isinf(this->maxCap)); };
void dumpMe(FILE *fp);
};
#endif //DORAYME_CYLINDER_H

View File

@@ -10,6 +10,7 @@
#define DORAYME_GROUP_H
#include <shape.h>
#include <stdio.h>
/* TODO: Add a way to force(?) material from group to be applied on childs */
@@ -43,6 +44,8 @@ public:
void updateTransform();
Group();
void dumpMe(FILE * fp);
};
#endif /* DORAYME_GROUP_H */

View File

@@ -12,6 +12,7 @@
#include <tuple.h>
#include <colour.h>
#include <renderstat.h>
#include <stdio.h>
enum LightType
{
@@ -33,6 +34,8 @@ public:
bool operator==(const Light &b) const { return this->intensity == b.intensity &&
this->position == b.position &&
this->type == b.type; };
void dumpMe(FILE *fp);
};
#endif /* DORAYME_LIGHT_H */

View File

@@ -68,27 +68,27 @@ public:
void setMaxIntersect(uint32_t count) { if (this->maxIntersectOnARay<count) { this->maxIntersectOnARay = count; } };
void printStats() {
printf("Rendering statistics:\n");
printf("Cones : %ld\n", this->coneCount);
printf("Cubes : %ld\n", this->cubeCount);
printf("Cylinders : %ld\n", this->cylinderCount);
printf("Groups : %ld\n", this->groupCount);
printf("Lights : %ld\n", this->lightCount);
printf("Planes : %ld\n", this->planeCount);
printf("Spheres : %ld\n", this->sphereCount);
printf("Triangles : %ld\n", this->triangleCount);
printf("Cones : %lld\n", this->coneCount);
printf("Cubes : %lld\n", this->cubeCount);
printf("Cylinders : %lld\n", this->cylinderCount);
printf("Groups : %lld\n", this->groupCount);
printf("Lights : %lld\n", this->lightCount);
printf("Planes : %lld\n", this->planeCount);
printf("Spheres : %lld\n", this->sphereCount);
printf("Triangles : %lld\n", this->triangleCount);
printf("==================================================\n");
printf("Pixel rendered : %ld\n", this->pixelCount);
printf("Ray casted : %ld\n", this->rayCount);
printf("Light Ray casted : %ld\n", this->lightRayEmitedCount);
printf("Reflection ray casted : %ld\n", this->reflectionRayCount);
printf("Refraction ray casted : %ld\n", this->refractedRayCount);
printf("Intersect object created: %ld\n", this->intersectCount);
printf("Intersection created : %ld\n", this->intersectionCount);
printf("Malloc called : %ld\n", this->mallocCallCount);
printf("Realloc called : %ld\n", this->reallocCallCount);
printf("Bounding box missed : %ld\n", this->discardedIntersectCount);
printf("Min depth atteined : %ld\n", this->maxDepthAttained);
printf("Max intersect count : %ld\n", this->maxIntersectOnARay);
printf("Pixel rendered : %lld\n", this->pixelCount);
printf("Ray casted : %lld\n", this->rayCount);
printf("Light Ray casted : %lld\n", this->lightRayEmitedCount);
printf("Reflection ray casted : %lld\n", this->reflectionRayCount);
printf("Refraction ray casted : %lld\n", this->refractedRayCount);
printf("Intersect object created: %lld\n", this->intersectCount);
printf("Intersection created : %lld\n", this->intersectionCount);
printf("Malloc called : %lld\n", this->mallocCallCount);
printf("Realloc called : %lld\n", this->reallocCallCount);
printf("Bounding box missed : %lld\n", this->discardedIntersectCount);
printf("Min depth atteined : %lld\n", this->maxDepthAttained);
printf("Max intersect count : %lld\n", this->maxIntersectOnARay);
printf("==================================================\n");
};
};

View File

@@ -13,6 +13,7 @@
#include <ray.h>
#include <intersect.h>
#include <renderstat.h>
#include <stdio.h>
class Sphere : public Shape
{
@@ -23,6 +24,9 @@ protected:
public:
Sphere() : Shape(SHAPE_SPHERE) { stats.addSphere(); };
/* All sphere are at (0, 0, 0) and radius 1 in the object space */
void dumpMe(FILE *fp);
};
/* Mostly for test purposes */

View File

@@ -10,6 +10,7 @@
#define DORAYME_TRIANGLE_H
#include <shape.h>
#include <stdio.h>
class Triangle : public Shape
{
@@ -25,6 +26,8 @@ public:
Triangle(Point p1, Point p2, Point p3);
BoundingBox getBounds();
void dumpMe(FILE *fp);
};
#endif /* DORAYME_TRIANGLE_H */