Skip to content
Snippets Groups Projects
Commit 959607d8 authored by George Psomathianos's avatar George Psomathianos
Browse files

Slideshow db

parent 6be8f2d0
No related branches found
No related tags found
No related merge requests found
...@@ -4,27 +4,36 @@ ...@@ -4,27 +4,36 @@
#include "pmp/MatVec.h" #include "pmp/MatVec.h"
namespace mmr { namespace mmr {
struct Entry struct Entry
{ {
public: public:
pmp::SurfaceMeshGL mesh; pmp::SurfaceMeshGL mesh;
std::string label; std::string label;
}; };
class Database class Database
{ {
public: public:
Database() = default; Database() = default;
Database(const std::string path); Database(const std::string path);
void draw(const pmp::mat4& projection_matrix, void draw(const pmp::mat4& projection_matrix,
const pmp::mat4& modelview_matrix, const pmp::mat4& modelview_matrix,
const std::string& draw_mode); const std::string& draw_mode);
void retrieve(const std::string& path); void drawModel(int index, const pmp::mat4& projection_matrix,
void clear(); const pmp::mat4& modelview_matrix,
const std::string& draw_mode);
void retrieve(const std::string& path);
void clear();
private: int getDBSize() { return entries.size(); }
static int avgVerts;
static int avgFaces; private:
std::vector<Entry> entries;
}; std::vector<Entry> entries;
public:
int avgVerts = 0;
int avgFaces = 0;
};
} // namespace mmr } // namespace mmr
...@@ -18,5 +18,6 @@ protected: ...@@ -18,5 +18,6 @@ protected:
private: private:
bool m_retrieved_db = false; bool m_retrieved_db = false;
int m_dbIndex = 0;
}; };
} // namespace mmr } // namespace mmr
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
namespace mmr { namespace mmr {
int Database::avgFaces = 0;
int Database::avgVerts = 0;
Database::Database(const std::string path) Database::Database(const std::string path)
{ {
retrieve(path); retrieve(path);
...@@ -21,6 +20,15 @@ void Database::draw(const pmp::mat4& projection_matrix, ...@@ -21,6 +20,15 @@ void Database::draw(const pmp::mat4& projection_matrix,
} }
} }
void Database::drawModel(int index, const pmp::mat4& projection_matrix,
const pmp::mat4& modelview_matrix,
const std::string& draw_mode)
{
entries[index].mesh.draw(projection_matrix, modelview_matrix, draw_mode);
}
void Database::retrieve(const std::string& path) void Database::retrieve(const std::string& path)
{ {
using std::filesystem::recursive_directory_iterator; using std::filesystem::recursive_directory_iterator;
......
...@@ -19,7 +19,7 @@ void MmrViewer::draw(const std::string& drawMode) ...@@ -19,7 +19,7 @@ void MmrViewer::draw(const std::string& drawMode)
MeshViewer::draw(drawMode); MeshViewer::draw(drawMode);
if (m_retrieved_db) if (m_retrieved_db)
m_database.draw(projection_matrix_, modelview_matrix_, drawMode); m_database.drawModel(m_dbIndex, projection_matrix_, modelview_matrix_, drawMode);
} }
void MmrViewer::keyboard(int key, int scancode, int action, int mods) void MmrViewer::keyboard(int key, int scancode, int action, int mods)
...@@ -68,6 +68,18 @@ void MmrViewer::process_imgui() ...@@ -68,6 +68,18 @@ void MmrViewer::process_imgui()
m_database.retrieve(asset::getModel("LabeledDB_new")); m_database.retrieve(asset::getModel("LabeledDB_new"));
m_retrieved_db = true; m_retrieved_db = true;
} }
if (ImGui::Button("Next") && m_retrieved_db && (m_dbIndex < m_database.getDBSize() -1))
{
m_dbIndex++;
}
if (ImGui::Button("Previous") && m_retrieved_db &&
(m_dbIndex > 0))
{
m_dbIndex--;
}
if (ImGui::Button("Flip")) if (ImGui::Button("Flip"))
{ {
Norma::lize(mesh_); Norma::lize(mesh_);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment