Wed, 26 Feb 2020 22:26:05 +0200
PartRenderer::modelToScreenCoordinates FINALLY WORKS
#pragma once #include "basics.h" namespace geom { struct Plane { glm::vec3 normal; glm::vec3 anchor; }; struct Line { glm::vec3 direction; glm::vec3 anchor; }; template<int N> struct Polygon { glm::vec3 points[N]; }; inline const glm::vec3 origin = {0, 0, 0}; inline const Plane XY = {{0, 0, 1}, origin}; inline const Plane XZ = {{0, 1, 0}, origin}; inline const Plane YZ = {{1, 0, 0}, origin}; using Triangle = Polygon<3>; Line lineFromPoints(const glm::vec3& point_1, const glm::vec3 point_2); Plane planeFromTriangle(const Triangle& triangle); glm::vec3 normalVector(const Triangle& triangle); std::optional<glm::vec3> linePlaneIntersection(const Line& line, const Plane& plane); }