Commit c165b337 authored by Pierre Kraemer's avatar Pierre Kraemer

import images & render colors

parent efc630d4
...@@ -28,6 +28,8 @@ ADD_SUBDIRECTORY(surface_modelisation) ...@@ -28,6 +28,8 @@ ADD_SUBDIRECTORY(surface_modelisation)
ADD_SUBDIRECTORY(surface_distance) ADD_SUBDIRECTORY(surface_distance)
ADD_SUBDIRECTORY(surface_radiance) ADD_SUBDIRECTORY(surface_radiance)
ADD_SUBDIRECTORY(cage2D_deformation)
ADD_SUBDIRECTORY(volume_import) ADD_SUBDIRECTORY(volume_import)
#ADD_SUBDIRECTORY(volume_render) #ADD_SUBDIRECTORY(volume_render)
......
...@@ -113,7 +113,7 @@ void MapParameters::stop(MapHandlerGen* mh) ...@@ -113,7 +113,7 @@ void MapParameters::stop(MapHandlerGen* mh)
bool Surface_Deformation_Plugin::enable() bool Surface_Deformation_Plugin::enable()
{ {
// magic line that init static variables of GenericMap in the plugins // magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers()); GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
m_dockTab = new Surface_Deformation_DockTab(m_schnapps, this); m_dockTab = new Surface_Deformation_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_Deformation"); m_schnapps->addPluginDockTab(this, m_dockTab, "Surface_Deformation");
...@@ -380,16 +380,16 @@ void Surface_Deformation_Plugin::toggleMapDeformation(MapHandlerGen* map) ...@@ -380,16 +380,16 @@ void Surface_Deformation_Plugin::toggleMapDeformation(MapHandlerGen* map)
if(map) if(map)
{ {
MapParameters& p = h_parameterSet[map]; MapParameters& p = h_parameterSet[map];
if(!p.initialized) if (!p.initialized)
{ {
p.start(map); p.start(map);
if(p.initialized && map->isSelectedMap()) if (p.initialized && map->isSelectedMap())
m_dockTab->mapParametersInitialized(true); m_dockTab->mapParametersInitialized(true);
} }
else else
{ {
p.stop(map); p.stop(map);
if(!p.initialized && map->isSelectedMap()) if (!p.initialized && map->isSelectedMap())
m_dockTab->mapParametersInitialized(false); m_dockTab->mapParametersInitialized(false);
} }
} }
...@@ -401,9 +401,9 @@ void Surface_Deformation_Plugin::matchDiffCoord(MapHandlerGen* mh) ...@@ -401,9 +401,9 @@ void Surface_Deformation_Plugin::matchDiffCoord(MapHandlerGen* mh)
MapParameters& p = h_parameterSet[mh]; MapParameters& p = h_parameterSet[mh];
nlMakeCurrent(p.nlContext); nlMakeCurrent(p.nlContext);
if(nlGetCurrentState() == NL_STATE_INITIAL) if (nlGetCurrentState() == NL_STATE_INITIAL)
nlBegin(NL_SYSTEM) ; nlBegin(NL_SYSTEM) ;
for(int coord = 0; coord < 3; ++coord) for (int coord = 0; coord < 3; ++coord)
{ {
LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.freeSelector->getMarker(), p.positionAttribute, coord); LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.freeSelector->getMarker(), p.positionAttribute, coord);
nlBegin(NL_MATRIX); nlBegin(NL_MATRIX);
...@@ -421,13 +421,13 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -421,13 +421,13 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
PFP2::MAP* map = static_cast<MapHandler<PFP2>*>(mh)->getMap(); PFP2::MAP* map = static_cast<MapHandler<PFP2>*>(mh)->getMap();
MapParameters& p = h_parameterSet[mh]; MapParameters& p = h_parameterSet[mh];
if(p.initialized) if (p.initialized)
{ {
CellMarkerNoUnmark<PFP2::MAP, VERTEX> m(*map) ; CellMarkerNoUnmark<PFP2::MAP, VERTEX> m(*map) ;
for(Dart d = map->begin(); d != map->end(); map->next(d)) for (Dart d = map->begin(); d != map->end(); map->next(d))
{ {
if(!m.isMarked(d)) if (!m.isMarked(d))
{ {
m.mark(d) ; m.mark(d) ;
...@@ -441,11 +441,11 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -441,11 +441,11 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
Dart neigh = map->phi1(it) ; Dart neigh = map->phi1(it) ;
PFP2::VEC3 v = p.positionAttribute[neigh] - pp ; PFP2::VEC3 v = p.positionAttribute[neigh] - pp ;
PFP2::VEC3 vv = p.positionInit[neigh] - ppInit ; PFP2::VEC3 vv = p.positionInit[neigh] - ppInit ;
for(unsigned int i = 0; i < 3; ++i) for (unsigned int i = 0; i < 3; ++i)
for(unsigned int j = 0; j < 3; ++j) for (unsigned int j = 0; j < 3; ++j)
cov(i,j) += v[i] * vv[j];// * perMap->edgeWeight[it] / area ; cov(i,j) += v[i] * vv[j];// * perMap->edgeWeight[it] / area ;
Dart dboundary = map->phi_1(it) ; Dart dboundary = map->phi_1(it) ;
if(map->phi2(dboundary) == dboundary) if (map->phi2(dboundary) == dboundary)
{ {
v = p.positionAttribute[dboundary] - pp ; v = p.positionAttribute[dboundary] - pp ;
vv = p.positionInit[dboundary] - pp ; vv = p.positionInit[dboundary] - pp ;
...@@ -454,15 +454,15 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -454,15 +454,15 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
cov(i,j) += v[i] * vv[j];// * perMap->edgeWeight[dboundary] / area ; cov(i,j) += v[i] * vv[j];// * perMap->edgeWeight[dboundary] / area ;
} }
it = map->alpha1(it) ; it = map->alpha1(it) ;
} while(it != d) ; } while (it != d) ;
Eigen::JacobiSVD<Eigen::Matrix3f> svd(cov, Eigen::ComputeFullU | Eigen::ComputeFullV) ; Eigen::JacobiSVD<Eigen::Matrix3f> svd(cov, Eigen::ComputeFullU | Eigen::ComputeFullV) ;
Eigen::Matrix3f R = svd.matrixU() * svd.matrixV().transpose() ; Eigen::Matrix3f R = svd.matrixU() * svd.matrixV().transpose() ;
if(R.determinant() < 0) if (R.determinant() < 0)
{ {
Eigen::Matrix3f U = svd.matrixU() ; Eigen::Matrix3f U = svd.matrixU() ;
for(unsigned int i = 0; i < 3; ++i) for (unsigned int i = 0; i < 3; ++i)
U(i,2) *= -1 ; U(i,2) *= -1 ;
R = U * svd.matrixV().transpose() ; R = U * svd.matrixV().transpose() ;
} }
...@@ -471,9 +471,9 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -471,9 +471,9 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
} }
} }
for(Dart d = map->begin(); d != map->end(); map->next(d)) for (Dart d = map->begin(); d != map->end(); map->next(d))
{ {
if(m.isMarked(d)) if (m.isMarked(d))
{ {
m.unmark(d) ; m.unmark(d) ;
...@@ -491,7 +491,7 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -491,7 +491,7 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
++degree ; ++degree ;
} }
it = map->alpha1(it) ; it = map->alpha1(it) ;
} while(it != d) ; } while (it != d) ;
r += p.vertexRotationMatrix[d] ; r += p.vertexRotationMatrix[d] ;
r /= degree + 1 ; r /= degree + 1 ;
PFP2::VEC3& dc = p.diffCoord[d] ; PFP2::VEC3& dc = p.diffCoord[d] ;
...@@ -531,9 +531,9 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh) ...@@ -531,9 +531,9 @@ void Surface_Deformation_Plugin::asRigidAsPossible(MapHandlerGen* mh)
} }
nlMakeCurrent(p.nlContext); nlMakeCurrent(p.nlContext);
if(nlGetCurrentState() == NL_STATE_INITIAL) if (nlGetCurrentState() == NL_STATE_INITIAL)
nlBegin(NL_SYSTEM); nlBegin(NL_SYSTEM);
for(int coord = 0; coord < 3; ++coord) for (int coord = 0; coord < 3; ++coord)
{ {
LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.freeSelector->getMarker(), p.positionAttribute, coord); LinearSolving::setupVariables<PFP2>(*map, p.vIndex, p.freeSelector->getMarker(), p.positionAttribute, coord);
nlBegin(NL_MATRIX); nlBegin(NL_MATRIX);
......
...@@ -29,11 +29,15 @@ private: ...@@ -29,11 +29,15 @@ private:
virtual void disable() {} virtual void disable() {}
public slots: public slots:
MapHandlerGen* importFromFile(const QString& fileName); MapHandlerGen* importMeshFromFile(const QString& fileName);
void importFromFileDialog(); void importMeshFromFileDialog();
MapHandlerGen* importImageFromFile(const QString& fileName);
void importImageFromFileDialog();
private: private:
QAction* importAction; QAction* importMeshAction;
QAction* importImageAction;
}; };
} // namespace SCHNApps } // namespace SCHNApps
...@@ -41,4 +45,3 @@ private: ...@@ -41,4 +45,3 @@ private:
} // namespace CGoGN } // namespace CGoGN
#endif #endif
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "mapHandler.h" #include "mapHandler.h"
#include "Algo/Import/import.h" #include "Algo/Import/import.h"
#include "Algo/Tiling/Surface/square.h"
#include <QFileDialog> #include <QFileDialog>
#include <QFileInfo> #include <QFileInfo>
...@@ -19,13 +20,18 @@ bool Surface_Import_Plugin::enable() ...@@ -19,13 +20,18 @@ bool Surface_Import_Plugin::enable()
// magic line that init static variables of GenericMap in the plugins // magic line that init static variables of GenericMap in the plugins
GenericMap::copyAllStatics(m_schnapps->getStaticPointers()); GenericMap::copyAllStatics(m_schnapps->getStaticPointers());
importAction = new QAction("import", this); importMeshAction = new QAction("import mesh", this);
m_schnapps->addMenuAction(this, "Surface;Import", importAction); m_schnapps->addMenuAction(this, "Surface;Import Mesh", importMeshAction);
connect(importAction, SIGNAL(triggered()), this, SLOT(importFromFileDialog())); connect(importMeshAction, SIGNAL(triggered()), this, SLOT(importMeshFromFileDialog()));
importImageAction = new QAction("import image", this);
m_schnapps->addMenuAction(this, "Surface;Import Image", importImageAction);
connect(importImageAction, SIGNAL(triggered()), this, SLOT(importImageFromFileDialog()));
return true; return true;
} }
MapHandlerGen* Surface_Import_Plugin::importFromFile(const QString& fileName) MapHandlerGen* Surface_Import_Plugin::importMeshFromFile(const QString& fileName)
{ {
QFileInfo fi(fileName); QFileInfo fi(fileName);
if(fi.exists()) if(fi.exists())
...@@ -58,12 +64,72 @@ MapHandlerGen* Surface_Import_Plugin::importFromFile(const QString& fileName) ...@@ -58,12 +64,72 @@ MapHandlerGen* Surface_Import_Plugin::importFromFile(const QString& fileName)
return NULL; return NULL;
} }
void Surface_Import_Plugin::importFromFileDialog() void Surface_Import_Plugin::importMeshFromFileDialog()
{ {
QStringList fileNames = QFileDialog::getOpenFileNames(m_schnapps, "Import surfaces", m_schnapps->getAppPath(), "Surface mesh Files (*.ply *.off *.trian)"); QStringList fileNames = QFileDialog::getOpenFileNames(m_schnapps, "Import surface meshes", m_schnapps->getAppPath(), "Surface mesh Files (*.ply *.off *.trian)");
QStringList::Iterator it = fileNames.begin(); QStringList::Iterator it = fileNames.begin();
while(it != fileNames.end()) { while(it != fileNames.end())
importFromFile(*it); {
importMeshFromFile(*it);
++it;
}
}
MapHandlerGen* Surface_Import_Plugin::importImageFromFile(const QString& fileName)
{
QFileInfo fi(fileName);
if(fi.exists())
{
MapHandlerGen* mhg = m_schnapps->addMap(fi.baseName(), 2);
if(mhg)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg);
PFP2::MAP* map = mh->getMap();
VertexAttribute<PFP2::VEC3, PFP2::MAP> position = map->addAttribute<PFP2::VEC3, VERTEX, PFP2::MAP>("position");
VertexAttribute<PFP2::VEC3, PFP2::MAP> color = map->addAttribute<PFP2::VEC3, VERTEX, PFP2::MAP>("color");
QImage image;
QString extension = fi.suffix();
extension.toUpper();
if(!image.load(fileName, extension.toUtf8().constData()))
{
CGoGNout << "Image [" << fileName.toStdString() << "] has not been loaded correctly" << CGoGNendl;
return NULL;
}
int imageX = image.width();
int imageY = image.height();
Algo::Surface::Tilings::Square::Grid<PFP2> grid(*map, imageX - 1, imageY - 1);
grid.embedIntoGrid(position, imageX - 1, imageY - 1);
const std::vector<Dart>& vDarts = grid.getVertexDarts();
QRgb pixel;
for(int i = 0; i < imageX; ++i)
{
for(int j = 0; j < imageY; ++j)
{
pixel = image.pixel(i, (imageY-j) - 1);
color[vDarts[j*imageX + i]] = PFP2::VEC3(qRed(pixel)/255.f, qGreen(pixel)/255.f, qBlue(pixel)/255.f);
}
}
mh->registerAttribute(position);
mh->registerAttribute(color);
}
return mhg;
}
else
return NULL;
}
void Surface_Import_Plugin::importImageFromFileDialog()
{
QStringList fileNames = QFileDialog::getOpenFileNames(m_schnapps, "Import images", m_schnapps->getAppPath(), "Surface mesh Files (*.png *.jpg *.jpeg)");
QStringList::Iterator it = fileNames.begin();
while(it != fileNames.end())
{
importImageFromFile(*it);
++it; ++it;
} }
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "Utils/Shaders/shaderFlat.h" #include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderPhong.h" #include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderColorPerVertex.h"
#include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/pointSprite.h" #include "Utils/pointSprite.h"
...@@ -28,19 +29,21 @@ struct MapParameters ...@@ -28,19 +29,21 @@ struct MapParameters
MapParameters() : MapParameters() :
positionVBO(NULL), positionVBO(NULL),
normalVBO(NULL), normalVBO(NULL),
colorVBO(NULL),
verticesScaleFactor(1.0f), verticesScaleFactor(1.0f),
renderVertices(false), renderVertices(false),
renderEdges(false), renderEdges(false),
renderFaces(true), renderFaces(true),
faceStyle(FLAT), faceStyle(FLAT),
diffuseColor(0.8f,0.9f,0.7f,0.0f), diffuseColor(0.85f,0.25f,0.19f,0.0f),
simpleColor(0.0f,0.0f,0.0f,0.0f), simpleColor(0.0f,0.0f,0.0f,0.0f),
vertexColor(0.0f,0.0f,1.0f,0.0f) vertexColor(0.0f,0.0f,1.0f,0.0f)
{} {}
Utils::VBO* positionVBO; Utils::VBO* positionVBO;
Utils::VBO* normalVBO; Utils::VBO* normalVBO;
Utils::VBO* colorVBO;
float verticesScaleFactor; float verticesScaleFactor;
bool renderVertices; bool renderVertices;
bool renderEdges; bool renderEdges;
...@@ -56,10 +59,12 @@ struct MapParameters ...@@ -56,10 +59,12 @@ struct MapParameters
class Surface_Render_Plugin : public PluginInteraction class Surface_Render_Plugin : public PluginInteraction
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin) Q_INTERFACES(CGoGN::SCHNApps::Plugin)
#if CGOGN_QT_DESIRED_VERSION == 5 #if CGOGN_QT_DESIRED_VERSION == 5
Q_PLUGIN_METADATA(IID "CGoGN.SCHNapps.Plugin") Q_PLUGIN_METADATA(IID "CGoGN.SCHNapps.Plugin")
#endif #endif
friend class Surface_Render_DockTab; friend class Surface_Render_DockTab;
public: public:
...@@ -103,6 +108,7 @@ public slots: ...@@ -103,6 +108,7 @@ public slots:
// slots for Python calls // slots for Python calls
void changePositionVBO(const QString& view, const QString& map, const QString& vbo); void changePositionVBO(const QString& view, const QString& map, const QString& vbo);
void changeNormalVBO(const QString& view, const QString& map, const QString& vbo); void changeNormalVBO(const QString& view, const QString& map, const QString& vbo);
void changeColorVBO(const QString& view, const QString& map, const QString& vbo);
void changeRenderVertices(const QString& view, const QString& map, bool b); void changeRenderVertices(const QString& view, const QString& map, bool b);
void changeVerticesScaleFactor(const QString&view, const QString& map, float f); void changeVerticesScaleFactor(const QString&view, const QString& map, float f);
void changeRenderEdges(const QString& view, const QString& map, bool b); void changeRenderEdges(const QString& view, const QString& map, bool b);
...@@ -119,6 +125,7 @@ protected: ...@@ -119,6 +125,7 @@ protected:
CGoGN::Utils::ShaderFlat* m_flatShader; CGoGN::Utils::ShaderFlat* m_flatShader;
CGoGN::Utils::ShaderPhong* m_phongShader; CGoGN::Utils::ShaderPhong* m_phongShader;
CGoGN::Utils::ShaderColorPerVertex* m_colorPerVertexShader;
CGoGN::Utils::ShaderSimpleColor* m_simpleColorShader; CGoGN::Utils::ShaderSimpleColor* m_simpleColorShader;
CGoGN::Utils::PointSprite* m_pointSprite; CGoGN::Utils::PointSprite* m_pointSprite;
}; };
......
...@@ -27,16 +27,19 @@ public: ...@@ -27,16 +27,19 @@ public:
private: private:
SCHNApps* m_schnapps; SCHNApps* m_schnapps;
Surface_Render_Plugin* m_plugin; Surface_Render_Plugin* m_plugin;
bool b_updatingUI;
QColorDialog* m_colorDial; QColorDialog* m_colorDial;
QColor m_diffuseColor; QColor m_diffuseColor;
QColor m_simpleColor; QColor m_simpleColor;
QColor m_vertexColor; QColor m_vertexColor;
int m_currentColorDial; int m_currentColorDial;
bool b_updatingUI;
private slots: private slots:
void positionVBOChanged(int index); void positionVBOChanged(int index);
void normalVBOChanged(int index); void normalVBOChanged(int index);
void colorVBOChanged(int index);
void renderVerticesChanged(bool b); void renderVerticesChanged(bool b);
void verticesScaleFactorChanged(int i); void verticesScaleFactorChanged(int i);
void renderEdgesChanged(bool b); void renderEdgesChanged(bool b);
...@@ -49,13 +52,13 @@ private slots: ...@@ -49,13 +52,13 @@ private slots:
void vertexColorClicked(); void vertexColorClicked();
void colorSelected(const QColor& col); void colorSelected(const QColor& col);
private: private:
void addPositionVBO(QString name); void addPositionVBO(QString name);
void removePositionVBO(QString name); void removePositionVBO(QString name);
void addNormalVBO(QString name); void addNormalVBO(QString name);
void removeNormalVBO(QString name); void removeNormalVBO(QString name);
void addColorVBO(QString name);
void removeColorVBO(QString name);
void updateMapParameters(); void updateMapParameters();
}; };
......
...@@ -19,14 +19,14 @@ bool Surface_Render_Plugin::enable() ...@@ -19,14 +19,14 @@ bool Surface_Render_Plugin::enable()
m_flatShader = new CGoGN::Utils::ShaderFlat(); m_flatShader = new CGoGN::Utils::ShaderFlat();
m_flatShader->setAmbiant(CGoGN::Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f)); m_flatShader->setAmbiant(CGoGN::Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f));
m_flatShader->setDiffuse(CGoGN::Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f));
m_flatShader->setExplode(1.0f); m_flatShader->setExplode(1.0f);
m_phongShader = new CGoGN::Utils::ShaderPhong() ; m_phongShader = new CGoGN::Utils::ShaderPhong();
m_phongShader->setAmbiant(CGoGN::Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f)) ; m_phongShader->setAmbiant(CGoGN::Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f));
m_phongShader->setDiffuse(CGoGN::Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f)) ; m_phongShader->setSpecular(CGoGN::Geom::Vec4f(0.9f, 0.9f, 0.9f, 1.0f));
m_phongShader->setSpecular(CGoGN::Geom::Vec4f(0.9f, 0.9f, 0.9f, 1.0f)) ; m_phongShader->setShininess(80.0f);
m_phongShader->setShininess(80.0f) ;
m_colorPerVertexShader = new CGoGN::Utils::ShaderColorPerVertex();
m_simpleColorShader = new CGoGN::Utils::ShaderSimpleColor(); m_simpleColorShader = new CGoGN::Utils::ShaderSimpleColor();
...@@ -34,6 +34,7 @@ bool Surface_Render_Plugin::enable() ...@@ -34,6 +34,7 @@ bool Surface_Render_Plugin::enable()
registerShader(m_flatShader); registerShader(m_flatShader);
registerShader(m_phongShader); registerShader(m_phongShader);
registerShader(m_colorPerVertexShader);
registerShader(m_simpleColorShader); registerShader(m_simpleColorShader);
registerShader(m_pointSprite); registerShader(m_pointSprite);
...@@ -82,9 +83,18 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -82,9 +83,18 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
switch(p.faceStyle) switch(p.faceStyle)
{ {
case MapParameters::FLAT : case MapParameters::FLAT :
m_flatShader->setAttributePosition(p.positionVBO); if(p.colorVBO)
m_flatShader->setDiffuse(p.diffuseColor); {
map->draw(m_flatShader, CGoGN::Algo::Render::GL2::TRIANGLES); m_colorPerVertexShader->setAttributePosition(p.positionVBO);
m_colorPerVertexShader->setAttributeColor(p.colorVBO);
map->draw(m_colorPerVertexShader, CGoGN::Algo::Render::GL2::TRIANGLES);
}
else
{
m_flatShader->setAttributePosition(p.positionVBO);
m_flatShader->setDiffuse(p.diffuseColor);
map->draw(m_flatShader, CGoGN::Algo::Render::GL2::TRIANGLES);
}
break; break;
case MapParameters::PHONG : case MapParameters::PHONG :
if(p.normalVBO != NULL) if(p.normalVBO != NULL)
...@@ -98,13 +108,15 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map) ...@@ -98,13 +108,15 @@ void Surface_Render_Plugin::drawMap(View* view, MapHandlerGen* map)
} }
glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_POLYGON_OFFSET_FILL);
} }
if(p.renderVertices)
if(p.renderVertices)
{ {
m_pointSprite->setSize(map->getBBdiagSize() / 200.0f * p.verticesScaleFactor); m_pointSprite->setSize(map->getBBdiagSize() / 200.0f * p.verticesScaleFactor);
m_pointSprite->setAttributePosition(p.positionVBO); m_pointSprite->setAttributePosition(p.positionVBO);
m_pointSprite->setColor(p.vertexColor); m_pointSprite->setColor(p.vertexColor);
map->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS); map->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS);
} }
if(p.renderEdges) if(p.renderEdges)
{ {
glLineWidth(1.0f); glLineWidth(1.0f);
...@@ -169,6 +181,7 @@ void Surface_Render_Plugin::vboAdded(Utils::VBO *vbo) ...@@ -169,6 +181,7 @@ void Surface_Render_Plugin::vboAdded(Utils::VBO *vbo)
{ {
m_dockTab->addPositionVBO(QString::fromStdString(vbo->name())); m_dockTab->addPositionVBO(QString::fromStdString(vbo->name()));
m_dockTab->addNormalVBO(QString::fromStdString(vbo->name())); m_dockTab->addNormalVBO(QString::fromStdString(vbo->name()));
m_dockTab->addColorVBO(QString::fromStdString(vbo->name()));
} }
} }
} }
...@@ -249,6 +262,23 @@ void Surface_Render_Plugin::changeNormalVBO(const QString& view, const QString& ...@@ -249,6 +262,23 @@ void Surface_Render_Plugin::changeNormalVBO(const QString& view, const QString&
} }
} }
void Surface_Render_Plugin::changeColorVBO(const QString& view, const QString& map, const QString& vbo)
{
DEBUG_SLOT();
View* v = m_schnapps->getView(view);
MapHandlerGen* m = m_schnapps->getMap(map);
if(v && m)
{
Utils::VBO* vbuf = m->getVBO(vbo);
h_viewParameterSet[v][m].colorVBO = vbuf;
if(v->isSelectedView())
{
if(v->isLinkedToMap(m)) v->updateGL();
if(m->isSelectedMap()) m_dockTab->updateMapParameters();
}
}
}
void Surface_Render_Plugin::changeRenderVertices(const QString& view, const QString& map, bool b) void Surface_Render_Plugin::changeRenderVertices(const QString& view, const QString& map, bool b)
{ {
DEBUG_SLOT(); DEBUG_SLOT();
......
...@@ -21,6 +21,7 @@ Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugi ...@@ -21,6 +21,7 @@ Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugi
connect(combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(positionVBOChanged(int))); connect(combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(positionVBOChanged(int)));
connect(combo_normalVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(normalVBOChanged(int))); connect(combo_normalVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(normalVBOChanged(int)));
connect(combo_colorVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(colorVBOChanged(int)));
connect(check_renderVertices, SIGNAL(toggled(bool)), this, SLOT(renderVerticesChanged(bool))); connect(check_renderVertices, SIGNAL(toggled(bool)), this, SLOT(renderVerticesChanged(bool)));
connect(slider_verticesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(verticesScaleFactorChanged(int))); connect(slider_verticesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(verticesScaleFactorChanged(int)));
connect(check_renderEdges, SIGNAL(toggled(bool)), this, SLOT(renderEdgesChanged(bool))); connect(check_renderEdges, SIGNAL(toggled(bool)), this, SLOT(renderEdgesChanged(bool)));
...@@ -33,95 +34,28 @@ Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugi ...@@ -33,95 +34,28 @@ Surface_Render_DockTab::Surface_Render_DockTab(SCHNApps* s, Surface_Render_Plugi
connect(scolorButton,SIGNAL(clicked()),this,SLOT(simpleColorClicked())); connect(scolorButton,SIGNAL(clicked()),this,SLOT(simpleColorClicked()));
connect(vcolorButton,SIGNAL(clicked()),this,SLOT(vertexColorClicked())); connect(vcolorButton,SIGNAL(clicked()),this,SLOT(vertexColorClicked()));
connect(m_colorDial,SIGNAL(colorSelected(const QColor&)),this,SLOT(colorSelected(const QColor&))); connect(m_colorDial,SIGNAL(colorSelected(const QColor&)),this,SLOT(colorSelected(const QColor&)));
} }
void Surface_Render_DockTab::diffuseColorClicked()
{
m_colorDial->show();
m_colorDial->setCurrentColor(m_diffuseColor);
m_currentColorDial = 1;
}
void Surface_Render_DockTab::simpleColorClicked()
{
m_colorDial->show();
m_colorDial->setCurrentColor(m_simpleColor);
m_currentColorDial = 2;
}
void Surface_Render_DockTab::vertexColorClicked()
{
m_colorDial->show();
m_colorDial->setCurrentColor(m_vertexColor);
m_currentColorDial = 3;
}
void Surface_Render_DockTab::colorSelected(const QColor& col)