-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSphere.hh
More file actions
41 lines (28 loc) · 749 Bytes
/
Sphere.hh
File metadata and controls
41 lines (28 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef SPHERE_HH
#define SPHERE_HH
#include "Basic.hh"
class Sphere : public Primitive
{
public:
Vec3f center;
float radius;
Sphere(Vec3f center, float radius, Shader *shader)
: center(center), radius(radius), Primitive(shader)
{};
~Sphere() {};
virtual bool Intersect(Ray &ray);
virtual Vec3f GetNormal(Ray &ray);
virtual Box CalcBounds()
{
// sphere's bounding box is computed based on the radius of the sphere
Box b = Box();
b.Extend(center + Vec3f(-radius,-radius,-radius));
b.Extend(center + Vec3f(radius,radius,radius));
return b;
};
virtual void GetUV(const Ray &ray, float &u, float &v) const {
u = ray.u;
v = ray.v;
}
};
#endif