Files
PhotonMF/sphere.hpp

39 lines
818 B
C++
Raw Normal View History

2016-12-25 21:47:28 -04:00
#pragma once
#ifndef SPHERE_HPP
#define SPHERE_HPP
2016-12-26 15:41:29 -04:00
#include <glm/glm.hpp>
2016-12-25 21:47:28 -04:00
#include "figure.hpp"
using glm::vec3;
class Sphere : public Figure {
public:
vec3 m_center;
float m_radius;
Sphere(Material * mat = NULL): Figure(mat), m_center(vec3(0.0f)), m_radius(0.5f) {
calculate_inv_area();
}
2016-12-25 21:47:28 -04:00
Sphere(float x, float y, float z, float r, Material * mat = NULL): Figure(mat), m_center(vec3(x, y, z)), m_radius(r) {
calculate_inv_area();
}
2016-12-25 21:47:28 -04:00
Sphere(vec3 _c, float r, Material * mat = NULL): Figure(mat), m_center(_c), m_radius(r) {
calculate_inv_area();
}
2016-12-25 21:47:28 -04:00
virtual ~Sphere() { }
2016-12-26 19:14:21 -04:00
virtual bool intersect(Ray & r, float & t) const;
virtual vec3 normal_at_int(Ray & r, float & t) const;
virtual vec3 sample_at_surface() const;
private:
virtual void calculate_inv_area();
2016-12-25 21:47:28 -04:00
};
#endif