Merge pull request #2454 from maxGimeno/Mesh_3_plugin_fix-GF

Polyhedron demo: Fix tets rendering on Windows
This commit is contained in:
Laurent Rineau 2017-10-13 16:53:26 +02:00
commit edac6aaa5a
7 changed files with 13 additions and 45 deletions

View File

@ -1512,7 +1512,9 @@ void MainWindow::on_actionLoad_triggered()
scene->redraw_model();
this->addToRecentFiles(filename);
} else {
int scene_size = scene->numberOfEntries();
open(filename);
if(scene->numberOfEntries() != scene_size)
scene->item(scene->numberOfEntries()-1)->setColor(colors_[++nb_item]);
}
}

View File

@ -49,7 +49,6 @@
<file>resources/euler_facet.png</file>
<file>resources/euler_vertex.png</file>
<file>javascript/lib.js</file>
<file>resources/shader_c3t3_tets.v</file>
<file>resources/shader_flat.f</file>
<file>resources/hexahedron.png</file>
<file>resources/icosphere.png</file>

View File

@ -75,7 +75,7 @@ public :
{
//vao containing the data for the facets
{
program = getShaderProgram(PROGRAM_C3T3_TETS, viewer);
program = getShaderProgram(PROGRAM_C3T3, viewer);
program->bind();
vaos[Facets]->bind();
@ -133,11 +133,14 @@ public :
{
if(is_fast)
return;
const Kernel::Plane_3& plane = qobject_cast<Scene_c3t3_item*>(this->parent())->plane();
vaos[Facets]->bind();
program = getShaderProgram(PROGRAM_C3T3_TETS);
attribBuffers(viewer, PROGRAM_C3T3_TETS);
program = getShaderProgram(PROGRAM_C3T3);
attribBuffers(viewer, PROGRAM_C3T3);
program->bind();
float shrink_factor = qobject_cast<Scene_c3t3_item*>(this->parent())->getShrinkFactor();
QVector4D cp(-plane.a(), -plane.b(), -plane.c(), -plane.d());
program->setUniformValue("cutplane", cp);
program->setUniformValue("shrink_factor", shrink_factor);
// positions_poly is also used for the faces in the cut plane
// and changes when the cut plane is moved
@ -1421,7 +1424,7 @@ void Scene_c3t3_item_priv::computeIntersection(const Primitive& facet)
Tr::Cell_handle ch = facet.id().first;
if(intersected_cells.find(ch) == intersected_cells.end())
{
QColor c = this->colors_subdomains[ch->subdomain_index()].darker(150);
QColor c = this->colors_subdomains[ch->subdomain_index()].light(50);
const Tr::Bare_point& pa = wp2p(ch->vertex(0)->point());
const Tr::Bare_point& pb = wp2p(ch->vertex(1)->point());
@ -1446,9 +1449,10 @@ void Scene_c3t3_item_priv::computeIntersection(const Primitive& facet)
const Tr::Bare_point& pc = wp2p(nh->vertex(2)->point());
const Tr::Bare_point& pd = wp2p(nh->vertex(3)->point());
QColor c = this->colors_subdomains[nh->subdomain_index()].darker(150);
QColor c = this->colors_subdomains[nh->subdomain_index()].light(50);
CGAL::Color color(c.red(), c.green(), c.blue());
intersection->addTriangle(pb, pa, pc, color);
intersection->addTriangle(pa, pb, pd, color);
intersection->addTriangle(pa, pd, pc, color);

View File

@ -815,7 +815,6 @@ void Viewer::attribBuffers(int program_name) const {
case PROGRAM_WITH_TEXTURE:
case PROGRAM_CUTPLANE_SPHERES:
case PROGRAM_SPHERES:
case PROGRAM_C3T3_TETS:
case PROGRAM_OLD_FLAT:
case PROGRAM_FLAT:
program->setUniformValue("light_pos", position);
@ -834,7 +833,6 @@ void Viewer::attribBuffers(int program_name) const {
case PROGRAM_INSTANCED:
case PROGRAM_CUTPLANE_SPHERES:
case PROGRAM_SPHERES:
case PROGRAM_C3T3_TETS:
case PROGRAM_OLD_FLAT:
case PROGRAM_FLAT:
program->setUniformValue("mv_matrix", mv_mat);
@ -1249,9 +1247,6 @@ QOpenGLShaderProgram* Viewer::getShaderProgram(int name) const
case PROGRAM_CUTPLANE_SPHERES:
return declare_program(name, ":/cgal/Polyhedron_3/resources/shader_c3t3_spheres.v" , ":/cgal/Polyhedron_3/resources/shader_c3t3.f");
break;
case PROGRAM_C3T3_TETS:
return declare_program(name, ":/cgal/Polyhedron_3/resources/shader_c3t3_tets.v" , ":/cgal/Polyhedron_3/resources/shader_with_light.f");
break;
case PROGRAM_SPHERES:
return declare_program(name, ":/cgal/Polyhedron_3/resources/shader_spheres.v" , ":/cgal/Polyhedron_3/resources/shader_with_light.f");
break;

View File

@ -1,30 +0,0 @@
#version 120
attribute highp vec4 vertex;
attribute highp vec3 normals;
attribute highp vec3 colors;
attribute highp vec3 barycenter;
uniform highp mat4 mvp_matrix;
uniform highp mat4 mv_matrix;
uniform highp float shrink_factor;
varying highp vec4 fP;
varying highp vec3 fN;
varying highp vec4 color;
void main(void)
{
color = vec4(colors, 1.0);
fP = mv_matrix * vertex;
fN = mat3(mv_matrix)* normals;
highp mat4 transOB = mat4(1, 0, 0, 0, // first column
0, 1, 0, 0, // second column
0, 0, 1, 0, // third column
barycenter.x, barycenter.y, barycenter.z, 1); // fourth column
highp mat4 transBO = mat4(1, 0, 0, 0, // first column
0, 1, 0, 0, // second column
0, 0, 1, 0, // third column
-barycenter.x, -barycenter.y, -barycenter.z, 1); // fourth column
highp mat4 scaling = mat4(shrink_factor, 0, 0, 0,
0, shrink_factor, 0, 0,
0, 0, shrink_factor, 0,
0, 0, 0, 1);
gl_Position = mvp_matrix *transOB * scaling * transBO * vertex;
}

View File

@ -82,7 +82,6 @@ public:
PROGRAM_C3T3_EDGES, /** Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light.*/
PROGRAM_CUTPLANE_SPHERES, /** Used to render the spheres of an item with a cut plane.*/
PROGRAM_SPHERES, /** Used to render one or several spheres.*/
PROGRAM_C3T3_TETS, /** Used to render the tetrahedra of the intersection of a c3t3_item.*/
PROGRAM_FLAT, /** Used to render flat shading without pre computing normals*/
PROGRAM_OLD_FLAT, /** Used to render flat shading without pre computing normals without geometry shader*/
NB_OF_PROGRAMS /** Holds the number of different programs in this enum.*/

View File

@ -71,7 +71,6 @@ public:
PROGRAM_C3T3_EDGES, //! Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light.
PROGRAM_CUTPLANE_SPHERES, //! Used to render the spheres of an item with a cut plane.
PROGRAM_SPHERES, //! Used to render one or several spheres.
PROGRAM_C3T3_TETS, //! Used to render the tetrahedra of the intersection of a c3t3_item.
PROGRAM_FLAT, /** Used to render flat shading without pre computing normals*/
PROGRAM_OLD_FLAT, /** Used to render flat shading without pre computing normals without geometry shader*/
NB_OF_PROGRAMS //! Holds the number of different programs in this enum.