Commit a523c182 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge branch 'develop' into 'develop'

Develop

See merge request !45
parents cc1bae49 d13f94c0
......@@ -40,7 +40,7 @@ struct MapParameters
VertexAttribute<Geom::Vec2i, PFP2::MAP> param;
Utils::VBO* paramVBO;
DartAttribute<PFP2::REAL, PFP2::MAP> halfedgeError;
// DartAttribute<PFP2::REAL, PFP2::MAP> halfedgeError;
Algo::Surface::Decimation::ApproximatorGen<PFP2>* positionApproximator;
Algo::Surface::Decimation::ApproximatorGen<PFP2>* normalApproximator;
......@@ -115,12 +115,14 @@ public slots:
protected:
MapHandlerGen* currentlyDecimatedMap() { return m_currentlyDecimatedMap; }
bool currentDecimationHalf() { return m_currentDecimationHalf; }
static void checkNbVerticesAndExport(Surface_Radiance_Plugin* p, const unsigned int* nbVertices);
Surface_Radiance_DockTab* m_dockTab;
QHash<MapHandlerGen*, MapParameters> h_mapParameterSet;
MapHandlerGen* m_currentlyDecimatedMap;
bool m_currentDecimationHalf;
std::vector<unsigned int> exportNbVert;
unsigned int nextExportIndex;
......
......@@ -60,6 +60,7 @@ void Surface_Radiance_Plugin::drawMap(View* view, MapHandlerGen* map)
{
p.radiancePerVertexShader->setAttributePosition(p.positionVBO);
p.radiancePerVertexShader->setAttributeNormal(p.normalVBO);
p.radiancePerVertexShader->setAttributeRadiance(p.paramVBO, p.radianceTexture, GL_TEXTURE1);
qglviewer::Vec c = view->getCurrentCamera()->position();
PFP2::VEC3 camera(c.x, c.y, c.z);
......@@ -263,14 +264,14 @@ MapHandlerGen* Surface_Radiance_Plugin::importFromFile(const QString& fileName)
mapParams.radianceTexture->update();
// map->removeAttribute(mapParams.radiance);
mapParams.paramVBO = new Utils::VBO();
mapParams.paramVBO->updateData(mapParams.param);
mapParams.radiancePerVertexShader = new Utils::ShaderRadiancePerVertex(Utils::SphericalHarmonics<PFP2::REAL, PFP2::VEC3>::get_resolution());
registerShader(mapParams.radiancePerVertexShader);
mapParams.radiancePerVertexShader->setAttributeRadiance(mapParams.paramVBO, mapParams.radianceTexture, GL_TEXTURE1);
// compute map bounding box
mh->updateBB(position);
}
......@@ -400,6 +401,7 @@ void Surface_Radiance_Plugin::decimate(const QString& mapName, const QString& po
}
m_currentlyDecimatedMap = mh;
m_currentDecimationHalf = halfCollapse;
Algo::Surface::Decimation::decimate<PFP2>(*map, mapParams.selector, approximators, decimationGoal * nbVertices, true, NULL, (void (*)(void*, const void*))(Surface_Radiance_Plugin::checkNbVerticesAndExport), (void*)(this));
m_currentlyDecimatedMap = NULL;
......@@ -415,7 +417,7 @@ void Surface_Radiance_Plugin::checkNbVerticesAndExport(Surface_Radiance_Plugin*
if (*nbVertices == p->exportNbVert[p->nextExportIndex])
{
std::stringstream exportName;
exportName << p->currentlyDecimatedMap()->getName().toStdString() << "_" << *nbVertices << ".ply";
exportName << p->currentlyDecimatedMap()->getName().toStdString() << "_" << (p->currentDecimationHalf() ? "half_" : "full_") << (*nbVertices) << ".ply";
std::cout << "export : " << exportName.str() << std::endl;
p->exportPLY(mhg->getName(), "position", "normal", QString::fromStdString(exportName.str()));
p->nextExportIndex++;
......
......@@ -160,6 +160,8 @@ protected:
Utils::Texture<2, Geom::Vec3uc>* m_textureWallpaper;
Utils::ShaderWallPaper* m_shaderWallpaper;
bool b_saveSnapshots;
};
} // namespace SCHNApps
......
......@@ -21,7 +21,7 @@ namespace SCHNApps
{
unsigned int View::viewCount = 0;
View::View(const QString& name, SCHNApps* s, QGLFormat& format) :
View::View(const QString& name, SCHNApps* s, QGLFormat& format) :
QGLViewer(format, NULL, NULL),
b_updatingUI(false),
m_name(name),
......@@ -41,10 +41,15 @@ View::View(const QString& name, SCHNApps* s, QGLFormat& format) :
m_dialogCameras(NULL),
m_frameDrawer(NULL),
m_textureWallpaper(NULL),
m_shaderWallpaper(NULL)
m_shaderWallpaper(NULL),
b_saveSnapshots(false)
{
++viewCount;
setSnapshotFormat("JPEG");
setSnapshotFileName(m_name);
setSnapshotQuality(95);
m_currentCamera = m_schnapps->addCamera();
m_currentCamera->linkView(this);
......@@ -80,7 +85,7 @@ View::View(const QString& name, SCHNApps* s, QGLFormat& format) :
m_dialogCameras->check(m_currentCamera->getName(),Qt::Checked);
}
View::View(const QString& name, SCHNApps* s, QGLFormat& format, const QGLWidget* shareWidget) :
View::View(const QString& name, SCHNApps* s, QGLFormat& format, const QGLWidget* shareWidget) :
QGLViewer(format, NULL, shareWidget),
b_updatingUI(false),
m_name(name),
......@@ -104,6 +109,10 @@ View::View(const QString& name, SCHNApps* s, QGLFormat& format, const QGLWidget
{
++viewCount;
setSnapshotFormat("JPEG");
setSnapshotFileName(m_name);
setSnapshotQuality(95);
m_currentCamera = m_schnapps->addCamera();
m_currentCamera->linkView(this);
......@@ -545,9 +554,20 @@ void View::drawFrame()
void View::keyPressEvent(QKeyEvent* event)
{
foreach(PluginInteraction* plugin, l_plugins)
plugin->keyPress(this, event);
QGLViewer::keyPressEvent(event);
if (event->key() == Qt::Key_S)
{
b_saveSnapshots = !b_saveSnapshots;
if (b_saveSnapshots)
connect(this, SIGNAL(drawFinished(bool)), this, SLOT(saveSnapshot(bool)));
else
disconnect(this, SIGNAL(drawFinished(bool)), this, SLOT(saveSnapshot(bool)));
}
else
{
foreach(PluginInteraction* plugin, l_plugins)
plugin->keyPress(this, event);
QGLViewer::keyPressEvent(event);
}
}
void View::keyReleaseEvent(QKeyEvent *event)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment