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

changes in extern/glow-extras

parent 3cb26d4f
Branches
No related tags found
1 merge request!16picking samples
Pipeline #17958 passed
glow-extras @ 438e6c07
Subproject commit 7bd27e7e229d16008e3c926b614c5a2165a83e7e
Subproject commit 438e6c078c1952c3bcb1efd3d801da23d96dea55
......@@ -15,8 +15,8 @@
#include <glow-extras/viewer/canvas.hh>
#include <glow-extras/viewer/view.hh>
#include <typed-geometry/tg.hh>
#include <polymesh/objects/cube.hh>
#include <typed-geometry/tg.hh>
// path to sample files
std::string const dataPath = glow::util::pathOf(__FILE__) + "/../../../data/";
......@@ -96,12 +96,90 @@ void simple_picking(pm::vertex_attribute<tg::pos3> const& pos, pm::face_attribut
}));
}*/
// simple picking functionality, primitive IDs defined internally
{
// simple picking functionality, primitive IDs defined internally | OLD VERSION
/*{
gv::view(pos, col, gv::pick([&](uint32_t face_id, tg::pos3 world_pos, tg::vec3 normal) {
std::cout << "Something has been picked! " << "ID: " << face_id << std::endl;
std::cout << "Something has been picked! "
<< "ID: " << face_id << std::endl;
return;
}));
}*/
// NEW SPEC
{
// In this case a Picker is defined for the Renderable (Picking Texture filled) but no callback will be executed.
gv::view(pos, col, gv::pick());
}
{
// Only on_left_click callback defined
gv::view(pos, col, gv::pick().on_left_click([&](uint32_t face_id, tg::pos3 world_pos, tg::vec3 normal) {
std::cout << "Something has been picked! ON_LEFT_CLICK"
<< "ID: " << face_id << std::endl;
return;
}));
}
{
// Only on_right_click callback defined
gv::view(pos, col, gv::pick().on_right_click([&](uint32_t face_id, tg::pos3 world_pos, tg::vec3 normal) {
std::cout << "Something has been picked! ON_RIGHT_CLICK"
<< "ID: " << face_id << std::endl;
return;
}));
}
{
// Only on_hover callback defined
gv::view(pos, col, gv::pick().on_hover([&](uint32_t face_id, tg::pos3 world_pos, tg::vec3 normal) {
std::cout << "Something has been picked! ON_HOVER"
<< "ID: " << face_id << std::endl;
return;
}));
}
{
// On_hover, on_right_click, and on_left_click callbacks defined simultaneously
gv::view(pos, col,
gv::pick()
.on_left_click([&](uint32_t face_id, tg::pos3 world_pos, tg::vec3 normal) {
std::cout << "Something has been picked! ON_LEFT_CLICK"
<< "ID: " << face_id << std::endl;
return;
})
.on_right_click([&](uint32_t face_id, tg::pos3 world_pos, tg::vec3 normal) {
std::cout << "Something has been picked! ON_RIGHT_CLICK"
<< "ID: " << face_id << std::endl;
return;
})
.on_hover([&](uint32_t face_id, tg::pos3 world_pos, tg::vec3 normal) {
std::cout << "Something has been picked! ON_HOVER"
<< "ID: " << face_id << std::endl;
return;
})
);
}
{
//User defined IDs check
auto id_f = pm::face_attribute<int>(pos.mesh());
int32_t id = 0;
std::vector<pick_id> ids;
for (auto f : pos.mesh().all_faces())
{
pick_id pid;
pid.id = id;
ids.push_back(pid);
id++;
}
gv::view(pos, col, ids, gv::pick().on_left_click([&](uint32_t face_id, tg::pos3 world_pos, tg::vec3 normal) {
std::cout << "Something has been picked! ON_LEFT_CLICK"
<< "ID: " << face_id << std::endl;
return;
}));
}
}
......@@ -1055,42 +1133,18 @@ int main()
// load a sample polymesh mesh
pm::Mesh m;
auto pos = m.vertices().make_attribute<tg::pos3>();
//load(dataPath + "suzanne.obj", m, pos);
// load(dataPath + "suzanne.obj", m, pos);
pm::objects::add_cube(m, pos);
//normalize(pos); // make it -1..1*/
// normalize(pos); // make it -1..1*/
auto col = pm::face_attribute<tg::color3>(m);
int it = 0;
auto r = tg::rng();
for (auto x : m.faces())
for (auto x : m.faces())
{
tg::color3 color;
tg::color3 color;
color = tg::uniform<tg::color3>(r);
/*switch (it % 6)
{
case 0:
color = tg::color3::blue;
break;
case 1:
color = tg::color3::black;
break;
case 2:
color = tg::color3::cyan;
break;
case 3:
color = tg::color3::magenta;
break;
case 4:
color = tg::color3::red;
break;
case 5:
color = tg::color3::yellow;
break;
default:
color = tg::color3::white;
}*/
it++;
col[x] = color;
col[x] = color;
}
pm::Mesh m_2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment