private void renderBody(CelestialBody Body, CaptionMode CaptionMode, double Zoom) { if (projector.PositionNearlyLocked && projector.BodyWithCamera.Equals(Body) && projector.ViewMode != ViewMode.TopDown) { return; } float radiusInPixels; double subtendedAngle = Body.AngleSubtendedFromDistance(Body.DistanceFromCamera) / 2.0; radiusInPixels = (float)Math.Abs(projector.Zoom * subtendedAngle); if (Body.RenderPoint.X < -radiusInPixels || Body.RenderPoint.Y < -radiusInPixels || Body.RenderPoint.X > this.ScreenSize.Width + radiusInPixels || Body.RenderPoint.Y > this.ScreenSize.Height + radiusInPixels) { return; } #if DEBUG if (Body.RenderPoint.IsZero) { throw new Exception(); } #endif bool caption; switch (CaptionMode) { case SolarMax.CaptionMode.Auto: caption = projector.BodyBeingViewed.Equals(Body) || radiusInPixels > AUTO_CAPTION_THRESHOLD || Zoom > Body.CaptionZoomThreshold; break; case SolarMax.CaptionMode.DynamicOnly: caption = projector.BodyBeingViewed.Equals(Body) || (Body.BodyType == CelestialBodyType.Dynamic && (radiusInPixels > AUTO_CAPTION_THRESHOLD || Zoom > Body.CaptionZoomThreshold)); break; default: caption = false; break; } if (caption) { DrawString(Body.DisplayName, new QPoint(Body.RenderPoint.X + radiusInPixels, Body.RenderPoint.Y + radiusInPixels), Body == projector.BodyBeingViewed ? QPen.White : Body.CaptionPen, this.SmallFont); } if (this.WireFrameBodyRender && radiusInPixels > 7 && Body.HasShape) { var shape = (radiusInPixels > 80) ? Body.ShapeBig : (radiusInPixels > 30) ? Body.ShapeMedium : Body.ShapeSmall; shape.Reset(); if (Body.HasDynamicShape) { shape.RotateAbout(Body.Axis, Body.AngleSnapshot); } shape.Move(Body.PositionSnapshot); QPoint p1, p2; double distSqr = projector.Position.DistanceToSquared(Body.PositionSnapshot); bool highlightSun = HighlightSunlitAreas && Body is Orbiter; double distSqrSun = highlightSun ? CelestialBody.Sun.PositionSnapshot.DistanceToSquared(Body.PositionSnapshot) : double.MaxValue; // Draw back of object foreach (var l in shape.Lines) { l.IsInFront = l.P1.DistanceToSquared(projector.Position) < distSqr || l.P2.DistanceToSquared(projector.Position) < distSqr; if (!l.IsInFront) { if (projector.Project2DLine(l.P1, l.P2, out p1, out p2)) { DrawingTarget.DrawLine(l.LineType == LineType.Special ? primeMeridianDarkPen : Body.BackPen, p1, p2); } } } // Draw axis if (radiusInPixels > DRAW_AXIS_THRESHOLD) { if (projector.Project2DLine(Body.PositionSnapshot + Body.Axis * Body.Radius * AXIS_SCALE, Body.PositionSnapshot - Body.Axis * Body.Radius * AXIS_SCALE, out p1, out p2)) { DrawingTarget.DrawLine(planetAxisPen, p1, p2); } } //Draw front of object foreach (var l in shape.Lines) { if (l.IsInFront) { if (projector.Project2DLine(l.P1, l.P2, out p1, out p2)) { if (highlightSun && l.LineType != LineType.Special && (l.P1.DistanceToSquared(CelestialBody.Sun.PositionSnapshot) < distSqrSun || l.P2.DistanceToSquared(CelestialBody.Sun.PositionSnapshot) < distSqrSun)) { DrawingTarget.DrawLine(sunlitArea, p1, p2); } else { DrawingTarget.DrawLine(l.LineType == LineType.Special ? primeMeridianPen : Body.FrontPen, p1, p2); } } } } } else { radiusInPixels += Body.RadiusEnhancement; if (radiusInPixels > 1f) { DrawingTarget.FillCircle(Body.Pen, Body.RenderPoint.X, Body.RenderPoint.Y, radiusInPixels); } else { DrawingTarget.SetPixel(Body.Pen, Body.RenderPoint.X, Body.RenderPoint.Y); } } RenderLocations[NumRenderLocations++] = Body; }
private double fullZoomAmount(double Distance, CelestialBody Body) { return(Math.Max(MinimumPixelsPerRadian, 0.004 * Math.Log(Body.Radius) * (double)this.ScreenSize.Width / Body.AngleSubtendedFromDistance(Distance))); }