Fixed normals on wipe tower box

This commit is contained in:
Enrico Turri 2018-05-03 11:09:13 +02:00
parent 20d9bda87e
commit d19b1162b3
2 changed files with 14 additions and 7 deletions

View File

@ -51,9 +51,6 @@ TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Point3>& fa
for (int i = 0; i < stl.stats.number_of_facets; i++) {
stl_facet facet;
facet.normal.x = 0;
facet.normal.y = 0;
facet.normal.z = 0;
const Pointf3& ref_f1 = points[facets[i].x];
facet.vertex[0].x = ref_f1.x;
@ -73,6 +70,13 @@ TriangleMesh::TriangleMesh(const Pointf3s &points, const std::vector<Point3>& fa
facet.extra[0] = 0;
facet.extra[1] = 0;
float normal[3];
stl_calculate_normal(normal, &facet);
stl_normalize_vector(normal);
facet.normal.x = normal[0];
facet.normal.y = normal[1];
facet.normal.z = normal[2];
stl.facet_start[i] = facet;
}
stl_get_size(&stl);

View File

@ -443,10 +443,13 @@ std::vector<int> GLVolumeCollection::load_object(
int GLVolumeCollection::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)
{
float color[4] = { 1.0f, 1.0f, 0.0f, 0.5f };
float color[4] = { 0.5f, 0.5f, 0.0f, 0.5f };
this->volumes.emplace_back(new GLVolume(color));
GLVolume &v = *this->volumes.back();
if (height == 0.0f)
height = 0.1f;
auto mesh = make_cube(width, depth, height);
mesh.translate(-width / 2.f, -depth / 2.f, 0.f);
Point origin_of_rotation(0.f, 0.f);