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
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
Zain Selman
glow-samples
Commits
58c42b9d
Commit
58c42b9d
authored
5 years ago
by
Philip Trettner
Browse files
Options
Downloads
Patches
Plain Diff
made types explicit
parent
2925f2a5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
samples/wip/viewer/main.cc
+11
-11
11 additions, 11 deletions
samples/wip/viewer/main.cc
with
11 additions
and
11 deletions
samples/wip/viewer/main.cc
+
11
−
11
View file @
58c42b9d
...
@@ -30,21 +30,21 @@ int main()
...
@@ -30,21 +30,21 @@ int main()
// Load a polymesh mesh
// Load a polymesh mesh
pm
::
Mesh
m
;
pm
::
Mesh
m
;
auto
pos
=
m
.
vertices
().
make_attribute
<
glm
::
vec
3
>
();
auto
pos
=
m
.
vertices
().
make_attribute
<
tg
::
pos
3
>
();
load
(
dataPath
+
"suzanne.obj"
,
m
,
pos
);
load
(
dataPath
+
"suzanne.obj"
,
m
,
pos
);
normalize
(
pos
);
// make it -1..1
normalize
(
pos
);
// make it -1..1
// prepare some data
// prepare some data
auto
uv
=
pos
.
map
([](
glm
::
vec
3
v
)
{
return
glm
::
vec2
(
v
.
x
,
v
.
y
);
});
pm
::
vertex_attribute
<
glm
::
vec2
>
uv
=
pos
.
map
([](
tg
::
pos
3
v
)
{
return
glm
::
vec2
(
v
.
x
,
v
.
y
);
});
auto
vdata
=
pos
.
map
([](
glm
::
vec
3
v
)
{
return
v
.
y
;
});
pm
::
vertex_attribute
<
float
>
vdata
=
pos
.
map
([](
tg
::
pos
3
v
)
{
return
v
.
y
;
});
auto
vnormals
=
vertex_normals_by_area
(
m
,
pos
);
pm
::
vertex_attribute
<
tg
::
vec3
>
vnormals
=
vertex_normals_by_area
(
m
,
pos
);
auto
fdata
=
m
.
faces
().
map
([
&
](
pm
::
face_handle
f
)
{
return
f
.
vertices
().
avg
(
pos
).
z
;
});
pm
::
face_attribute
<
float
>
fdata
=
m
.
faces
().
map
([
&
](
pm
::
face_handle
f
)
{
return
f
.
vertices
().
avg
(
pos
).
z
;
});
auto
tex
=
glow
::
Texture2D
::
createFromFile
(
dataPath
+
"textures/tiles.color.png"
,
glow
::
ColorSpace
::
sRGB
);
glow
::
SharedTexture2D
tex
=
glow
::
Texture2D
::
createFromFile
(
dataPath
+
"textures/tiles.color.png"
,
glow
::
ColorSpace
::
sRGB
);
auto
atex
=
glow
::
AsyncTextureLoader
::
load2D
(
dataPath
+
"textures/tiles.color.png"
,
glow
::
ColorSpace
::
sRGB
);
glow
::
AsyncTexture2D
atex
=
glow
::
AsyncTextureLoader
::
load2D
(
dataPath
+
"textures/tiles.color.png"
,
glow
::
ColorSpace
::
sRGB
);
auto
fcolors
=
m
.
faces
().
map
([
&
](
pm
::
face_handle
)
{
return
glow
::
colors
::
color
(
dis
(
rng
),
dis
(
rng
),
dis
(
rng
));
});
pm
::
face_attribute
<
glow
::
colors
::
color
>
fcolors
=
m
.
faces
().
map
([
&
](
pm
::
face_handle
)
{
return
glow
::
colors
::
color
(
dis
(
rng
),
dis
(
rng
),
dis
(
rng
));
});
auto
vcolors
=
attribute
(
m
.
vertices
(),
glow
::
colors
::
color
(
1
,
0
,
0
));
pm
::
vertex_attribute
<
glow
::
colors
::
color
>
vcolors
=
attribute
(
m
.
vertices
(),
glow
::
colors
::
color
(
1
,
0
,
0
));
auto
edge_lengths
=
m
.
edges
().
map
([
&
](
pm
::
edge_handle
e
)
{
return
edge_length
(
e
,
pos
);
});
pm
::
edge_attribute
<
float
>
edge_lengths
=
m
.
edges
().
map
([
&
](
pm
::
edge_handle
e
)
{
return
edge_length
(
e
,
pos
);
});
auto
ptsize
=
m
.
vertices
().
map
([
&
](
pm
::
vertex_handle
v
)
{
return
v
.
edges
().
avg
(
edge_lengths
);
});
pm
::
vertex_attribute
<
float
>
ptsize
=
m
.
vertices
().
map
([
&
](
pm
::
vertex_handle
v
)
{
return
v
.
edges
().
avg
(
edge_lengths
);
});
// Simplest view
// Simplest view
glow
::
viewer
::
view
(
pos
);
glow
::
viewer
::
view
(
pos
);
...
...
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