Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philip Trettner
polymesh
Commits
207dc3fb
Commit
207dc3fb
authored
Sep 22, 2018
by
Philip Trettner
Browse files
added a cube builder
parent
26d40e3f
Changes
2
Show whitespace changes
Inline
Side-by-side
src/polymesh/objects.hh
View file @
207dc3fb
#pragma once
#pragma once
// includes all supported objects
// includes all supported objects
#include "objects/cube.hh"
#include "objects/quad.hh"
#include "objects/quad.hh"
src/polymesh/objects/cube.hh
0 → 100644
View file @
207dc3fb
#pragma once
#include "../Mesh.hh"
namespace
polymesh
{
namespace
objects
{
/// Adds a cube to the given mesh
/// cf is called with (v, x, y, z), with vertex handle v and (x,y,z) from 0..1 (int literals)
/// returns the one of the new vertices (usually the first)
/// NOTE: the result is NOT triangulated!
template
<
class
CubeF
>
vertex_handle
add_cube
(
Mesh
&
m
,
CubeF
&&
cf
);
/// ======== IMPLEMENTATION ========
template
<
class
CubeF
>
vertex_handle
add_cube
(
Mesh
&
m
,
CubeF
&&
cf
)
{
auto
v000
=
m
.
vertices
().
add
();
auto
v001
=
m
.
vertices
().
add
();
auto
v010
=
m
.
vertices
().
add
();
auto
v011
=
m
.
vertices
().
add
();
auto
v100
=
m
.
vertices
().
add
();
auto
v101
=
m
.
vertices
().
add
();
auto
v110
=
m
.
vertices
().
add
();
auto
v111
=
m
.
vertices
().
add
();
m
.
faces
().
add
(
v000
,
v010
,
v110
,
v100
);
m
.
faces
().
add
(
v000
,
v100
,
v101
,
v001
);
m
.
faces
().
add
(
v000
,
v001
,
v011
,
v010
);
m
.
faces
().
add
(
v001
,
v101
,
v111
,
v011
);
m
.
faces
().
add
(
v010
,
v011
,
v111
,
v110
);
m
.
faces
().
add
(
v100
,
v110
,
v111
,
v101
);
cf
(
v000
,
0
,
0
,
0
);
cf
(
v001
,
0
,
0
,
1
);
cf
(
v010
,
0
,
1
,
0
);
cf
(
v011
,
0
,
1
,
1
);
cf
(
v100
,
1
,
0
,
0
);
cf
(
v101
,
1
,
0
,
1
);
cf
(
v110
,
1
,
1
,
0
);
cf
(
v111
,
1
,
1
,
1
);
return
v000
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment