-
Notifications
You must be signed in to change notification settings - Fork 234
Expand file tree
/
Copy pathpoint_cloud_parameterization_quantity.cpp
More file actions
97 lines (70 loc) · 2.65 KB
/
point_cloud_parameterization_quantity.cpp
File metadata and controls
97 lines (70 loc) · 2.65 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright 2017-2023, Nicholas Sharp and the Polyscope contributors. https://polyscope.run
#include "polyscope/point_cloud_parameterization_quantity.h"
#include "polyscope/file_helpers.h"
#include "polyscope/polyscope.h"
#include "polyscope/render/engine.h"
#include "imgui.h"
namespace polyscope {
PointCloudParameterizationQuantity::PointCloudParameterizationQuantity(std::string name, PointCloud& cloud_,
const std::vector<glm::vec2>& coords_,
ParamCoordsType type_, ParamVizStyle style_)
: PointCloudQuantity(name, cloud_, true), ParameterizationQuantity(*this, coords_, type_, style_) {}
void PointCloudParameterizationQuantity::draw() {
if (!isEnabled()) return;
if (program == nullptr) {
createProgram();
}
// Set uniforms
setParameterizationUniforms(*program);
parent.setStructureUniforms(*program);
parent.setPointCloudUniforms(*program);
render::engine->setMaterialUniforms(*program, parent.getMaterial());
program->draw();
}
void PointCloudParameterizationQuantity::createProgram() {
// Create the program to draw this quantity
// clang-format off
program = render::engine->requestShader(parent.getShaderNameForRenderMode(),
render::engine->addMaterialRules(parent.getMaterial(),
parent.addPointCloudRules(
addParameterizationRules(
{"SPHERE_PROPAGATE_VALUE2"}
)
)
)
);
// clang-format on
// Fill buffers
fillCoordBuffers(*program);
fillParameterizationBuffers(*program);
parent.setPointProgramGeometryAttributes(*program);
render::engine->setMaterial(*program, parent.getMaterial());
}
void PointCloudParameterizationQuantity::fillCoordBuffers(render::ShaderProgram& p) {
p.setAttribute("a_value2", coords.getRenderAttributeBuffer());
}
void PointCloudParameterizationQuantity::buildCustomUI() {
ImGui::SameLine();
// == Options popup
if (ImGui::Button("Options")) {
ImGui::OpenPopup("OptionsPopup");
}
if (ImGui::BeginPopup("OptionsPopup")) {
buildParameterizationOptionsUI();
ImGui::EndPopup();
}
buildParameterizationUI();
}
void PointCloudParameterizationQuantity::refresh() {
program.reset();
Quantity::refresh();
}
std::string PointCloudParameterizationQuantity::niceName() { return name + " (parameterization)"; }
void PointCloudParameterizationQuantity::buildPickUI(size_t ind) {
glm::vec2 coord = coords.getValue(ind);
ImGui::TextUnformatted(name.c_str());
ImGui::NextColumn();
ImGui::Text("<%g,%g>", coord.x, coord.y);
ImGui::NextColumn();
}
} // namespace polyscope