/// <summary> /// 响应鼠标的操作 /// </summary> public void Fire() { if (Start) { PhysicsWorld.RemoveObject(_elasticatedNet); DrawQueue.Remove(_elasticatedNet); } // 创建弹性网并加入到物理世界和绘制队列 _elasticatedNet = new ElasticatedNet( new Vector2D(40, 120).ToSimUnits(), Width, Height, GridSize, Factor ); DrawQueue.Add(_elasticatedNet); PhysicsWorld.AddObject(_elasticatedNet); // 拉扯弹性网 var net = _elasticatedNet.Net; for (int i = 0; i < Width; i++) { net[i, Height - 1].Velocity = new Vector2D(0, 0.1) * 4 * (i >= Width / 2 ? -1 : 1); net[i, Height - 1].InverseMass = 0; } Start = true; }