File: voronoi.cpp

package info (click to toggle)
embree 4.3.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 100,656 kB
  • sloc: cpp: 228,918; xml: 40,944; ansic: 2,685; python: 812; sh: 635; makefile: 228; csh: 42
file content (55 lines) | stat: -rw-r--r-- 1,498 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#include "../common/tutorial/tutorial.h"

namespace embree
{
  typedef void (*DrawGUI)(void);

  extern "C" {
    int g_num_points = 128;
    int g_num_knn = 4;
    bool g_show_voronoi = true;
    bool g_point_repulsion = false;
    float g_tmax = inf;
    Vec3fa g_query_point(0.7f, 0.0f, 0.3f);
  }

  struct Tutorial : public TutorialApplication 
  {
    Tutorial()
      : TutorialApplication("voronoi", FEATURE_RTCORE) {}

#if defined(USE_GLFW)
    
    void drawGUI() override
    {
      ImGui::SliderInt ("Number of points", &g_num_points, 4, 4096);
      ImGui::Checkbox  ("Show Voronoi", &g_show_voronoi);
      if (!g_show_voronoi)
      {
        ImGui::SliderInt ("Number of neighbours", &g_num_knn, 1, 128);
        ImGui::Checkbox  ("Simulate: Point repulsion", &g_point_repulsion);
        ImGui::InputFloat("Max dist for NN query", &g_tmax);
      }
    }

    void keypressed(int key) override
    {
      if (key == GLFW_KEY_RIGHT) g_query_point.x += 0.01f;
      if (key == GLFW_KEY_LEFT)  g_query_point.x -= 0.01f;
      if (key == GLFW_KEY_UP)    g_query_point.z -= 0.01f;
      if (key == GLFW_KEY_DOWN)  g_query_point.z += 0.01f;
      g_query_point = max(g_query_point, Vec3fa(0.f));
      g_query_point = min(g_query_point, Vec3fa(1.f));
      
      TutorialApplication::keypressed(key);
    }
#endif
  };
}

int main(int argc, char** argv) {
  return embree::Tutorial().main(argc,argv);
}