#pragma once #include #include #include #include #include #include #include // helper array with the corner vertices of an icosahedron constexpr inline float icosahedronVertices[] = { 0.000000f, -1.000000f, 0.000000f, 0.723600f, -0.447214f, 0.525720f, -0.276386f, -0.447214f, 0.850640f, -0.894424f, -0.447214f, 0.000000f, -0.276386f, -0.447214f, -0.850640f, 0.723600f, -0.447214f, -0.525720f, 0.276386f, 0.447214f, 0.850640f, -0.723600f, 0.447214f, 0.525720f, -0.723600f, 0.447214f, -0.525720f, 0.276386f, 0.447214f, -0.850640f, 0.894424f, 0.447214f, 0.000000f, 0.000000f, 1.000000f, 0.000000f }; // helper array of indices which form the triangular faces of an icosahedron constexpr inline GLubyte icosahedronIndices[] = { 0, 1, 2, 1, 0, 5, 0, 2, 3, 0, 3, 4, 0, 4, 5, 1, 5, 10, 2, 1, 6, 3, 2, 7, 4, 3, 8, 5, 4, 9, 1, 10, 6, 2, 6, 7, 3, 7, 8, 4, 8, 9, 5, 9, 10, 6, 10, 11, 7, 6, 11, 8, 7, 11, 9, 8, 11, 10, 9, 11 }; namespace std { // specialization of std::hash for std::pair so that std::unordered_map, T> can be used template struct hash> { using argument_type = pair; using result_type = size_t; result_type operator()(argument_type const & p) const noexcept { return hash>{}(p.first) ^ (hash>{}(p.second) << 1); } }; } // helper function to subdivide a triangular mesh and project it onto the unit sphere void subdivideIcosphere(std::vector & vertices, std::vector & indices); // helper function to compute a perspective projection matrix with an infinite far range Eigen::Matrix4d calculateInfinitePerspective(double minimumFieldOfView, double aspectRatio, double zNear); // helper function to compute a lookat-matrix (camera at eye, target at center, global up direction; up must be linearly independent of (center - eye)) Eigen::Matrix4d calculateLookAtMatrix(Eigen::Vector3d eye, Eigen::Vector3d center, Eigen::Vector3d up); // helper function to load a Qt resource as an array of char (bytes) std::vector loadResource(char const * path);