work on raytracing
This commit is contained in:
21
geo/volume/BVH.h
Normal file
21
geo/volume/BVH.h
Normal 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
|
||||
18
geo/volume/BoundingVolume.h
Normal file
18
geo/volume/BoundingVolume.h
Normal 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
|
||||
30
geo/volume/BoundingVolumeAABB.h
Normal file
30
geo/volume/BoundingVolumeAABB.h
Normal 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
|
||||
4
geo/volume/BoundingVolumeBox.h
Normal file
4
geo/volume/BoundingVolumeBox.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef BOUNDINGVOLUMEBOX_H
|
||||
#define BOUNDINGVOLUMEBOX_H
|
||||
|
||||
#endif // BOUNDINGVOLUMEBOX_H
|
||||
4
geo/volume/BoundingVolumeHierarchy.h
Normal file
4
geo/volume/BoundingVolumeHierarchy.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef BOUNDINGVOLUMEHIERARCHY_H
|
||||
#define BOUNDINGVOLUMEHIERARCHY_H
|
||||
|
||||
#endif // BOUNDINGVOLUMEHIERARCHY_H
|
||||
27
geo/volume/BoundingVolumeSphere.h
Normal file
27
geo/volume/BoundingVolumeSphere.h
Normal 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
|
||||
Reference in New Issue
Block a user