-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlanar.h
More file actions
40 lines (36 loc) · 1.31 KB
/
Planar.h
File metadata and controls
40 lines (36 loc) · 1.31 KB
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
/**
* \author Marie DARRIGOL & Anthony LEONARD & Ophélie PELLOUX-PRAYER & Olivier SOLDANO
* \project Ray-Tracing
* \file Planar.h
* \brief Represents a planar object, with a position and two Vec3 (instance of SceneObject)
*/
#pragma once
#include "SceneObject.h"
class Planar : public SceneObject{
public:
// Default constructor
Planar();
// Constructor with all the parameters for the position and size
Planar(Vec3 &pos, Vec3 &w, Vec3 &h);
// Constructor with all the parameters
Planar(Vec3 &pos, Vec3 &w, Vec3 &h, Material &m);
/**
* Determine the intersection between a ray and a planar
* Solution Geometric : p = l0 + t * l
* Solution Analytic : t = (p0 - l0).n / (l.n)
* return : false and the ray's origin if no intersection and true and the impact point if intersection
* base on http://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-plane-and-ray-disk-intersection
**/
pair<bool, Vec3> intersect(Ray &ray);
Vec3 minCoordinates();
Vec3 maxCoordinates();
// Overridden method to match the planar case
Vec3 computeBump(const Vec3& impact) const;
private:
// Normal vector of the planar
Vec3 n;
// Half width of the object (beginning at its position)
Vec3 halfWidth; // x
// Half height of the object (beginning at its position)
Vec3 halfHeight; // y
};