Printbed textures generated from svg files

This commit is contained in:
Enrico Turri 2019-02-20 15:23:23 +01:00
parent 0b0457186b
commit 11fc849b1a
16 changed files with 5124 additions and 33 deletions

View file

@ -3,6 +3,9 @@
#include "GLTexture.hpp"
#include "3DScene.hpp"
#if ENABLE_TEXTURES_FROM_SVG
#include "GLShader.hpp"
#endif // ENABLE_TEXTURES_FROM_SVG
class GLUquadric;
typedef class GLUquadric GLUquadricObj;
@ -12,17 +15,41 @@ namespace GUI {
class GeometryBuffer
{
#if ENABLE_TEXTURES_FROM_SVG
struct Vertex
{
float position[3];
float tex_coords[2];
Vertex()
{
position[0] = 0.0f; position[1] = 0.0f; position[2] = 0.0f;
tex_coords[0] = 0.0f; tex_coords[1] = 0.0f;
}
};
std::vector<Vertex> m_vertices;
#else
std::vector<float> m_vertices;
std::vector<float> m_tex_coords;
#endif // ENABLE_TEXTURES_FROM_SVG
public:
bool set_from_triangles(const Polygons& triangles, float z, bool generate_tex_coords);
bool set_from_lines(const Lines& lines, float z);
#if ENABLE_TEXTURES_FROM_SVG
const float* get_vertices_data() const;
unsigned int get_vertices_data_size() const { return (unsigned int)m_vertices.size() * get_vertex_data_size(); }
unsigned int get_vertex_data_size() const { return (unsigned int)(5 * sizeof(float)); }
unsigned int get_position_offset() const { return 0; }
unsigned int get_tex_coords_offset() const { return (unsigned int)(3 * sizeof(float)); }
unsigned int get_vertices_count() const { return (unsigned int)m_vertices.size(); }
#else
const float* get_vertices() const { return m_vertices.data(); }
const float* get_tex_coords() const { return m_tex_coords.data(); }
unsigned int get_vertices_count() const { return (unsigned int)m_vertices.size() / 3; }
#endif // ENABLE_TEXTURES_FROM_SVG
};
class Bed3D
@ -62,8 +89,14 @@ private:
Polygon m_polygon;
GeometryBuffer m_triangles;
GeometryBuffer m_gridlines;
#if ENABLE_TEXTURES_FROM_SVG
mutable GLTexture m_texture;
mutable Shader m_shader;
mutable unsigned int m_vbo_id;
#else
mutable GLTexture m_top_texture;
mutable GLTexture m_bottom_texture;
#endif // ENABLE_TEXTURES_FROM_SVG
mutable GLBed m_model;
Axes m_axes;
@ -71,6 +104,9 @@ private:
public:
Bed3D();
#if ENABLE_TEXTURES_FROM_SVG
~Bed3D() { reset(); }
#endif // ENABLE_TEXTURES_FROM_SVG
EType get_type() const { return m_type; }
@ -93,8 +129,16 @@ private:
void calc_triangles(const ExPolygon& poly);
void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox);
EType detect_type(const Pointfs& shape) const;
#if ENABLE_TEXTURES_FROM_SVG
void render_prusa(const std::string& key, bool bottom) const;
void render_prusa_shader(unsigned int vertices_count, bool transparent) const;
#else
void render_prusa(const std::string &key, float theta, bool useVBOs) const;
#endif // ENABLE_TEXTURES_FROM_SVG
void render_custom() const;
#if ENABLE_TEXTURES_FROM_SVG
void reset();
#endif // ENABLE_TEXTURES_FROM_SVG
};
} // GUI