Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
glow-samples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glow
glow-samples
Commits
3b8d9e01
Commit
3b8d9e01
authored
3 years ago
by
Aaron Kreuzberg
Browse files
Options
Downloads
Patches
Plain Diff
changes in extern/glow-extras
parent
3cb26d4f
Branches
Branches containing commit
No related tags found
1 merge request
!16
picking samples
Pipeline
#17958
passed
3 years ago
Stage: Build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
extern/glow-extras
+1
-1
1 addition, 1 deletion
extern/glow-extras
samples/basic/viewer/main.cc
+87
-33
87 additions, 33 deletions
samples/basic/viewer/main.cc
with
88 additions
and
34 deletions
glow-extras
@
438e6c07
Subproject commit
7bd27e7e229d16008e3c926b614c5a2165a83e7e
Subproject commit
438e6c078c1952c3bcb1efd3d801da23d96dea55
This diff is collapsed.
Click to expand it.
samples/basic/viewer/main.cc
+
87
−
33
View file @
3b8d9e01
...
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment