Wipe tower rotation - preview box

This commit is contained in:
Lukas Matena 2017-11-30 14:43:47 +01:00
parent 2921302fe9
commit a733df8f37
4 changed files with 10 additions and 8 deletions

View file

@ -198,7 +198,7 @@ sub reload_scene {
$self->volumes->load_wipe_tower_preview(1000, $self->volumes->load_wipe_tower_preview(1000,
$self->{config}->wipe_tower_x, $self->{config}->wipe_tower_y, $self->{config}->wipe_tower_x, $self->{config}->wipe_tower_y,
$self->{config}->wipe_tower_width, $self->{config}->wipe_tower_per_color_wipe * ($extruders_count - 1), $self->{config}->wipe_tower_width, $self->{config}->wipe_tower_per_color_wipe * ($extruders_count - 1),
$self->{model}->bounding_box->z_max, $self->UseVBOs); $self->{model}->bounding_box->z_max, $self->{config}->wipe_tower_rotation_angle, $self->UseVBOs);
} }
} }
} }

View file

@ -301,17 +301,19 @@ std::vector<int> GLVolumeCollection::load_object(
int GLVolumeCollection::load_wipe_tower_preview( int GLVolumeCollection::load_wipe_tower_preview(
int obj_idx, float pos_x, float pos_y, float width, float depth, float height, bool use_VBOs) int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs)
{ {
float color[4] = { 1.0f, 1.0f, 0.0f, 0.5f }; float color[4] = { 1.0f, 1.0f, 0.0f, 0.5f };
this->volumes.emplace_back(new GLVolume(color)); this->volumes.emplace_back(new GLVolume(color));
GLVolume &v = *this->volumes.back(); GLVolume &v = *this->volumes.back();
auto mesh = make_cube(width, depth, height); auto mesh = make_cube(width, depth, height);
v.indexed_vertex_array.load_mesh_flat_shading(mesh); v.origin = Pointf3(pos_x, pos_y, 0.);
v.origin = Pointf3(pos_x, pos_y, 0.); Point origin = Point(pos_x,pos_y);
mesh.rotate(rotation_angle,&origin);
v.indexed_vertex_array.load_mesh_flat_shading(mesh);
// finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry(). // finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
v.bounding_box = v.indexed_vertex_array.bounding_box(); v.bounding_box = v.indexed_vertex_array.bounding_box();
v.indexed_vertex_array.finalize_geometry(use_VBOs); v.indexed_vertex_array.finalize_geometry(use_VBOs);
v.composite_id = obj_idx * 1000000; v.composite_id = obj_idx * 1000000;
v.select_group_id = obj_idx * 1000000; v.select_group_id = obj_idx * 1000000;
v.drag_group_id = obj_idx * 1000; v.drag_group_id = obj_idx * 1000;

View file

@ -226,7 +226,7 @@ public:
const std::string &drag_by); const std::string &drag_by);
int load_wipe_tower_preview( int load_wipe_tower_preview(
int obj_idx, float pos_x, float pos_y, float width, float depth, float height, bool use_VBOs); int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs);
// Bounding box of this volume, in unscaled coordinates. // Bounding box of this volume, in unscaled coordinates.
BoundingBoxf3 bounding_box; BoundingBoxf3 bounding_box;
@ -315,7 +315,7 @@ public:
bool use_VBOs); bool use_VBOs);
int load_wipe_tower_preview( int load_wipe_tower_preview(
int obj_idx, float pos_x, float pos_y, float width, float depth, float height, bool use_VBOs); int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs);
// Render the volumes by OpenGL. // Render the volumes by OpenGL.
void render_VBOs() const; void render_VBOs() const;

View file

@ -76,7 +76,7 @@
std::vector<int> load_object(ModelObject *object, int obj_idx, std::vector<int> instance_idxs, std::string color_by, std::string select_by, std::string drag_by, bool use_VBOs); std::vector<int> load_object(ModelObject *object, int obj_idx, std::vector<int> instance_idxs, std::string color_by, std::string select_by, std::string drag_by, bool use_VBOs);
int load_wipe_tower_preview(int obj_idx, float pos_x, float pos_y, float width, float depth, float height, bool use_VBOs); int load_wipe_tower_preview(int obj_idx, float pos_x, float pos_y, float width, float depth, float height, float rotation_angle, bool use_VBOs);
void erase() void erase()
%code{% THIS->clear(); %}; %code{% THIS->clear(); %};