Commit 0a5bad5b authored by Patrik Huber's avatar Patrik Huber

Removed v2:: from Vertex class and removed old class

Replaced all instances of old Vertex class with Vertex<float>, so now there's only one vertex class.
parent 9ebe49cc
...@@ -65,8 +65,8 @@ public: ...@@ -65,8 +65,8 @@ public:
*/ */
template <typename T, glm::precision P = glm::defaultp> template <typename T, glm::precision P = glm::defaultp>
glm::tvec4<T, P> glm::tvec4<T, P>
shade_triangle_pixel(int x, int y, const detail::v2::Vertex<T, P>& point_a, shade_triangle_pixel(int x, int y, const detail::Vertex<T, P>& point_a,
const detail::v2::Vertex<T, P>& point_b, const detail::v2::Vertex<T, P>& point_c, const detail::Vertex<T, P>& point_b, const detail::Vertex<T, P>& point_c,
const glm::tvec3<T, P>& lambda, const boost::optional<Texture>& texture, float dudx, const glm::tvec3<T, P>& lambda, const boost::optional<Texture>& texture, float dudx,
float dudy, float dvdx, float dvdy) float dudy, float dvdx, float dvdy)
{ {
...@@ -95,8 +95,8 @@ public: ...@@ -95,8 +95,8 @@ public:
*/ */
template <typename T, glm::precision P = glm::defaultp> template <typename T, glm::precision P = glm::defaultp>
glm::tvec4<T, P> glm::tvec4<T, P>
shade_triangle_pixel(int x, int y, const detail::v2::Vertex<T, P>& point_a, shade_triangle_pixel(int x, int y, const detail::Vertex<T, P>& point_a,
const detail::v2::Vertex<T, P>& point_b, const detail::v2::Vertex<T, P>& point_c, const detail::Vertex<T, P>& point_b, const detail::Vertex<T, P>& point_c,
const glm::tvec3<T, P>& lambda, const boost::optional<eos::render::Texture>& texture, const glm::tvec3<T, P>& lambda, const boost::optional<eos::render::Texture>& texture,
float dudx, float dudy, float dvdx, float dvdy) float dudx, float dudy, float dvdx, float dvdy)
{ {
...@@ -164,8 +164,8 @@ public: ...@@ -164,8 +164,8 @@ public:
*/ */
template <typename T, glm::precision P = glm::defaultp> template <typename T, glm::precision P = glm::defaultp>
glm::tvec4<T, P> glm::tvec4<T, P>
shade_triangle_pixel(int x, int y, const detail::v2::Vertex<T, P>& point_a, shade_triangle_pixel(int x, int y, const detail::Vertex<T, P>& point_a,
const detail::v2::Vertex<T, P>& point_b, const detail::v2::Vertex<T, P>& point_c, const detail::Vertex<T, P>& point_b, const detail::Vertex<T, P>& point_c,
const glm::tvec3<T, P>& lambda, const boost::optional<Texture>& texture, float dudx, const glm::tvec3<T, P>& lambda, const boost::optional<Texture>& texture, float dudx,
float dudy, float dvdx, float dvdy) float dudy, float dvdx, float dvdy)
{ {
......
...@@ -57,8 +57,8 @@ public: ...@@ -57,8 +57,8 @@ public:
* @ return X. * @ return X.
*/ */
template <typename T, glm::precision P = glm::defaultp> template <typename T, glm::precision P = glm::defaultp>
void raster_triangle(const detail::v2::Vertex<T, P>& point_a, const detail::v2::Vertex<T, P>& point_b, void raster_triangle(const detail::Vertex<T, P>& point_a, const detail::Vertex<T, P>& point_b,
const detail::v2::Vertex<T, P>& point_c, const boost::optional<Texture>& texture) const detail::Vertex<T, P>& point_c, const boost::optional<Texture>& texture)
{ {
// We already calculated this in the culling/clipping stage. Maybe we should save/cache it after all. // We already calculated this in the culling/clipping stage. Maybe we should save/cache it after all.
cv::Rect boundingBox = detail::calculate_clipped_bounding_box( cv::Rect boundingBox = detail::calculate_clipped_bounding_box(
......
...@@ -54,8 +54,8 @@ namespace render { ...@@ -54,8 +54,8 @@ namespace render {
// Forward declarations (these functions should probably be moved into detail/): // Forward declarations (these functions should probably be moved into detail/):
template <typename T, glm::precision P = glm::defaultp> template <typename T, glm::precision P = glm::defaultp>
std::vector<detail::v2::Vertex<T, P>> std::vector<detail::Vertex<T, P>>
clip_polygon_to_plane_in_4d(const std::vector<detail::v2::Vertex<T, P>>& vertices, clip_polygon_to_plane_in_4d(const std::vector<detail::Vertex<T, P>>& vertices,
const glm::tvec4<T, P>& plane_normal); const glm::tvec4<T, P>& plane_normal);
/** /**
...@@ -64,7 +64,7 @@ clip_polygon_to_plane_in_4d(const std::vector<detail::v2::Vertex<T, P>>& vertice ...@@ -64,7 +64,7 @@ clip_polygon_to_plane_in_4d(const std::vector<detail::v2::Vertex<T, P>>& vertice
* Can this go into the SoftwareRenderer class or something? No, I think FragShader needs it? Where to put it? * Can this go into the SoftwareRenderer class or something? No, I think FragShader needs it? Where to put it?
*/ */
template <typename T, glm::precision P = glm::defaultp> template <typename T, glm::precision P = glm::defaultp>
using Triangle = std::array<detail::v2::Vertex<T, P>, 3>; using Triangle = std::array<detail::Vertex<T, P>, 3>;
/** /**
* @brief X. * @brief X.
...@@ -218,11 +218,11 @@ public: ...@@ -218,11 +218,11 @@ public:
// If we're here, the triangle is CCW in screen space and the bbox is inside the viewport! // If we're here, the triangle is CCW in screen space and the bbox is inside the viewport!
triangles_to_raster.push_back( triangles_to_raster.push_back(
Triangle<T, P>{detail::v2::Vertex<T, P>{prospective_tri[0], mesh.colors[tri_indices[0]], Triangle<T, P>{detail::Vertex<T, P>{prospective_tri[0], mesh.colors[tri_indices[0]],
mesh.texcoords[tri_indices[0]]}, mesh.texcoords[tri_indices[0]]},
detail::v2::Vertex<T, P>{prospective_tri[1], mesh.colors[tri_indices[1]], detail::Vertex<T, P>{prospective_tri[1], mesh.colors[tri_indices[1]],
mesh.texcoords[tri_indices[1]]}, mesh.texcoords[tri_indices[1]]},
detail::v2::Vertex<T, P>{prospective_tri[2], mesh.colors[tri_indices[2]], detail::Vertex<T, P>{prospective_tri[2], mesh.colors[tri_indices[2]],
mesh.texcoords[tri_indices[2]]}}); mesh.texcoords[tri_indices[2]]}});
continue; // Triangle was either added or not added. Continue with next triangle. continue; // Triangle was either added or not added. Continue with next triangle.
} }
...@@ -230,15 +230,15 @@ public: ...@@ -230,15 +230,15 @@ public:
// Note: It seems that this is only w.r.t. the near-plane. If a triangle is partially outside the // Note: It seems that this is only w.r.t. the near-plane. If a triangle is partially outside the
// tlbr viewport, it'll get rejected. // tlbr viewport, it'll get rejected.
// Well, 'z' of these triangles seems to be -1, so is that really the near plane? // Well, 'z' of these triangles seems to be -1, so is that really the near plane?
std::vector<detail::v2::Vertex<T, P>> vertices; std::vector<detail::Vertex<T, P>> vertices;
vertices.reserve(3); vertices.reserve(3);
vertices.push_back(detail::v2::Vertex<T, P>{clipspace_vertices[tri_indices[0]], vertices.push_back(detail::Vertex<T, P>{clipspace_vertices[tri_indices[0]],
mesh.colors[tri_indices[0]], mesh.colors[tri_indices[0]],
mesh.texcoords[tri_indices[0]]}); mesh.texcoords[tri_indices[0]]});
vertices.push_back(detail::v2::Vertex<T, P>{clipspace_vertices[tri_indices[1]], vertices.push_back(detail::Vertex<T, P>{clipspace_vertices[tri_indices[1]],
mesh.colors[tri_indices[1]], mesh.colors[tri_indices[1]],
mesh.texcoords[tri_indices[1]]}); mesh.texcoords[tri_indices[1]]});
vertices.push_back(detail::v2::Vertex<T, P>{clipspace_vertices[tri_indices[2]], vertices.push_back(detail::Vertex<T, P>{clipspace_vertices[tri_indices[2]],
mesh.colors[tri_indices[2]], mesh.colors[tri_indices[2]],
mesh.texcoords[tri_indices[2]]}); mesh.texcoords[tri_indices[2]]});
// split the triangle if it intersects the near plane: // split the triangle if it intersects the near plane:
...@@ -307,11 +307,11 @@ public: ...@@ -307,11 +307,11 @@ public:
// If we're here, the triangle is CCW in screen space and the bbox is inside the viewport! // If we're here, the triangle is CCW in screen space and the bbox is inside the viewport!
triangles_to_raster.push_back( triangles_to_raster.push_back(
Triangle<T, P>{detail::v2::Vertex<T, P>{prospective_tri[0], vertices[0].color, Triangle<T, P>{detail::Vertex<T, P>{prospective_tri[0], vertices[0].color,
vertices[0].texcoords}, vertices[0].texcoords},
detail::v2::Vertex<T, P>{prospective_tri[1], vertices[1 + k].color, detail::Vertex<T, P>{prospective_tri[1], vertices[1 + k].color,
vertices[1 + k].texcoords}, vertices[1 + k].texcoords},
detail::v2::Vertex<T, P>{prospective_tri[2], vertices[2 + k].color, detail::Vertex<T, P>{prospective_tri[2], vertices[2 + k].color,
vertices[2 + k].texcoords}}); vertices[2 + k].texcoords}});
// continue; // triangle was either added or not added. Continue with next triangle. // continue; // triangle was either added or not added. Continue with next triangle.
// COPY END // COPY END
...@@ -352,11 +352,11 @@ private: ...@@ -352,11 +352,11 @@ private:
* @ return X. * @ return X.
*/ */
template <typename T, glm::precision P = glm::defaultp> template <typename T, glm::precision P = glm::defaultp>
std::vector<detail::v2::Vertex<T, P>> std::vector<detail::Vertex<T, P>>
clip_polygon_to_plane_in_4d(const std::vector<detail::v2::Vertex<T, P>>& vertices, clip_polygon_to_plane_in_4d(const std::vector<detail::Vertex<T, P>>& vertices,
const glm::tvec4<T, P>& plane_normal) const glm::tvec4<T, P>& plane_normal)
{ {
std::vector<detail::v2::Vertex<T, P>> clipped_vertices; std::vector<detail::Vertex<T, P>> clipped_vertices;
// We can have 2 cases: // We can have 2 cases:
// * 1 vertex visible: we make 1 new triangle out of the visible vertex plus the 2 intersection points // * 1 vertex visible: we make 1 new triangle out of the visible vertex plus the 2 intersection points
...@@ -395,10 +395,10 @@ clip_polygon_to_plane_in_4d(const std::vector<detail::v2::Vertex<T, P>>& vertice ...@@ -395,10 +395,10 @@ clip_polygon_to_plane_in_4d(const std::vector<detail::v2::Vertex<T, P>>& vertice
if (fa < 0) // we keep the original vertex plus the new one if (fa < 0) // we keep the original vertex plus the new one
{ {
clipped_vertices.push_back(vertices[a]); clipped_vertices.push_back(vertices[a]);
clipped_vertices.push_back(detail::v2::Vertex<T, P>{position, color, texcoords}); clipped_vertices.push_back(detail::Vertex<T, P>{position, color, texcoords});
} else if (fb < 0) // we use only the new vertex } else if (fb < 0) // we use only the new vertex
{ {
clipped_vertices.push_back(detail::v2::Vertex<T, P>{position, color, texcoords}); clipped_vertices.push_back(detail::Vertex<T, P>{position, color, texcoords});
} }
} else if (fa < 0 && fb < 0) // both are visible (on the "good" side of the plane), no splitting } else if (fa < 0 && fb < 0) // both are visible (on the "good" side of the plane), no splitting
// required, use the current vertex // required, use the current vertex
......
...@@ -34,9 +34,6 @@ namespace eos { ...@@ -34,9 +34,6 @@ namespace eos {
namespace render { namespace render {
namespace detail { namespace detail {
// In a v2 namespace for now to disambiguate between this and the "older" Vertex class:
namespace v2 {
/** /**
* @brief A representation for a vertex during rendering, used internally. * @brief A representation for a vertex during rendering, used internally.
* *
...@@ -58,8 +55,6 @@ struct Vertex ...@@ -58,8 +55,6 @@ struct Vertex
glm::tvec2<T, P> texcoords; // UV glm::tvec2<T, P> texcoords; // UV
}; };
} /* namespace v2 */
} /* namespace detail */ } /* namespace detail */
} /* namespace render */ } /* namespace render */
} /* namespace eos */ } /* namespace eos */
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#define RENDER_DETAIL_HPP_ #define RENDER_DETAIL_HPP_
#include "eos/render/utils.hpp" #include "eos/render/utils.hpp"
#include "eos/render/detail/Vertex.hpp"
#include "glm/glm.hpp" // tvec2, glm::precision, tvec3, tvec4, normalize, dot, cross #include "glm/glm.hpp" // tvec2, glm::precision, tvec3, tvec4, normalize, dot, cross
...@@ -38,23 +39,6 @@ namespace eos { ...@@ -38,23 +39,6 @@ namespace eos {
namespace render { namespace render {
namespace detail { namespace detail {
/**
* Just a representation for a vertex during rendering.
*
* Might consider getting rid of it.
* Used in render_affine and render.
*/
class Vertex
{
public:
Vertex() {};
Vertex(const glm::tvec4<float>& position, const glm::tvec3<float>& color, const glm::tvec2<float>& texcoords) : position(position), color(color), texcoords(texcoords) {};
glm::tvec4<float> position;
glm::tvec3<float> color; ///< in RGB order
glm::tvec2<float> texcoords;
};
class plane class plane
{ {
public: public:
...@@ -144,7 +128,7 @@ public: ...@@ -144,7 +128,7 @@ public:
*/ */
struct TriangleToRasterize struct TriangleToRasterize
{ {
Vertex v0, v1, v2; Vertex<float> v0, v1, v2;
int min_x; int min_x;
int max_x; int max_x;
int min_y; int min_y;
...@@ -231,9 +215,9 @@ double implicit_line(float x, float y, const glm::tvec4<T, P>& v1, const glm::tv ...@@ -231,9 +215,9 @@ double implicit_line(float x, float y, const glm::tvec4<T, P>& v1, const glm::tv
return ((double)v1[1] - (double)v2[1])*(double)x + ((double)v2[0] - (double)v1[0])*(double)y + (double)v1[0] * (double)v2[1] - (double)v2[0] * (double)v1[1]; return ((double)v1[1] - (double)v2[1])*(double)x + ((double)v2[0] - (double)v1[0])*(double)y + (double)v1[0] * (double)v2[1] - (double)v2[0] * (double)v1[1];
}; };
inline std::vector<Vertex> clip_polygon_to_plane_in_4d(const std::vector<Vertex>& vertices, const glm::tvec4<float>& plane_normal) inline std::vector<Vertex<float>> clip_polygon_to_plane_in_4d(const std::vector<Vertex<float>>& vertices, const glm::tvec4<float>& plane_normal)
{ {
std::vector<Vertex> clippedVertices; std::vector<Vertex<float>> clippedVertices;
// We can have 2 cases: // We can have 2 cases:
// * 1 vertex visible: we make 1 new triangle out of the visible vertex plus the 2 intersection points with the near-plane // * 1 vertex visible: we make 1 new triangle out of the visible vertex plus the 2 intersection points with the near-plane
...@@ -262,11 +246,11 @@ inline std::vector<Vertex> clip_polygon_to_plane_in_4d(const std::vector<Vertex> ...@@ -262,11 +246,11 @@ inline std::vector<Vertex> clip_polygon_to_plane_in_4d(const std::vector<Vertex>
if (fa < 0) // we keep the original vertex plus the new one if (fa < 0) // we keep the original vertex plus the new one
{ {
clippedVertices.push_back(vertices[a]); clippedVertices.push_back(vertices[a]);
clippedVertices.push_back(Vertex(position, color, texCoord)); clippedVertices.push_back(Vertex<float>{position, color, texCoord});
} }
else if (fb < 0) // we use only the new vertex else if (fb < 0) // we use only the new vertex
{ {
clippedVertices.push_back(Vertex(position, color, texCoord)); clippedVertices.push_back(Vertex<float>{position, color, texCoord});
} }
} }
else if (fa < 0 && fb < 0) // both are visible (on the "good" side of the plane), no splitting required, use the current vertex else if (fa < 0 && fb < 0) // both are visible (on the "good" side of the plane), no splitting required, use the current vertex
...@@ -408,7 +392,7 @@ inline cv::Vec3f tex2d_linear(const cv::Vec2f& imageTexCoord, unsigned char mipm ...@@ -408,7 +392,7 @@ inline cv::Vec3f tex2d_linear(const cv::Vec2f& imageTexCoord, unsigned char mipm
// Todo: Split this function into the general (core-part) and the texturing part. // Todo: Split this function into the general (core-part) and the texturing part.
// Then, utils::extractTexture can re-use the core-part. // Then, utils::extractTexture can re-use the core-part.
// Note: Maybe a bit outdated "todo" above. // Note: Maybe a bit outdated "todo" above.
inline boost::optional<TriangleToRasterize> process_prospective_tri(Vertex v0, Vertex v1, Vertex v2, int viewport_width, int viewport_height, bool enable_backface_culling) inline boost::optional<TriangleToRasterize> process_prospective_tri(Vertex<float> v0, Vertex<float> v1, Vertex<float> v2, int viewport_width, int viewport_height, bool enable_backface_culling)
{ {
using cv::Vec2f; using cv::Vec2f;
using cv::Vec3f; using cv::Vec3f;
......
...@@ -145,7 +145,7 @@ inline std::pair<cv::Mat, cv::Mat> render(core::Mesh mesh, glm::tmat4x4<float> m ...@@ -145,7 +145,7 @@ inline std::pair<cv::Mat, cv::Mat> render(core::Mesh mesh, glm::tmat4x4<float> m
// Vertex shader: // Vertex shader:
//processedVertex = shade(Vertex); // processedVertex : pos, col, tex, texweight //processedVertex = shade(Vertex); // processedVertex : pos, col, tex, texweight
// Assemble the vertices, project to clip space, and store as detail::Vertex (the internal representation): // Assemble the vertices, project to clip space, and store as detail::Vertex (the internal representation):
vector<detail::Vertex> clipspace_vertices; vector<detail::Vertex<float>> clipspace_vertices;
clipspace_vertices.reserve(mesh.vertices.size()); clipspace_vertices.reserve(mesh.vertices.size());
for (int i = 0; i < mesh.vertices.size(); ++i) { // "previously": mesh.vertex for (int i = 0; i < mesh.vertices.size(); ++i) { // "previously": mesh.vertex
glm::tvec4<float> clipspace_coords = projection_matrix * model_view_matrix * mesh.vertices[i]; glm::tvec4<float> clipspace_coords = projection_matrix * model_view_matrix * mesh.vertices[i];
...@@ -156,7 +156,7 @@ inline std::pair<cv::Mat, cv::Mat> render(core::Mesh mesh, glm::tmat4x4<float> m ...@@ -156,7 +156,7 @@ inline std::pair<cv::Mat, cv::Mat> render(core::Mesh mesh, glm::tmat4x4<float> m
else { else {
vertex_colour = mesh.colors[i]; vertex_colour = mesh.colors[i];
} }
clipspace_vertices.push_back(detail::Vertex(clipspace_coords, vertex_colour, mesh.texcoords[i])); clipspace_vertices.push_back(detail::Vertex<float>{clipspace_coords, vertex_colour, mesh.texcoords[i]});
} }
// All vertices are in clip-space now. // All vertices are in clip-space now.
...@@ -207,7 +207,7 @@ inline std::pair<cv::Mat, cv::Mat> render(core::Mesh mesh, glm::tmat4x4<float> m ...@@ -207,7 +207,7 @@ inline std::pair<cv::Mat, cv::Mat> render(core::Mesh mesh, glm::tmat4x4<float> m
continue; continue;
} }
// at this moment the triangle is known to be intersecting one of the view frustum's planes // at this moment the triangle is known to be intersecting one of the view frustum's planes
std::vector<detail::Vertex> vertices; std::vector<detail::Vertex<float>> vertices;
vertices.push_back(clipspace_vertices[tri_indices[0]]); vertices.push_back(clipspace_vertices[tri_indices[0]]);
vertices.push_back(clipspace_vertices[tri_indices[1]]); vertices.push_back(clipspace_vertices[tri_indices[1]]);
vertices.push_back(clipspace_vertices[tri_indices[2]]); vertices.push_back(clipspace_vertices[tri_indices[2]]);
......
...@@ -66,7 +66,7 @@ inline std::pair<cv::Mat, cv::Mat> render_affine(core::Mesh mesh, cv::Mat affine ...@@ -66,7 +66,7 @@ inline std::pair<cv::Mat, cv::Mat> render_affine(core::Mesh mesh, cv::Mat affine
Mat affine_with_z = detail::calculate_affine_z_direction(affine_camera_matrix); Mat affine_with_z = detail::calculate_affine_z_direction(affine_camera_matrix);
vector<detail::Vertex> projected_vertices; vector<detail::Vertex<float>> projected_vertices;
projected_vertices.reserve(mesh.vertices.size()); projected_vertices.reserve(mesh.vertices.size());
for (int i = 0; i < mesh.vertices.size(); ++i) { for (int i = 0; i < mesh.vertices.size(); ++i) {
Mat vertex_screen_coords = affine_with_z * Mat(cv::Vec4f(mesh.vertices[i].x, mesh.vertices[i].y, mesh.vertices[i].z, mesh.vertices[i].w)); Mat vertex_screen_coords = affine_with_z * Mat(cv::Vec4f(mesh.vertices[i].x, mesh.vertices[i].y, mesh.vertices[i].z, mesh.vertices[i].w));
...@@ -78,7 +78,7 @@ inline std::pair<cv::Mat, cv::Mat> render_affine(core::Mesh mesh, cv::Mat affine ...@@ -78,7 +78,7 @@ inline std::pair<cv::Mat, cv::Mat> render_affine(core::Mesh mesh, cv::Mat affine
else { else {
vertex_colour = mesh.colors[i]; vertex_colour = mesh.colors[i];
} }
projected_vertices.push_back(detail::Vertex(vertex_screen_coords_glm, vertex_colour, mesh.texcoords[i])); projected_vertices.push_back(detail::Vertex<float>{vertex_screen_coords_glm, vertex_colour, mesh.texcoords[i]});
} }
// All vertices are screen-coordinates now // All vertices are screen-coordinates now
......
...@@ -453,7 +453,7 @@ cv::Mat extract_texture(core::Mesh mesh, glm::mat4x4 view_model_matrix, glm::mat ...@@ -453,7 +453,7 @@ cv::Mat extract_texture(core::Mesh mesh, glm::mat4x4 view_model_matrix, glm::mat
// Test with a rendered & re-extracted texture shows that we're off by a pixel or more, // Test with a rendered & re-extracted texture shows that we're off by a pixel or more,
// definitely need to correct this. Probably here. // definitely need to correct this. Probably here.
// It looks like it is 1-2 pixels off. Definitely a bit more than 1. // It looks like it is 1-2 pixels off. Definitely a bit more than 1.
detail::v2::Vertex<double> pa{ detail::Vertex<double> pa{
vec4(mesh.texcoords[tvi[0]][0] * tex_width, mesh.texcoords[tvi[0]][1] * tex_height, vec4(mesh.texcoords[tvi[0]][0] * tex_width, mesh.texcoords[tvi[0]][1] * tex_height,
wnd_coords[tvi[0]].z /* z_ndc */, wnd_coords[tvi[0]].w /* 1/w_clip */), wnd_coords[tvi[0]].z /* z_ndc */, wnd_coords[tvi[0]].w /* 1/w_clip */),
vec3(/* empty */), vec3(/* empty */),
...@@ -462,7 +462,7 @@ cv::Mat extract_texture(core::Mesh mesh, glm::mat4x4 view_model_matrix, glm::mat ...@@ -462,7 +462,7 @@ cv::Mat extract_texture(core::Mesh mesh, glm::mat4x4 view_model_matrix, glm::mat
/* maybe 1 - ... ? */ wnd_coords[tvi[0]].y / /* maybe 1 - ... ? */ wnd_coords[tvi[0]].y /
image image
.rows /* wndcoords of the projected/rendered model triangle (in the input img). Normalised to 0,1. */)}; .rows /* wndcoords of the projected/rendered model triangle (in the input img). Normalised to 0,1. */)};
detail::v2::Vertex<double> pb{ detail::Vertex<double> pb{
vec4(mesh.texcoords[tvi[1]][0] * tex_width, mesh.texcoords[tvi[1]][1] * tex_height, vec4(mesh.texcoords[tvi[1]][0] * tex_width, mesh.texcoords[tvi[1]][1] * tex_height,
wnd_coords[tvi[1]].z /* z_ndc */, wnd_coords[tvi[1]].w /* 1/w_clip */), wnd_coords[tvi[1]].z /* z_ndc */, wnd_coords[tvi[1]].w /* 1/w_clip */),
vec3(/* empty */), vec3(/* empty */),
...@@ -471,7 +471,7 @@ cv::Mat extract_texture(core::Mesh mesh, glm::mat4x4 view_model_matrix, glm::mat ...@@ -471,7 +471,7 @@ cv::Mat extract_texture(core::Mesh mesh, glm::mat4x4 view_model_matrix, glm::mat
/* maybe 1 - ... ? */ wnd_coords[tvi[1]].y / /* maybe 1 - ... ? */ wnd_coords[tvi[1]].y /
image image
.rows /* wndcoords of the projected/rendered model triangle (in the input img). Normalised to 0,1. */)}; .rows /* wndcoords of the projected/rendered model triangle (in the input img). Normalised to 0,1. */)};
detail::v2::Vertex<double> pc{ detail::Vertex<double> pc{
vec4(mesh.texcoords[tvi[2]][0] * tex_width, mesh.texcoords[tvi[2]][1] * tex_height, vec4(mesh.texcoords[tvi[2]][0] * tex_width, mesh.texcoords[tvi[2]][1] * tex_height,
wnd_coords[tvi[2]].z /* z_ndc */, wnd_coords[tvi[2]].w /* 1/w_clip */), wnd_coords[tvi[2]].z /* z_ndc */, wnd_coords[tvi[2]].w /* 1/w_clip */),
vec3(/* empty */), vec3(/* empty */),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment