// bool enable_texturing = false; Maybe re-add later, not sure
// bool enable_texturing = false; Maybe re-add later, not sure
// take a cv::Mat texture instead and convert to Texture internally? no, we don't want to recreate mipmap levels on each render() call.
// take a cv::Mat texture instead and convert to Texture internally? no, we don't want to recreate mipmap levels on each render() call.
autot1=std::chrono::high_resolution_clock::now();
assert(mesh.vertices.size()==mesh.colors.size()||mesh.colors.empty());// The number of vertices has to be equal for both shape and colour, or, alternatively, it has to be a shape-only model.
assert(mesh.vertices.size()==mesh.colors.size()||mesh.colors.empty());// The number of vertices has to be equal for both shape and colour, or, alternatively, it has to be a shape-only model.
assert(mesh.vertices.size()==mesh.texcoords.size()||mesh.texcoords.empty());// same for the texcoords
assert(mesh.vertices.size()==mesh.texcoords.size()||mesh.texcoords.empty());// same for the texcoords
// another assert: If cv::Mat texture != empty, then we need texcoords?
// another assert: If cv::Mat texture != empty, then we need texcoords?
// Todo: Split this whole stuff up. Make a "clip" function, ... rename "processProspective..".. what is "process"... get rid of "continue;"-stuff by moving stuff inside process...
// Todo: Split this whole stuff up. Make a "clip" function, ... rename "processProspective..".. what is "process"... get rid of "continue;"-stuff by moving stuff inside process...
// classify vertices visibility with respect to the planes of the view frustum
// classify vertices visibility with respect to the planes of the view frustum
// we're in clip-coords (NDC), so just check if outside [-1, 1] x ...
// we're in clip-coords (NDC), so just check if outside [-1, 1] x ...
// split the triangle if it intersects the near plane:
// split the triangle if it intersects the near plane:
if(enable_near_clipping)
if(enable_near_clipping)
{
{
vertices=detail::clip_polygon_to_plane_in_4d(vertices,glm::tvec4<float>(0.0f,0.0f,-1.0f,-1.0f));// "Normal" (or "4D hyperplane") of the near-plane. I tested it and it works like this but I'm a little bit unsure because Songho says the normal of the near-plane is (0,0,-1,1) (maybe I have to switch around the < 0 checks in the function?)
-1.0f));// "Normal" (or "4D hyperplane") of the near-plane. I tested it and it works like this but I'm a little bit unsure because Songho says the normal of the near-plane is (0,0,-1,1) (maybe I have to switch around the < 0 checks in the function?)
}
}
// triangulation of the polygon formed of vertices array
// triangulation of the polygon formed of vertices array