@@ -19,7 +19,7 @@ SceneCloth::SceneCloth()
19
19
: clothVao(0 ), numElements(0 ),
20
20
nParticles(40 , 40 ), clothSize(4 .0f , 3 .0f ),
21
21
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 ))
23
23
{
24
24
}
25
25
@@ -174,6 +174,11 @@ void SceneCloth::render()
174
174
glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL );
175
175
176
176
computeProg.use ();
177
+
178
+ computeProg.setUniform (" HasWind" , static_cast <float >(wind));
179
+ computeProg.setUniform (" WindStrength" , windStrength);
180
+ computeProg.setUniform (" WindDir" , windDir);
181
+
177
182
for (int i = 0 ; i < 1000 ; i++) {
178
183
glDispatchCompute (nParticles.x / 10 , nParticles.y / 10 , 1 );
179
184
glMemoryBarrier (GL_SHADER_STORAGE_BARRIER_BIT);
@@ -230,6 +235,13 @@ void SceneCloth::uiUpdate()
230
235
ImGui::Begin (" GUI" );
231
236
ImGui::Text (" Application average %.3f ms/frame (%.1f FPS)" , 1000 .0f / ImGui::GetIO ().Framerate , ImGui::GetIO ().Framerate );
232
237
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
+
233
245
ImGui::End ();
234
246
}
235
247
0 commit comments