Wed, 26 Feb 2020 22:26:05 +0200
PartRenderer::modelToScreenCoordinates FINALLY WORKS
55 | 1 | #pragma once |
2 | #include "basics.h" | |
3 | ||
4 | namespace geom | |
5 | { | |
6 | struct Plane | |
7 | { | |
8 | glm::vec3 normal; | |
9 | glm::vec3 anchor; | |
10 | }; | |
11 | ||
12 | struct Line | |
13 | { | |
14 | glm::vec3 direction; | |
15 | glm::vec3 anchor; | |
16 | }; | |
17 | ||
18 | template<int N> | |
19 | struct Polygon | |
20 | { | |
21 | glm::vec3 points[N]; | |
22 | }; | |
23 | ||
24 | inline const glm::vec3 origin = {0, 0, 0}; | |
25 | inline const Plane XY = {{0, 0, 1}, origin}; | |
26 | inline const Plane XZ = {{0, 1, 0}, origin}; | |
27 | inline const Plane YZ = {{1, 0, 0}, origin}; | |
28 | using Triangle = Polygon<3>; | |
29 | ||
30 | Line lineFromPoints(const glm::vec3& point_1, const glm::vec3 point_2); | |
31 | Plane planeFromTriangle(const Triangle& triangle); | |
32 | glm::vec3 normalVector(const Triangle& triangle); | |
33 | std::optional<glm::vec3> linePlaneIntersection(const Line& line, const Plane& plane); | |
34 | } |