2020-05-11 14:26:35 +00:00
|
|
|
#ifndef slic3r_GLModel_hpp_
|
|
|
|
#define slic3r_GLModel_hpp_
|
|
|
|
|
2020-05-11 14:37:04 +00:00
|
|
|
#include "libslic3r/Point.hpp"
|
2020-05-12 09:33:50 +00:00
|
|
|
#include "libslic3r/BoundingBox.hpp"
|
2020-05-11 14:37:04 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2020-05-11 14:26:35 +00:00
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
class TriangleMesh;
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
struct GLModelInitializationData
|
|
|
|
{
|
|
|
|
std::vector<Vec3f> positions;
|
|
|
|
std::vector<Vec3f> normals;
|
|
|
|
std::vector<Vec3i> triangles;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GL_Model
|
|
|
|
{
|
|
|
|
unsigned int m_vbo_id{ 0 };
|
|
|
|
unsigned int m_ibo_id{ 0 };
|
|
|
|
size_t m_indices_count{ 0 };
|
|
|
|
|
2020-05-12 09:33:50 +00:00
|
|
|
BoundingBoxf3 m_bounding_box;
|
|
|
|
|
2020-05-11 14:26:35 +00:00
|
|
|
public:
|
|
|
|
virtual ~GL_Model() { reset(); }
|
|
|
|
|
2020-05-12 09:33:50 +00:00
|
|
|
void init_from(const GLModelInitializationData& data);
|
|
|
|
void init_from(const TriangleMesh& mesh);
|
2020-05-11 14:26:35 +00:00
|
|
|
void reset();
|
|
|
|
void render() const;
|
|
|
|
|
2020-05-12 09:33:50 +00:00
|
|
|
const BoundingBoxf3& get_bounding_box() const { return m_bounding_box; }
|
|
|
|
|
2020-05-11 14:26:35 +00:00
|
|
|
private:
|
|
|
|
void send_to_gpu(const std::vector<float>& vertices, const std::vector<unsigned int>& indices);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// create an arrow with cylindrical stem and conical tip, with the given dimensions and resolution
|
2020-05-12 09:33:50 +00:00
|
|
|
// the origin of the arrow is in the center of the stem cap
|
|
|
|
// the arrow has its axis of symmetry along the Z axis and is pointing upward
|
2020-05-11 14:26:35 +00:00
|
|
|
GLModelInitializationData stilized_arrow(int resolution, float tip_radius, float tip_height,
|
|
|
|
float stem_radius, float stem_height);
|
|
|
|
|
2020-05-12 14:15:43 +00:00
|
|
|
// create an arrow whose stem is a quarter of circle, with the given dimensions and resolution
|
|
|
|
// the origin of the arrow is in the center of the circle
|
2020-05-13 07:07:06 +00:00
|
|
|
// the arrow is contained in the 1st quadrant of the XY plane and is pointing counterclockwise
|
2020-05-12 14:15:43 +00:00
|
|
|
GLModelInitializationData circular_arrow(int resolution, float radius, float tip_height, float tip_width, float stem_width, float thickness);
|
|
|
|
|
2020-05-13 07:07:06 +00:00
|
|
|
// create an arrow with the given dimensions
|
|
|
|
// the origin of the arrow is in the center of the stem cap
|
|
|
|
// the arrow is contained in XY plane and has its main axis along the Y axis
|
|
|
|
GLModelInitializationData straight_arrow(float tip_width, float tip_height, float stem_width, float stem_height, float thickness);
|
|
|
|
|
2020-05-11 14:26:35 +00:00
|
|
|
} // namespace GUI
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif // slic3r_GLModel_hpp_
|
|
|
|
|