work on raytracing

This commit is contained in:
2017-09-06 08:34:20 +02:00
parent c21925e86f
commit e4cd9c6b8d
32 changed files with 2790 additions and 3 deletions

21
geo/volume/BVH.h Normal file
View File

@@ -0,0 +1,21 @@
#ifndef BOUNDINGVOLUMEHIERARCHY_H
#define BOUNDINGVOLUMEHIERARCHY_H
#include "BoundingVolume.h"
#include "BoundingVolumeAABB.h"
#include "BoundingVolumeSphere.h"
class BVH {
public:
/** add a new volume to the tree */
void add(BoundingVolume* bv) {
}
};
#endif // BOUNDINGVOLUMEHIERARCHY_H

View File

@@ -0,0 +1,18 @@
#ifndef BOUNDINGVOLUME_H
#define BOUNDINGVOLUME_H
#include "../Point3.h"
class BoundingVolume {
public:
/** get the volume's size (something like m^3) */
virtual float getVolumeSize() const = 0;
/** does the volume contain the given point? */
virtual bool contains(const Point3 p) const = 0;
};
#endif // BOUNDINGVOLUME_H

View File

@@ -0,0 +1,30 @@
#ifndef BOUNDINGVOLUMEBOX_H
#define BOUNDINGVOLUMEBOX_H
#include "BoundingVolume.h"
#include "../Point3.h"
class BoundingVolumeAABB : public BoundingVolume {
static constexpr float MAX = +99999;
static constexpr float MIN = -99999;
/** minimum */
Point3 p1;
/** maximum */
Point3 p2;
public:
/** empty ctor */
BoundingVolumeAABB() : p1(MAX,MAX,MAX), p2(MIN,MIN,MIN) {;}
float getVolumeSize() const override {
return (p2.x-p1.x) * (p2.y-p1.y) * (p2.z-p1.z);
}
};
#endif // BOUNDINGVOLUMEBOX_H

View File

@@ -0,0 +1,4 @@
#ifndef BOUNDINGVOLUMEBOX_H
#define BOUNDINGVOLUMEBOX_H
#endif // BOUNDINGVOLUMEBOX_H

View File

@@ -0,0 +1,4 @@
#ifndef BOUNDINGVOLUMEHIERARCHY_H
#define BOUNDINGVOLUMEHIERARCHY_H
#endif // BOUNDINGVOLUMEHIERARCHY_H

View File

@@ -0,0 +1,27 @@
#ifndef BOUNDINGVOLUMESPHERE_H
#define BOUNDINGVOLUMESPHERE_H
#include "../Point3.h"
class BoundingVolumeSphere : public BoundingVolume {
private:
Point3 center;
float radius;
public:
float getVolumeSize() const override {
return (4.0f / 3.0f) * M_PI * (radius*radius*radius);
}
/** does the volume contain the given point? */
virtual bool contains(const Point3 p) const {
return (center-p).length() <= radius;
}
};
#endif // BOUNDINGVOLUMESPHERE_H