-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHit.cpp
50 lines (41 loc) · 848 Bytes
/
Hit.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "Hit.h"
#include "Vector3D.h"
#include "Point3D.h"
#include "GeometricObject.h"
Hit::Hit()
{
}
Hit::Hit(const Hit& hit)
: hitObject(hit.hitObject), hitPoint(hit.hitPoint), inDir(hit.inDir)
{
}
Hit::Hit(const GeometricObject* object, const Point3D& ip, const Vector3D& viewDir)
: hitObject(object), hitPoint(ip), inDir(viewDir)
{
}
Hit::Hit(const GeometricObject* object, const Ray& ray, float dist)
: hitObject(object)
{
hitPoint = ray.getPointAt(dist);
inDir = ray.getDirection();
}
const GeometricObject* Hit::getHitObject() const
{
return hitObject;
}
Point3D Hit::getHitPoint() const
{
return hitPoint;
}
Vector3D Hit::getNormal() const
{
return hitObject->getNormal(hitPoint);
}
Vector3D Hit::getInDir() const
{
return inDir;
}
const Material* Hit::getMaterial() const
{
return hitObject->getMaterial(hitPoint);
}