Skip to content
Snippets Groups Projects
Commit 2f262ead authored by Aaron Kreuzberg's avatar Aaron Kreuzberg
Browse files

added a picking test function in main.cc

parent 0d71a90b
No related branches found
No related tags found
No related merge requests found
glow-extras @ 6f9c9a2f
Subproject commit 76bc3b2141fba84b981545b58fc54dc20e5da02d
Subproject commit 6f9c9a2fe8be60af499d326633e5ae73a72a1534
......@@ -22,14 +22,13 @@ std::string const dataPath = glow::util::pathOf(__FILE__) + "/../../../data/";
void picking_concept(pm::vertex_attribute<tg::pos3> const& pos)
{
/*Picking concept that will be implemented first: User gives a list of ids (std::vector<uint_32t>) that will be stored in Picker. Number od ids has to match the
number of faces in the mesh. At first: Only implement for Triangle_Meshes!*/
/*Picking concept that will be implemented first: User gives a list of ids (std::vector<uint_32t>) that will be stored in Picker. Number od ids
has to match the number of faces in the mesh. At first: Only implement for Triangle_Meshes!*/
std::vector<uint32_t> col_ids = {1, 2};
gv::view(pos, gv::Picker::pick(col_ids, [&](pm::face_index f, tg::pos3 world_pos, tg::dir3 normal) { std::cout << "face: " << std::endl; }));
/*gv::view(pos, gv::pick()
.on_hover([&](pm::face_index f, tg::pos3 world_pos, tg::dir3 normal){
// std::cout << "face: " << f.idx << std::endl;
......@@ -73,6 +72,15 @@ void picking_concept(pm::vertex_attribute<tg::pos3> const& pos)
}
}
void simple_picking(pm::vertex_attribute<tg::pos3> const& pos, pm::face_attribute<tg::color3> const& col)
{
// simple picking functionality, user-defined ids for primitives (i.e. triangles) + user-defined callback-function
std::vector<uint32_t> col_ids = {1, 2};
gv::view(pos, col, gv::Picker::pick(col_ids, [&](uint32_t face_id, tg::pos3 world_pos, tg::dir3 normal) {
std::cout << "Something has been picked!" << std::endl;
}));
}
void simple_view(pm::vertex_attribute<tg::pos3> const& pos)
{
......@@ -1043,12 +1051,21 @@ int main()
pos[t2_vh1] = tg::pos3(20, 0, 0);
pos[t2_vh2] = tg::pos3(20, 20, 0);
m.faces().add(t1_vh0, t1_vh1, t1_vh2);
m.faces().add(t2_vh0, t2_vh1, t2_vh2);
auto col = pm::face_attribute<tg::color3>(m);
const auto f1 = m.faces().add(t1_vh0, t1_vh1, t1_vh2);
const auto f2 = m.faces().add(t2_vh0, t2_vh1, t2_vh2);
col[f1] = tg::color3::blue;
col[f2] = tg::color3::cyan;
// deduplicate(m, pos);
// m.compactify();
// simple picking demo
{
simple_picking(pos, col);
}
// basic demos
{
simple_view(pos);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment