Skip to content

Commit

Permalink
Added another GIF. Made initial droplet count configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
shanecelis committed Dec 29, 2018
1 parent 23eb67b commit 12e5ad8
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Usage

Create a new project using Unity 2018.2.17f1. Clone this repo into the "Assets" directory. Open the "cube-of-water" scene and hit play.

![Click on water to cause a wave.](clickable.gif)

You can click on the water to cause a wave. You can drag to move the camera around. Hit "space" key to pause water simulation. Hit "n" key to update the simulation one time step.

Implementation Notes
Expand Down
3 changes: 2 additions & 1 deletion Scripts/WaterSimulation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class WaterSimulation : MonoBehaviour, IPointerClickHandler, IDragHandler
public CustomRenderTexture texture;
public float dropRadius = 1f; // uv units [0, 1]
public bool pause = false;
public int initialDropCount = 20;

private CustomRenderTextureUpdateZone[] zones = null;
private Collider collider;
Expand Down Expand Up @@ -48,7 +49,7 @@ void Start() {
waveZone.updateZoneSize = new Vector2(dropRadius, dropRadius);

var waves = new List<CustomRenderTextureUpdateZone>();
for (int i = 0; i < 20; i++) {
for (int i = 0; i < initialDropCount; i++) {
waveZone.updateZoneCenter = new Vector2(Random.Range(0f, 1f),
Random.Range(0f, 1f));
// CustomRenderTextureUpdateZone is a struct so this is a copy operation.
Expand Down
Binary file added clickable.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions clickable.gif.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 12e5ad8

Please sign in to comment.