Commit c1635bb8 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge branch 'develop' of icube-forge.unistra.fr:cgogn/cgogn into develop

parents 041bfaed d61d1583
......@@ -134,9 +134,9 @@ void MyQT::cb_redraw()
for (std::vector<Utils::Pickable*>::iterator it=m_pickables.begin(); it != m_pickables.end(); ++it)
{
if (*it == m_lastPickedObject)
glLineWidth(2.0);
(*it)->setLineWidth(3.0);
else
glLineWidth(1.0);
(*it)->setLineWidth(1.0);
(*it)->draw();
}
......
......@@ -29,7 +29,8 @@ MCMesh::MCMesh() :
m_drawFaces(true),
m_render(NULL),
m_flatShader(NULL),
m_simpleColorShader(NULL)
m_simpleColorShader(NULL),
m_linesShader(NULL)
{}
void MCMesh::initGUI()
......@@ -58,31 +59,67 @@ void MCMesh::cb_initGL()
m_flatShader->setDiffuse(colDif);
m_flatShader->setExplode(1.0f);
m_simpleColorShader = new Utils::ShaderSimpleColor();
m_simpleColorShader->setAttributePosition(m_positionVBO);
//m_simpleColorShader = new Utils::ShaderSimpleColor();
//m_simpleColorShader->setAttributePosition(m_positionVBO);
m_linesShader = new Utils::ShaderBoldLines();
m_linesShader->setAttributePosition(m_positionVBO);
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()
{
glEnable(GL_BLEND);
m_dr->callList(0.1f);
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)
{
Geom::Vec4f c(0.0f, 0.0f, 0.0f, 0.0f);
m_simpleColorShader->setColor(c);
m_linesShader->setColor(c);
}
else
{
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);
glEnable(GL_LIGHTING);
glEnable(GL_POLYGON_OFFSET_FILL);
......
......@@ -39,9 +39,11 @@
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderBoldLines.h"
#include "Utils/vbo.h"
#include "Algo/Geometry/boundingbox.h"
#include "Utils/drawer.h"
using namespace CGoGN ;
......@@ -79,9 +81,14 @@ public:
Algo::Render::GL2::MapRender* m_render ;
Utils::VBO* m_positionVBO ;
Utils::VBO* m_colorVBO ;
Utils::ShaderFlat* m_flatShader ;
Utils::ShaderSimpleColor* m_simpleColorShader ;
Utils::ShaderBoldLines* m_linesShader ;
Utils::Drawer* m_dr;
DATATYPE valLabel;
SAlgo::MC::Image<DATATYPE>* myImg;
......
......@@ -218,6 +218,7 @@ void MyQT::cb_initGL()
registerShader(m_explode_render->shaderLines());
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->setSize(m_WidthObj/2.0f);
......@@ -254,6 +255,7 @@ void MyQT::cb_redraw()
if (clip_volume && !hide_clipping)
{
m_frame->draw();
m_PlanePick->setLineWidth(2.0f);
m_PlanePick->draw();
}
......
......@@ -442,7 +442,7 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs)
typedef typename PFP::MAP MAP;
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_edges;
......@@ -464,14 +464,14 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs)
{
if (!me.isMarked(d))
{
mf.markOrbit<EDGE>(d);
mf.template markOrbit<EDGE>(d);
Dart f = map.phi1(d);
Dart e = map.cutEdge(d);
attributs[e] = (attributs[d] + attributs[f]) /2.0;
me.template markOrbit<EDGE>(d);
me.template markOrbit<EDGE>(e);
// 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));
else
l_edges.push_back(e);
......@@ -522,7 +522,7 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs)
// compute face average of "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 f = map.template phi<211>(e);
......@@ -537,10 +537,10 @@ void CatmullClarkInterpolSubdivision(typename PFP::MAP& map, EMBV& attributs)
{
Dart xb = map.phi2(x);
if (map.isBoundaryMarked<2>(x))
if (map.template isBoundaryMarked<2>(x))
std::cout << "ERROR " << attributs[x];
if (!map.isBoundaryMarked<2>(xb))
if (!map.template isBoundaryMarked<2>(xb))
{
Dart v1 = map.phi1(x);
Dart v2 = map.phi_1(map.phi2(map.phi_1(x)));
......@@ -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));
}
dm.markOrbit<FACE>(nf);
dm.template markOrbit<FACE>(nf);
fp.push_back(map.phi1(nf));
fp.push_back(map.phi_1(nf));
}
dm.markOrbit<EDGE1>(e);
dm.template markOrbit<EDGE1>(e);
e = map.phi1(e);
} while (e!=d);
}
......
......@@ -118,7 +118,7 @@ public:
// }
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;
}
......
......@@ -28,7 +28,6 @@
#include "Utils/gzstream.h"
#include "Utils/cgognStream.h"
//#define _BLOCKSIZE_ 4096
const unsigned int _BLOCKSIZE_ = 4096;
//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
ATTRIBUTE vec3 VertexPosition;
uniform mat4 ModelViewProjectionMatrix;
VARYING_VERT vec3 posClip;
INVARIANT_POS;
void main ()
{
posClip = VertexPosition;
gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);
}
......@@ -29,6 +29,7 @@
#include "Utils/gl_def.h"
#include "Geometry/vector_gen.h"
#include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/Shaders/shaderBoldColorLines.h"
namespace CGoGN { namespace Utils { class VBO; } }
namespace CGoGN { namespace Utils { namespace SVG { class SVGOut ; } } }
......@@ -65,10 +66,12 @@ protected:
std::vector<Geom::Vec3f> m_dataPos;
std::vector<Geom::Vec3f> m_dataCol;
std::vector<PrimParam> m_begins;
float m_currentWidth;
float m_currentSize;
GLenum m_compile;
Utils::ShaderColorPerVertex* m_shader;
Utils::ShaderBoldColorLines* m_shader2;
public:
......@@ -83,7 +86,11 @@ public:
*/
~Drawer();
Utils::ShaderColorPerVertex* getShader();
// Utils::ShaderColorPerVertex* getShader();
std::vector<Utils::GLSLShader*> getShaders();
void updateMatrices(const glm::mat4& projection, const glm::mat4& modelview);
/**
* init the data structure
......@@ -144,12 +151,12 @@ public:
/**
* call a set of sub-lists
*/
void callSubLists(std::vector<int> indices, float opacity);
// void callSubLists(std::vector<int> indices, float opacity);
/**
* call a set of sub-lists
*/
void callSubLists(int first, int nb, float opacity);
// void callSubLists(int first, int nb, float opacity);
/**
......
......@@ -29,6 +29,7 @@
#include "Utils/vbo_base.h"
#include "glm/glm.hpp"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderBoldLines.h"
#include "Utils/pickables.h"
#include "Utils/dll.h"
......@@ -71,12 +72,13 @@ protected:
/**
* VBO for color
*/
Utils::VBO* m_vboCol;
// Utils::VBO* m_vboCol;
/**
* Shader
*/
Utils::ShaderSimpleColor* m_shader;
Utils::ShaderBoldLines* m_shaderBL;
/**
* the axis to be highlighted
......
......@@ -28,8 +28,8 @@
#include "Utils/vbo_base.h"
#include "glm/glm.hpp"
#include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/Shaders/shaderSimpleColor.h"
//#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderBoldLines.h"
#include "Utils/dll.h"
......@@ -56,7 +56,8 @@ protected:
/**
* Shader
*/
Utils::ShaderSimpleColor* m_shader;
// static Utils::ShaderSimpleColor* s_shader;