Commit d61d1583 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' into 'develop'

Develop

See merge request !64
parents eadfb56d b6a91c26
...@@ -134,9 +134,9 @@ void MyQT::cb_redraw() ...@@ -134,9 +134,9 @@ void MyQT::cb_redraw()
for (std::vector<Utils::Pickable*>::iterator it=m_pickables.begin(); it != m_pickables.end(); ++it) for (std::vector<Utils::Pickable*>::iterator it=m_pickables.begin(); it != m_pickables.end(); ++it)
{ {
if (*it == m_lastPickedObject) if (*it == m_lastPickedObject)
glLineWidth(2.0); (*it)->setLineWidth(3.0);
else else
glLineWidth(1.0); (*it)->setLineWidth(1.0);
(*it)->draw(); (*it)->draw();
} }
......
...@@ -29,7 +29,8 @@ MCMesh::MCMesh() : ...@@ -29,7 +29,8 @@ MCMesh::MCMesh() :
m_drawFaces(true), m_drawFaces(true),
m_render(NULL), m_render(NULL),
m_flatShader(NULL), m_flatShader(NULL),
m_simpleColorShader(NULL) m_simpleColorShader(NULL),
m_linesShader(NULL)
{} {}
void MCMesh::initGUI() void MCMesh::initGUI()
...@@ -58,31 +59,67 @@ void MCMesh::cb_initGL() ...@@ -58,31 +59,67 @@ void MCMesh::cb_initGL()
m_flatShader->setDiffuse(colDif); m_flatShader->setDiffuse(colDif);
m_flatShader->setExplode(1.0f); m_flatShader->setExplode(1.0f);
m_simpleColorShader = new Utils::ShaderSimpleColor(); //m_simpleColorShader = new Utils::ShaderSimpleColor();
m_simpleColorShader->setAttributePosition(m_positionVBO); //m_simpleColorShader->setAttributePosition(m_positionVBO);
m_linesShader = new Utils::ShaderBoldLines();
m_linesShader->setAttributePosition(m_positionVBO);
registerShader(m_flatShader); registerShader(m_flatShader);
registerShader(m_simpleColorShader); // registerShader(m_simpleColorShader);
registerShader(m_linesShader);
m_dr = new Utils::Drawer();
m_dr->newList();
m_dr->pointSize(4.0f);
m_dr->lineWidth(25.0f);
m_dr->begin(GL_LINES);
m_dr->color3f(1.0,0.0,0.0);
m_dr->vertex3f(15.0,15.0,65.0);
m_dr->vertex3f(110.0,110.0,65.0);
m_dr->color3f(0.0,1.0,0.0);
m_dr->vertex3f(110.0,15.0,75.0);
m_dr->vertex3f(15.0,110.0,75.0);
m_dr->end();
m_dr->endList();
} }
void MCMesh::cb_redraw() void MCMesh::cb_redraw()
{ {
glEnable(GL_BLEND);
m_dr->callList(0.1f);
if (m_drawEdges) if (m_drawEdges)
// {
// glLineWidth(1.0f);
// if (m_drawFaces)
// {
// Geom::Vec4f c(0.0f, 0.0f, 0.0f, 0.0f);
// m_simpleColorShader->setColor(c);
// }
// else
// {
// Geom::Vec4f c(1.0f, 1.0f, 0.0f, 0.0f);
// m_simpleColorShader->setColor(c);
// }
// m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES);
// }
{ {
glLineWidth(1.0f); m_linesShader->setLineWidth(2.0f);
if (m_drawFaces) if (m_drawFaces)
{ {
Geom::Vec4f c(0.0f, 0.0f, 0.0f, 0.0f); Geom::Vec4f c(0.0f, 0.0f, 0.0f, 0.0f);
m_simpleColorShader->setColor(c); m_linesShader->setColor(c);
} }
else else
{ {
Geom::Vec4f c(1.0f, 1.0f, 0.0f, 0.0f); Geom::Vec4f c(1.0f, 1.0f, 0.0f, 0.0f);
m_simpleColorShader->setColor(c); m_linesShader->setColor(c);
} }
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES); m_render->draw(m_linesShader, Algo::Render::GL2::LINES);
} }
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_FILL);
......
...@@ -39,9 +39,11 @@ ...@@ -39,9 +39,11 @@
#include "Algo/Render/GL2/mapRender.h" #include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderFlat.h" #include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderBoldLines.h"
#include "Utils/vbo.h" #include "Utils/vbo.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
#include "Utils/drawer.h"
using namespace CGoGN ; using namespace CGoGN ;
...@@ -79,9 +81,14 @@ public: ...@@ -79,9 +81,14 @@ public:
Algo::Render::GL2::MapRender* m_render ; Algo::Render::GL2::MapRender* m_render ;
Utils::VBO* m_positionVBO ; Utils::VBO* m_positionVBO ;
Utils::VBO* m_colorVBO ;
Utils::ShaderFlat* m_flatShader ; Utils::ShaderFlat* m_flatShader ;
Utils::ShaderSimpleColor* m_simpleColorShader ; Utils::ShaderSimpleColor* m_simpleColorShader ;
Utils::ShaderBoldLines* m_linesShader ;
Utils::Drawer* m_dr;
DATATYPE valLabel; DATATYPE valLabel;
SAlgo::MC::Image<DATATYPE>* myImg; SAlgo::MC::Image<DATATYPE>* myImg;
......
...@@ -218,6 +218,7 @@ void MyQT::cb_initGL() ...@@ -218,6 +218,7 @@ void MyQT::cb_initGL()
registerShader(m_explode_render->shaderLines()); registerShader(m_explode_render->shaderLines());
m_PlanePick = new Utils::Pickable(Utils::Pickable::GRID,1); m_PlanePick = new Utils::Pickable(Utils::Pickable::GRID,1);
m_PlanePick->drawable()->setColor(Geom::Vec4f(1.0f,1.0f,0.0f,0.0f));
m_frame = new Utils::FrameManipulator(); m_frame = new Utils::FrameManipulator();
m_frame->setSize(m_WidthObj/2.0f); m_frame->setSize(m_WidthObj/2.0f);
...@@ -254,6 +255,7 @@ void MyQT::cb_redraw() ...@@ -254,6 +255,7 @@ void MyQT::cb_redraw()
if (clip_volume && !hide_clipping) if (clip_volume && !hide_clipping)
{ {
m_frame->draw(); m_frame->draw();
m_PlanePick->setLineWidth(2.0f);
m_PlanePick->draw(); m_PlanePick->draw();
} }
......
...@@ -442,7 +442,7 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs) ...@@ -442,7 +442,7 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs)
typedef typename PFP::MAP MAP; typedef typename PFP::MAP MAP;
typedef typename EMBV::DATA_TYPE EMB; typedef typename EMBV::DATA_TYPE EMB;
VertexAutoAttribute<EMB, PFP::MAP> facesAverage(map); VertexAutoAttribute<EMB, typename PFP::MAP> facesAverage(map);
std::vector<Dart> l_vertices; std::vector<Dart> l_vertices;
std::vector<Dart> l_edges; std::vector<Dart> l_edges;
...@@ -464,14 +464,14 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs) ...@@ -464,14 +464,14 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs)
{ {
if (!me.isMarked(d)) if (!me.isMarked(d))
{ {
mf.markOrbit<EDGE>(d); mf.template markOrbit<EDGE>(d);
Dart f = map.phi1(d); Dart f = map.phi1(d);
Dart e = map.cutEdge(d); Dart e = map.cutEdge(d);
attributs[e] = (attributs[d] + attributs[f]) /2.0; attributs[e] = (attributs[d] + attributs[f]) /2.0;
me.template markOrbit<EDGE>(d); me.template markOrbit<EDGE>(d);
me.template markOrbit<EDGE>(e); me.template markOrbit<EDGE>(e);
// warning store the dart that does not belong to the boundary // warning store the dart that does not belong to the boundary
if (map.isBoundaryMarked<2>(e)) if (map.template isBoundaryMarked<2>(e))
l_edges.push_back(map.phi2(d)); l_edges.push_back(map.phi2(d));
else else
l_edges.push_back(e); l_edges.push_back(e);
...@@ -522,7 +522,7 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs) ...@@ -522,7 +522,7 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs)
// compute face average of "edges" // compute face average of "edges"
for (Dart e : l_edges) for (Dart e : l_edges)
{ {
if (!map.isBoundaryMarked<2>(map.phi2(e))) // faster than map.isBoundaryEdge(e) if (!map.template isBoundaryMarked<2>(map.phi2(e))) // faster than map.isBoundaryEdge(e)
{ {
Dart ff = map.phi_1(e); Dart ff = map.phi_1(e);
Dart f = map.template phi<211>(e); Dart f = map.template phi<211>(e);
...@@ -537,10 +537,10 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs) ...@@ -537,10 +537,10 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs)
{ {
Dart xb = map.phi2(x); Dart xb = map.phi2(x);
if (map.isBoundaryMarked<2>(x)) if (map.template isBoundaryMarked<2>(x))
std::cout << "ERROR " << attributs[x]; std::cout << "ERROR " << attributs[x];
if (!map.isBoundaryMarked<2>(xb)) if (!map.template isBoundaryMarked<2>(xb))
{ {
Dart v1 = map.phi1(x); Dart v1 = map.phi1(x);
Dart v2 = map.phi_1(map.phi2(map.phi_1(x))); Dart v2 = map.phi_1(map.phi2(map.phi_1(x)));
...@@ -860,11 +860,11 @@ void DooSabin(typename PFP::MAP& map, EMBV& position) ...@@ -860,11 +860,11 @@ void DooSabin(typename PFP::MAP& map, EMBV& position)
Algo::Topo::setOrbitEmbedding<VERTEX>(map, map.template phi<11>(nf), map.template getEmbedding<EDGE>(e2)); Algo::Topo::setOrbitEmbedding<VERTEX>(map, map.template phi<11>(nf), map.template getEmbedding<EDGE>(e2));
} }
dm.markOrbit<FACE>(nf); dm.template markOrbit<FACE>(nf);
fp.push_back(map.phi1(nf)); fp.push_back(map.phi1(nf));
fp.push_back(map.phi_1(nf)); fp.push_back(map.phi_1(nf));
} }
dm.markOrbit<EDGE1>(e); dm.template markOrbit<EDGE1>(e);
e = map.phi1(e); e = map.phi1(e);
} while (e!=d); } while (e!=d);
} }
......
...@@ -118,7 +118,7 @@ public: ...@@ -118,7 +118,7 @@ public:
// } // }
for (unsigned int i = 0; i < atmv->m_tableData.size(); ++i) for (unsigned int i = 0; i < atmv->m_tableData.size(); ++i)
memcpy(m_tableData[i],atmv->m_tableData[i],_BLOCKSIZE_/32); memcpy(m_tableData[i],atmv->m_tableData[i],_BLOCKSIZE_/8);
return true; return true;
} }
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "Utils/gzstream.h" #include "Utils/gzstream.h"
#include "Utils/cgognStream.h" #include "Utils/cgognStream.h"
//#define _BLOCKSIZE_ 4096
const unsigned int _BLOCKSIZE_ = 4096; const unsigned int _BLOCKSIZE_ = 4096;
//typedef std::ifstream CGoGNistream; //typedef std::ifstream CGoGNistream;
......
// ShaderBoldColorLines::fragmentShaderText
PRECISION;
VARYING_FRAG vec3 fragColor;
uniform float alpha;
uniform vec4 planeClip;
VARYING_FRAG vec3 fragClip;
FRAG_OUT_DEF;
void main()
{
if (dot(planeClip,vec4(fragClip,1.0))>0.0)
discard;
FRAG_OUT = vec4(fragColor,alpha);
}
// ShaderBoldColorLines::geometryShaderText
uniform vec2 lineWidth;
VARYING_IN vec3 vcolor[];
VARYING_OUT vec3 fragColor;
VARYING_IN vec3 posClip[];
VARYING_OUT vec3 fragClip;
void main()
{
vec3 A = POSITION_IN(0).xyz / abs(POSITION_IN(0).w);
vec3 B = POSITION_IN(1).xyz / abs(POSITION_IN(1).w);
vec3 U = normalize(B-A);
vec3 V = cross(U,vec3(0.0,0.0,1.0));
vec3 LW = vec3(lineWidth,1.0);
fragClip = posClip[0];
fragColor = vcolor[0];
gl_Position = vec4(A-U*LW, 1.0);
EmitVertex();
gl_Position = vec4(A+V*LW, 1.0);
EmitVertex();
gl_Position = vec4(A-V*LW, 1.0);
EmitVertex();
fragColor = vcolor[1];
fragClip = posClip[1];
gl_Position = vec4(B+V*LW, 1.0);
EmitVertex();
gl_Position = vec4(B-V*LW, 1.0);
EmitVertex();
gl_Position = vec4(B+U*LW, 1.0);
EmitVertex();
EndPrimitive();
}
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __CGOGN_SHADER_BOLDCOLORLINES__
#define __CGOGN_SHADER_BOLDCOLORLINES__
#include "Utils/GLSLShader.h"
#include "Utils/clippingShader.h"
#include "Geometry/vector_gen.h"
#include "Utils/dll.h"
namespace CGoGN
{
namespace Utils
{
class CGoGN_UTILS_API ShaderBoldColorLines : public ClippingShader
{
protected:
// shader sources
static std::string vertexShaderText;
static std::string geometryShaderText;
static std::string fragmentShaderText;
CGoGNGLuint m_uniform_lineWidth;
CGoGNGLuint m_unif_alpha;
Geom::Vec2f m_lineWidth;
float m_pixWidth;
VBO* m_vboPos;
VBO* m_vboCol;
float m_opacity;
/// clipping
CGoGNGLuint m_unif_planeClip;
Geom::Vec4f m_planeClip;
void getLocations();
void sendParams();
void restoreUniformsAttribs();
public:
ShaderBoldColorLines();
void setLineWidth(float pix);
void updatePixelWidth();
void setOpacity(float op);
unsigned int setAttributeColor(VBO* vbo);
unsigned int setAttributePosition(VBO* vbo);
void setClippingPlane(const Geom::Vec4f& plane);
inline void setNoClippingPlane() { setClippingPlane(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f)); }
};
} // namespace Utils
} // namespace CGoGN
#endif
// ShaderBoldColorLines::vertexShaderText
ATTRIBUTE vec3 VertexPosition;
ATTRIBUTE vec3 VertexColor;
uniform mat4 ModelViewProjectionMatrix;
VARYING_VERT vec3 vcolor;
VARYING_VERT vec3 posClip;
INVARIANT_POS;
void main ()
{
posClip = VertexPosition;
vcolor = VertexColor;
gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);
}
// ShaderBoldLines::fragmentShaderText
PRECISION;
uniform vec4 lineColor;
uniform vec4 planeClip;
VARYING_FRAG vec3 fragClip;
FRAG_OUT_DEF;
void main()
{
if (dot(planeClip,vec4(fragClip,1.0))>0.0)
discard;
FRAG_OUT = lineColor;
}
// ShaderBoldLines::geometryShaderText
uniform vec2 lineWidth;
VARYING_IN vec3 posClip[];
VARYING_OUT vec3 fragClip;
void main()
{
vec3 A = POSITION_IN(0).xyz / abs(POSITION_IN(0).w);
vec3 B = POSITION_IN(1).xyz / abs(POSITION_IN(1).w);
vec3 U = normalize(B-A);
vec3 V = cross(U,vec3(0.0,0.0,1.0));
vec3 LW = vec3(lineWidth,1.0);
fragClip = posClip[0];
gl_Position = vec4(A-U*LW, 1.0);
EmitVertex();
gl_Position = vec4(A+V*LW, 1.0);
EmitVertex();
gl_Position = vec4(A-V*LW, 1.0);
EmitVertex();
fragClip = posClip[1];
gl_Position = vec4(B+V*LW, 1.0);
EmitVertex();
gl_Position = vec4(B-V*LW, 1.0);
EmitVertex();
gl_Position = vec4(B+U*LW, 1.0);
EmitVertex();
EndPrimitive();
}
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __CGOGN_SHADER_BOLDLINES__
#define __CGOGN_SHADER_BOLDLINES__
#include "Utils/GLSLShader.h"
#include "Utils/clippingShader.h"
#include "Geometry/vector_gen.h"
#include "Utils/dll.h"
namespace CGoGN
{
namespace Utils
{
class CGoGN_UTILS_API ShaderBoldLines : public ClippingShader
{
protected:
// shader sources
static std::string vertexShaderText;
static std::string geometryShaderText;
static std::string fragmentShaderText;
CGoGNGLuint m_uniform_lineWidth;
CGoGNGLuint m_uniform_color;
Geom::Vec2f m_lineWidth;
float m_pixWidth;
Geom::Vec4f m_color;
VBO* m_vboPos;
/// clipping
CGoGNGLuint m_unif_planeClip;
Geom::Vec4f m_planeClip;
void getLocations();
void sendParams();
void restoreUniformsAttribs();
public:
ShaderBoldLines();
void setLineWidth(float pix);
void updatePixelWidth();
void setColor(const Geom::Vec4f& color);
unsigned int setAttributePosition(VBO* vbo);
void setClippingPlane(const Geom::Vec4f& plane);
inline void setNoClippingPlane() { setClippingPlane(Geom::Vec4f(0.0f,0.0f,0.0f,0.0f)); }
};
} // namespace Utils
} // namespace CGoGN
#endif
// ShaderBoldLines::vertexShaderText