Skip to content

Commit 165a7ab

Browse files
[ui] handle wind
1 parent cae7687 commit 165a7ab

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

project01/scenecloth.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ SceneCloth::SceneCloth()
1919
: clothVao(0), numElements(0),
2020
nParticles(40, 40), clothSize(4.0f, 3.0f),
2121
time(0.0f), deltaT(0.0f), speed(200.0f), readBuf(0),
22-
wireframe(false)
22+
wireframe(false), wind(false), windStrength(0.5), windDir(glm::vec3(0.2, 0, 0.6))
2323
{
2424
}
2525

@@ -174,6 +174,11 @@ void SceneCloth::render()
174174
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
175175

176176
computeProg.use();
177+
178+
computeProg.setUniform("HasWind", static_cast<float>(wind));
179+
computeProg.setUniform("WindStrength", windStrength);
180+
computeProg.setUniform("WindDir", windDir);
181+
177182
for (int i = 0; i < 1000; i++) {
178183
glDispatchCompute(nParticles.x / 10, nParticles.y / 10, 1);
179184
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
@@ -230,6 +235,13 @@ void SceneCloth::uiUpdate()
230235
ImGui::Begin("GUI");
231236
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
232237
ImGui::Checkbox("Wireframe", &wireframe);
238+
if (ImGui::CollapsingHeader("Wind", ImGuiTreeNodeFlags_DefaultOpen))
239+
{
240+
ImGui::Checkbox("Enable", &wind);
241+
ImGui::SliderFloat("Strength", &windStrength, 0.0f, 10.0f);
242+
ImGui::SliderFloat3("Direction", &windDir[0], 0.0f, 1.0f);
243+
}
244+
233245
ImGui::End();
234246
}
235247

project01/scenecloth.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,9 @@ class SceneCloth : public Scene
3636
GLuint readBuf;
3737
GLuint posBufs[2], velBufs[2];
3838
GLuint normBuf, elBuf, tcBuf;
39+
3940
bool wireframe;
41+
bool wind;
42+
float windStrength;
43+
glm::vec3 windDir;
4044
};

0 commit comments

Comments
 (0)