private void MovePoint(FluidPoint pt, Vector3 toPos) { foreach (ShapeVertex sv in pt.vertices) { shapes[sv.shapeIndex].SetPosition(sv.vertexIndex, toPos); } }
void Splat(FluidPoint point) { splatProgram.SetTexture("_Target", velocity_dfbo.GetReadFBO()); splatProgram.SetFloat("_aspectRatio", screen_w / screen_h); splatProgram.SetColor("_point", new Color(point.x / screen_w, point.y / screen_h, 0f)); splatProgram.SetColor("_color", new Color(point.dx, point.dy, 1.0f)); splatProgram.SetFloat("_radius", splat_radius / 100.0f); splatProgram.Blit(velocity_dfbo.GetWriteFBO(), velocity_dfbo.GetWriteFBO(), blendOption); velocity_dfbo.Swap(); splatProgram.SetTexture("_Target", density_dfbo.GetReadFBO()); splatProgram.SetColor("_color", point.color); splatProgram.Blit(density_dfbo.GetWriteFBO(), density_dfbo.GetWriteFBO(), blendOption); density_dfbo.Swap(); }
public void Hit() { if (FluidCtrl.paused_check) { return; } FluidPoint p = new FluidPoint(); p.x = screen_w * Random.Range(0.0f, 1.0f); p.y = screen_h * Random.Range(0.0f, 1.0f); p.dx = 1000 * (Random.Range(0.0f, 1.0f) - 0.5f); p.dy = 1000 * (Random.Range(0.0f, 1.0f) - 0.5f); p.color = GenerateColor(); p.color.r *= 10.0f; p.color.g *= 10.0f; p.color.b *= 10.0f; Splat(p); }
private void InitPoints() { List <FluidPoint> pointList = new List <FluidPoint>(); foreach (LowPolyShape shape in shapes) { foreach (Vector3 pos in shape.GetPositions()) { if (pointList.FindIndex(pt => pt.startPosition == pos) == -1) { FluidPoint pt = InitPoint(pos); if (pt != null) { pointList.Add(pt); } } } } points = pointList.ToArray(); }
public void HitMany() { if (FluidCtrl.paused_check) { return; } int rcount = Random.Range(20, 40); for (int i = 0; i < rcount; i++) { FluidPoint p = new FluidPoint(); p.x = screen_w * Random.Range(0.0f, 1.0f); p.y = screen_h * Random.Range(0.0f, 1.0f); p.dx = 1000 * (Random.Range(0.0f, 1.0f) - 0.5f); p.dy = 1000 * (Random.Range(0.0f, 1.0f) - 0.5f); p.color = GenerateColor(); p.color.r *= 10.0f; p.color.g *= 10.0f; p.color.b *= 10.0f; Splat(p); } }
void CheckInput() { if (Input.GetKeyDown(KeyCode.Mouse0)) { point.down = true; lastColorChangeTime = Time.realtimeSinceStartup; Debug.Log("lastColorChangeTime:" + lastColorChangeTime); point.color = GenerateColor(); } if (Input.GetKeyUp(KeyCode.Mouse0)) { point.down = false; } if (Input.GetKeyUp(KeyCode.P)) { paused_check = !paused_check; } if (Input.GetKeyUp(KeyCode.C)) { colorful_enable = !colorful_enable; } if (Input.GetKeyUp(KeyCode.B)) { bloom_enabled = !bloom_enabled; } if (Input.GetKeyUp(KeyCode.S)) { shading_enable = !shading_enable; } if (Input.GetKeyDown(KeyCode.R)) { int rcount = Random.Range(20, 40); for (int i = 0; i < rcount; i++) { FluidPoint p = new FluidPoint(); p.x = screen_w * Random.Range(0.0f, 1.0f); p.y = screen_h * Random.Range(0.0f, 1.0f); p.dx = 1000 * (Random.Range(0.0f, 1.0f) - 0.5f); p.dy = 1000 * (Random.Range(0.0f, 1.0f) - 0.5f); p.color = GenerateColor(); p.color.r *= 10.0f; p.color.g *= 10.0f; p.color.b *= 10.0f; Splat(p); } } if (point.down) { // Debug.Log("Input.mousePosition:"+Input.mousePosition+" screen_w:"+screen_w+" screen_h:"+screen_h); point.moved = point.down; point.dx = (Input.mousePosition.x - point.x) * 5.0f; point.dy = (Input.mousePosition.y - point.y) * 5.0f; point.x = Input.mousePosition.x; point.y = Input.mousePosition.y; } if (point.moved) { point.moved = false; if (point.x > 0 && point.x < screen_w && point.y > 0 && point.y < screen_h) { Splat(point); } } if (!colorful_enable) { return; } if ((lastColorChangeTime + 0.2f) < Time.realtimeSinceStartup) { lastColorChangeTime = Time.realtimeSinceStartup; point.color = GenerateColor(); } }