private void drawProjectilePathPreview(PrimitiveGeometry geo) { var s = this.body.Shape; var dVector = this.aimDirection.Vector; var v = new Velocity2(dVector * 0.9f) + this.body.Velocity; var p = s.Center + new Difference2(dVector * s.Radius.NumericValue * 1.5f); geo.LineWidth = 0.05f; geo.Color = Color.Gray; for (int i = 0; i < 50; i++) { var acceleration = Vector2.Zero; foreach (var body in this.game.Bodies) { var shape = body.Shape; var difference = shape.Center - p; var distanceSquared = difference.LengthSquared; var a = Constants.G * body.Mass / distanceSquared.NumericValue; var dirNormal = difference.Direction.Vector; acceleration += dirNormal * a; } var speedFactor = Math.Min(0.5f / acceleration.Length.Sqrted(), 0.5f / v.Speed.NumericValue.Squared()); var t = TimeSpan.One * speedFactor; v += new Velocity2(acceleration * (float)t.NumericValue); var p2 = p + v * t; geo.DrawLine(p.Vector, p2.Vector); p = p2; } }
public void Draw(PrimitiveGeometry geo) { geo.Color = this.Color; geo.DrawLine(this.From, this.To); }