Skip to content
Snippets Groups Projects
Commit 2925f2a5 authored by Philip Trettner's avatar Philip Trettner
Browse files

updated subs, added interactive torus

parent 980e1e66
No related branches found
No related tags found
No related merge requests found
glow @ 7bdd20e1
Subproject commit 35192413e0a8a52ea88046197d1dad2bfaa9f15f
Subproject commit 7bdd20e13f1dc1d824a339d3fb4eba1e2dc8dd4b
glow-extras @ 65a79891
Subproject commit bd0f9d69c2d39513f4dc990d0cfaa9512259a68b
Subproject commit 65a7989156d719fb592c3291d08b8b6f2c657763
polymesh @ 384f6594
Subproject commit a1e1259beaca6a96c28e17786bd05f9e167c0e34
Subproject commit 384f659443ccd40c3bc355d79fd7333d6cf399db
typed-geometry @ d00bebc1
Subproject commit 0c65f3ae381cf53588587ae1e570f13f961d1a9d
Subproject commit d00bebc1b4e0428a22c89c9c73403e29ed687ae7
......@@ -9,6 +9,7 @@
#include <polymesh/algorithms/normalize.hh>
#include <polymesh/formats.hh>
#include <polymesh/objects/quad.hh>
#include <glow-extras/glfw/GlfwContext.hh>
#include <glow-extras/vector/graphics2D.hh>
......@@ -45,10 +46,6 @@ int main()
auto 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); });
// DBG
{
}
// Simplest view
glow::viewer::view(pos);
......@@ -106,6 +103,9 @@ int main()
// Points rendered as 3D spheres
view(points(pos).spheres().point_size_world(0.03f));
// Simple line soup
view(lines(pos));
// Configure view
{
auto v = glow::viewer::view();
......@@ -193,16 +193,10 @@ int main()
glow::viewer::interactive([r2](auto) {
static float configurable = 0.f;
ImGui::Begin("Interactive viewer");
auto const input = ImGui::SliderFloat("Height", &configurable, -3.f, 3.f);
ImGui::End();
{
auto v = glow::viewer::view(r2, tg::translation(tg::vec3(0.f, configurable, 0.f)));
// Conditional clear
if (input)
glow::viewer::clear_accumulation();
}
// conditionally clear view if input has changed
glow::viewer::view(r2, tg::translation(tg::vec3(0.f, configurable, 0.f)), glow::viewer::clear_accumulation(input));
});
}
}
......@@ -258,6 +252,47 @@ int main()
}
}
// Interactive Torus
{
pm::Mesh m;
auto pos = m.vertices().make_attribute<tg::pos3>();
auto uv = m.vertices().make_attribute<glm::vec2>();
pm::objects::add_quad(m,
[&](pm::vertex_handle v, float x, float y) {
auto [cx, sx] = tg::sin_cos(tg::pi<float> * 2 * x);
auto [cy, sy] = tg::sin_cos(tg::pi<float> * 2 * y);
auto orad = 8.f;
auto irad = 3.f;
tg::vec3 t;
t.x = cx;
t.z = sx;
tg::pos3 p;
p.x = orad * cx;
p.y = irad * cy;
p.z = orad * sx;
p += t * irad * sy;
pos[v] = p;
uv[v] = {1 - x, y};
},
32, 32);
auto a = 0.f;
auto animate = false;
glow::viewer::interactive([&](auto dt) {
ImGui::Begin("Torus");
auto changed = ImGui::SliderFloat("angle", &a, 0.f, 360.f);
ImGui::Checkbox("Animate", &animate);
ImGui::End();
if (animate)
a += 5 * dt;
changed |= animate;
view(pos, glow::viewer::textured(uv, tex).transform(tg::rotation_around(tg::pos2::zero, tg::degree(a))), glow::viewer::clear_accumulation(changed));
});
}
// Alternatively, output a single frame headlessly
// auto view = glow::viewer::view(pos);
// view->render()->bind().writeToFile("viewer_output.png");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment