ENH: thumbnail: optimize the thumbnail
1. set background to transparent 2. set the view to iso Change-Id: Ib3371e60bea743ade55430a5d39b58f9b9acf050
This commit is contained in:
parent
53787b4c9e
commit
a2da7e391b
|
@ -87,7 +87,7 @@ void Camera::set_zoom(double zoom)
|
||||||
void Camera::select_view(const std::string& direction)
|
void Camera::select_view(const std::string& direction)
|
||||||
{
|
{
|
||||||
if (direction == "iso")
|
if (direction == "iso")
|
||||||
set_default_orientation();
|
set_iso_orientation();
|
||||||
else if (direction == "left")
|
else if (direction == "left")
|
||||||
look_at(m_target - m_distance * Vec3d::UnitX(), m_target, Vec3d::UnitZ());
|
look_at(m_target - m_distance * Vec3d::UnitX(), m_target, Vec3d::UnitZ());
|
||||||
else if (direction == "right")
|
else if (direction == "right")
|
||||||
|
@ -578,6 +578,19 @@ void Camera::set_default_orientation()
|
||||||
m_view_matrix.fromPositionOrientationScale(m_view_rotation * (-camera_pos), m_view_rotation, Vec3d::Ones());*/
|
m_view_matrix.fromPositionOrientationScale(m_view_rotation * (-camera_pos), m_view_rotation, Vec3d::Ones());*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Camera::set_iso_orientation()
|
||||||
|
{
|
||||||
|
m_zenit = 45.0f;
|
||||||
|
const double theta_rad = Geometry::deg2rad(-(double)m_zenit);
|
||||||
|
const double phi_rad = Geometry::deg2rad(45.0);
|
||||||
|
const double sin_theta = ::sin(theta_rad);
|
||||||
|
const Vec3d camera_pos = m_target + m_distance * Vec3d(sin_theta * ::sin(phi_rad), sin_theta * ::cos(phi_rad), ::cos(theta_rad));
|
||||||
|
m_view_rotation = Eigen::AngleAxisd(theta_rad, Vec3d::UnitX()) * Eigen::AngleAxisd(phi_rad, Vec3d::UnitZ());
|
||||||
|
m_view_rotation.normalize();
|
||||||
|
m_view_matrix.fromPositionOrientationScale(m_view_rotation * (-camera_pos), m_view_rotation, Vec3d::Ones());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Vec3d Camera::validate_target(const Vec3d& target) const
|
Vec3d Camera::validate_target(const Vec3d& target) const
|
||||||
{
|
{
|
||||||
BoundingBoxf3 test_box = m_scene_box;
|
BoundingBoxf3 test_box = m_scene_box;
|
||||||
|
|
|
@ -163,6 +163,7 @@ private:
|
||||||
void set_distance(double distance);
|
void set_distance(double distance);
|
||||||
|
|
||||||
void set_default_orientation();
|
void set_default_orientation();
|
||||||
|
void set_iso_orientation();
|
||||||
Vec3d validate_target(const Vec3d& target) const;
|
Vec3d validate_target(const Vec3d& target) const;
|
||||||
void update_zenit();
|
void update_zenit();
|
||||||
void update_target();
|
void update_target();
|
||||||
|
|
|
@ -1091,7 +1091,7 @@ int GLCanvas3D::GetHoverId()
|
||||||
if (m_hover_plate_idxs.size() == 0) {
|
if (m_hover_plate_idxs.size() == 0) {
|
||||||
return -1; }
|
return -1; }
|
||||||
return m_hover_plate_idxs.front();
|
return m_hover_plate_idxs.front();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrinterTechnology GLCanvas3D::current_printer_technology() const {
|
PrinterTechnology GLCanvas3D::current_printer_technology() const {
|
||||||
|
@ -5563,9 +5563,12 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
||||||
else {
|
else {
|
||||||
camera.zoom_to_box(volumes_box);
|
camera.zoom_to_box(volumes_box);
|
||||||
|
|
||||||
const Vec3d& target = camera.get_target();
|
//const Vec3d& target = camera.get_target();
|
||||||
double distance = camera.get_distance();
|
//double distance = camera.get_distance();
|
||||||
camera.look_at(target - 0.707 * distance * Vec3d::UnitY() + 0.3 * distance * Vec3d::UnitZ(), target, Vec3d::UnitY() + Vec3d::UnitZ());
|
//camera.look_at(target - 0.707 * distance * Vec3d::UnitY() + 0.3 * distance * Vec3d::UnitZ(), target, Vec3d::UnitY() + Vec3d::UnitZ());
|
||||||
|
|
||||||
|
//BBS: use original iso view for thumbnail
|
||||||
|
camera.select_view("iso");
|
||||||
}
|
}
|
||||||
|
|
||||||
camera.apply_view_matrix();
|
camera.apply_view_matrix();
|
||||||
|
@ -5590,9 +5593,9 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
||||||
//glsafe(::glClearColor(0.50f, 0.5f, 0.5f, 1.0f));
|
//glsafe(::glClearColor(0.50f, 0.5f, 0.5f, 1.0f));
|
||||||
//glsafe(::glClearColor(0.121568f, 0.121568f, 0.121568f, 1.0f));
|
//glsafe(::glClearColor(0.121568f, 0.121568f, 0.121568f, 1.0f));
|
||||||
//glsafe(::glClearColor(0.17647f, 0.17647f, 0.17647f, 1.0f));
|
//glsafe(::glClearColor(0.17647f, 0.17647f, 0.17647f, 1.0f));
|
||||||
glsafe(::glClearColor(0.906f, 0.906f, 0.906f, 1.0f));
|
//glsafe(::glClearColor(0.906f, 0.906f, 0.906f, 1.0f));
|
||||||
//glsafe(::glClearColor(0.37647f, 0.37647f, 0.37647f, 0.5f)); too lite
|
//glsafe(::glClearColor(0.37647f, 0.37647f, 0.37647f, 0.5f)); too lite
|
||||||
//glsafe(::glClearColor(0.23529f, 0.26666f, 0.2745f, 1.0f));
|
glsafe(::glClearColor(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
||||||
|
|
Loading…
Reference in New Issue