2019-02-19 14:15:27 +00:00
|
|
|
#ifndef slic3r_3DBed_hpp_
|
|
|
|
#define slic3r_3DBed_hpp_
|
|
|
|
|
|
|
|
#include "GLTexture.hpp"
|
|
|
|
#include "3DScene.hpp"
|
2019-02-20 14:23:23 +00:00
|
|
|
#include "GLShader.hpp"
|
2019-02-19 14:15:27 +00:00
|
|
|
|
2020-01-09 09:27:42 +00:00
|
|
|
#include <tuple>
|
|
|
|
|
2019-02-19 14:15:27 +00:00
|
|
|
class GLUquadric;
|
|
|
|
typedef class GLUquadric GLUquadricObj;
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
namespace GUI {
|
|
|
|
|
2019-06-05 08:07:59 +00:00
|
|
|
class GLCanvas3D;
|
|
|
|
|
2019-02-19 14:15:27 +00:00
|
|
|
class GeometryBuffer
|
|
|
|
{
|
2019-02-20 14:23:23 +00:00
|
|
|
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;
|
2019-02-19 14:15:27 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
bool set_from_triangles(const Polygons& triangles, float z, bool generate_tex_coords);
|
|
|
|
bool set_from_lines(const Lines& lines, float z);
|
|
|
|
|
2019-02-20 14:23:23 +00:00
|
|
|
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)); }
|
2019-07-03 07:19:07 +00:00
|
|
|
size_t get_position_offset() const { return 0; }
|
|
|
|
size_t get_tex_coords_offset() const { return (size_t)(3 * sizeof(float)); }
|
2019-02-20 14:23:23 +00:00
|
|
|
unsigned int get_vertices_count() const { return (unsigned int)m_vertices.size(); }
|
2019-02-19 14:15:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Bed3D
|
|
|
|
{
|
|
|
|
struct Axes
|
|
|
|
{
|
|
|
|
static const double Radius;
|
|
|
|
static const double ArrowBaseRadius;
|
|
|
|
static const double ArrowLength;
|
|
|
|
Vec3d origin;
|
|
|
|
Vec3d length;
|
|
|
|
GLUquadricObj* m_quadric;
|
|
|
|
|
|
|
|
Axes();
|
|
|
|
~Axes();
|
|
|
|
|
|
|
|
void render() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void render_axis(double length) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum EType : unsigned char
|
|
|
|
{
|
2020-01-09 09:27:42 +00:00
|
|
|
System,
|
2019-02-19 14:15:27 +00:00
|
|
|
Custom,
|
|
|
|
Num_Types
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
EType m_type;
|
|
|
|
Pointfs m_shape;
|
2020-01-09 09:27:42 +00:00
|
|
|
std::string m_texture_filename;
|
|
|
|
std::string m_model_filename;
|
2019-06-14 08:38:09 +00:00
|
|
|
mutable BoundingBoxf3 m_bounding_box;
|
|
|
|
mutable BoundingBoxf3 m_extended_bounding_box;
|
2019-02-19 14:15:27 +00:00
|
|
|
Polygon m_polygon;
|
|
|
|
GeometryBuffer m_triangles;
|
|
|
|
GeometryBuffer m_gridlines;
|
2019-02-20 14:23:23 +00:00
|
|
|
mutable GLTexture m_texture;
|
2020-01-09 09:27:42 +00:00
|
|
|
mutable GLBed m_model;
|
2019-06-02 09:01:51 +00:00
|
|
|
// temporary texture shown until the main texture has still no levels compressed
|
|
|
|
mutable GLTexture m_temp_texture;
|
2019-02-20 14:23:23 +00:00
|
|
|
mutable Shader m_shader;
|
|
|
|
mutable unsigned int m_vbo_id;
|
2019-02-19 14:15:27 +00:00
|
|
|
Axes m_axes;
|
|
|
|
|
|
|
|
mutable float m_scale_factor;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Bed3D();
|
2019-02-20 14:23:23 +00:00
|
|
|
~Bed3D() { reset(); }
|
2019-02-19 14:15:27 +00:00
|
|
|
|
|
|
|
EType get_type() const { return m_type; }
|
|
|
|
|
|
|
|
bool is_custom() const { return m_type == Custom; }
|
|
|
|
|
|
|
|
const Pointfs& get_shape() const { return m_shape; }
|
|
|
|
// Return true if the bed shape changed, so the calee will update the UI.
|
2019-07-24 12:02:36 +00:00
|
|
|
bool set_shape(const Pointfs& shape, const std::string& custom_texture, const std::string& custom_model);
|
2019-02-19 14:15:27 +00:00
|
|
|
|
2020-04-14 11:18:08 +00:00
|
|
|
const BoundingBoxf3& get_bounding_box(bool extended) const {
|
|
|
|
return extended ? m_extended_bounding_box : m_bounding_box;
|
|
|
|
}
|
|
|
|
|
2019-02-19 14:15:27 +00:00
|
|
|
bool contains(const Point& point) const;
|
|
|
|
Point point_projection(const Point& point) const;
|
|
|
|
|
2020-04-14 11:18:08 +00:00
|
|
|
void render(GLCanvas3D& canvas, bool bottom, float scale_factor,
|
|
|
|
bool show_axes, bool show_texture) const;
|
2019-02-19 14:15:27 +00:00
|
|
|
|
|
|
|
private:
|
2019-06-14 08:38:09 +00:00
|
|
|
void calc_bounding_boxes() const;
|
2019-02-19 14:15:27 +00:00
|
|
|
void calc_triangles(const ExPolygon& poly);
|
|
|
|
void calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox);
|
2020-01-09 09:27:42 +00:00
|
|
|
std::tuple<EType, std::string, std::string> detect_type(const Pointfs& shape) const;
|
2019-07-26 07:45:22 +00:00
|
|
|
void render_axes() const;
|
2020-04-14 11:18:08 +00:00
|
|
|
void render_system(GLCanvas3D& canvas, bool bottom, bool show_texture) const;
|
2020-01-09 09:27:42 +00:00
|
|
|
void render_texture(bool bottom, GLCanvas3D& canvas) const;
|
|
|
|
void render_model() const;
|
2020-04-14 11:18:08 +00:00
|
|
|
void render_custom(GLCanvas3D& canvas, bool bottom, bool show_texture) const;
|
2019-07-25 08:38:18 +00:00
|
|
|
void render_default(bool bottom) const;
|
2019-02-20 14:23:23 +00:00
|
|
|
void reset();
|
2019-02-19 14:15:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // GUI
|
|
|
|
} // Slic3r
|
|
|
|
|
|
|
|
#endif // slic3r_3DBed_hpp_
|