GPU Splatting  1.0
A deffered render that draws the surface of point cloud data.
Vis2Application.h
1 #pragma once
2 
3 #include "GLFWApplication.h"
4 #include "GLProgram.h"
5 #include "Quad.h"
6 
7 #include <glm/glm.hpp>
8 
9 // Ant forward declaration
10 struct CTwBar;
11 typedef CTwBar TwBar;
12 
14 struct Vertex
15 {
16  glm::vec3 pos;
17  glm::vec3 normal;
18  glm::vec3 color;
19  glm::vec4 splatAxis;
20 };
21 
22 enum Models
23 {
24  BUNNY, MODEL000, MODEL002, NUM_MODELS
25 };
26 
28 
33 {
34 public:
36 
42  Vis2Application(int width, int height, int ctx_major, int ctx_minor);
43 
44  void init() override;
45  void update() override;
46  void render() override;
47  void resize(int width, int height) override;
48 
49  void initUI() override;
50  void renderUI() override;
51 
52  void loadModel(const std::string model_path);
53  void setModel(Models model);
54  Models getModel();
55 
56 private:
57  TwBar* bar;
58 
59  GL::GLProgram splatDepthProg;
60  GL::GLProgram splatAttribProg;
61  GL::GLProgram splatShadingProg;
62 
63  size_t numPoints;
64 
65  GLuint vbPointBuffer;
66  GL::Quad quad;
67 
68  struct {
69  float splatSizeFactor = 0.0005f;
70  float filterRadius = 2.0f;
71  bool useLenght = true;
72  bool useVertexColors = false;
73  bool autoRotate = true;
74  float lightDirection[3];
75  float objectRotation[4];
76  float camDist = 1.0f;
77  Models currentModel = Models::BUNNY;
78  bool enableVertexCulling = true;
79  float depthOffsetF;
80  float depthOffsetV;
81  } settings;
82 
83  struct {
84  GLuint depth;
85  GLuint accumWeight; // accumulated weights for normalization
86  GLuint accumNormal;
87  GLuint accumColor;
88  } tex;
89 
90  GLuint depthFBO;
91  GLuint fb;
92  GLuint va;
93 
94  int currentModel = 0;
95  std::vector<std::string> model_paths;
96 
97  glm::mat4 projection;
98  glm::mat4 view;
99 };
The main class of the renderer - the action is here!
Definition: Vis2Application.h:32
Encapsules an OpenGL shader program.
Definition: GLProgram.h:14
Vis2Application(int width, int height, int ctx_major, int ctx_minor)
Creates a new instance with the given parameters.
Definition: Vis2Application.cpp:12
glm::vec3 color
The color of the vertex.
Definition: Vis2Application.h:18
void render() override
Renders the scene.
Definition: Vis2Application.cpp:215
A generic base class for GLFW-applications.
Definition: GLFWApplication.h:11
void initUI() override
Initializes the AntTweakBar.
Definition: Vis2ApplicationGui.cpp:38
void setModel(Models model)
Sets the active model.
Definition: Vis2ApplicationGui.cpp:27
void update() override
Does nothing so far.
Definition: Vis2Application.cpp:211
A quadratic plane, centered at (0,0,0) with size 2, faceing z.
Definition: Quad.h:10
void resize(int width, int height) override
Reallocates the textures to fit the new screen size.
Definition: Vis2Application.cpp:333
glm::vec3 pos
The position of the vertex.
Definition: Vis2Application.h:16
Models getModel()
Returns the active model.
Definition: Vis2ApplicationGui.cpp:33
glm::vec4 splatAxis
The vector of the main-axis(components 1-3) and the major2minor-factor(component 4).
Definition: Vis2Application.h:19
void loadModel(const std::string model_path)
Loads the specified model.
Definition: Vis2Application.cpp:24
void renderUI() override
Renders the AntTweakBar.
Definition: Vis2ApplicationGui.cpp:89
Contains the attributes of a vertex.
Definition: Vis2Application.h:14
glm::vec3 normal
The normal vector of the vertex.
Definition: Vis2Application.h:17
void init() override
Initializes all the OpenGL buffers and loads the bunny-model.
Definition: Vis2Application.cpp:94