void Start() { debuggers = new List <GameObject>(); particles = new List <VParticle>(); for (int i = 0; i < count; i++) { var p = new VParticle(Vector3.right * i); particles.Add(p); var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.localScale = Vector3.one * 0.25f; debuggers.Add(sphere); } ; for (int i = 0; i < count; i++) { if (i != count - 1) { var a = particles[i]; var b = particles[i + 1]; var e = new VEdge(a, b); a.Connect(e); b.Connect(e); } } simulator = new VerletSimulator(particles); }
void Start() { debuggers = new List <GameObject>(); particles = new List <VParticle>(); var offset = -count * 0.5f; for (int y = 0; y < count; y++) { for (int x = 0; x < count; x++) { var p = new VParticle(y * Vector3.forward + (Vector3.right * (x - offset))); particles.Add(p); var sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); sphere.transform.localScale = Vector3.one * 0.25f; debuggers.Add(sphere); } } for (int y = 0; y < count; y++) { if (y != count - 1) { for (int x = 0; x < count; x++) { var index = y * count + x; var c = particles[index]; if (x != count - 1) { var right = particles[index + 1]; var re = new VEdge(c, right); c.Connect(re); right.Connect(re); } var down = particles[index + count]; var de = new VEdge(c, down); c.Connect(de); down.Connect(de); } } else { for (int x = 0; x < count - 1; x++) { var index = y * count + x; var c = particles[index]; var right = particles[index + 1]; var re = new VEdge(c, right); c.Connect(re); right.Connect(re); } } } simulator = new VerletSimulator(particles); }
protected void RenderConnection(VParticle p, Color color) { p.Connection.ForEach(e => { var other = e.Other(p); GL.PushMatrix(); GL.Begin(GL.LINES); GL.Vertex(p.position); GL.Vertex(other.position); GL.Color(color); GL.End(); GL.PopMatrix(); }); }