-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntersection.cs
31 lines (28 loc) · 948 Bytes
/
Intersection.cs
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
using System.Numerics;
namespace RayTracer
{
public struct Intersection
{
public float t; //distance from camera eye
public Vector3 point; //point of intersection
public IPrimitive primitive; //primitive from intersection
public Vector3 normal; //Normal vector on primitive
public Material material; //material at intersection
public Intersection(float t, Vector3 point, IPrimitive primitive)
{
this.t = t;
this.point = point;
this.primitive = primitive;
if (primitive != null)
{
this.normal = primitive.Normal(point);
this.material = primitive.GetMaterial(point);
}
else
{
this.normal = new Vector3(0, 0, 0);
this.material = new Material();
}
}
}
}