Example #1
0
        public void Draw(Graphics graphics, RectangleD cameraBounds)
        {
            var particleBounds = new List<RectangleF>();

            float particleScale;

            // Scale particle size with viewport width
            if (cameraBounds.Width > 1000)
            {
                particleScale = 1;
            }
            else
            {
                particleScale = (float)(1.22e-6 * cameraBounds.Width * cameraBounds.Width - 4.8e-3 * cameraBounds.Width + 4.4);
            }

            float halfParticleScale = particleScale * 0.5f;

            foreach (Particle particle in _particles)
            {
                if (particle.IsActive)
                {
                    if (cameraBounds.Contains(particle.Position))
                    {
                        PointF localPoint = RenderUtils.WorldToScreen(particle.Position, cameraBounds);

                        particleBounds.Add(new RectangleF(localPoint.X - halfParticleScale,
                                                          localPoint.Y - halfParticleScale,
                                                          particleScale, particleScale));
                    }
                }
            }

            RenderUtils.DrawRectangles(graphics, particleBounds, _color);
        }
Example #2
0
        public void Draw(Graphics graphics, RectangleD cameraBounds, IMapRenderable orbitingBody)
        {
            var traceBounds = new List<RectangleF>();

            for (int i = 1; i < _points.Count; i++)
            {
                DVector2 orbitPoint = _points[i];

                if (cameraBounds.Contains(orbitPoint))
                {
                    PointF localPoint = RenderUtils.WorldToScreen(orbitPoint, cameraBounds);

                    if (i == _apogeeIndex && i > 1)
                    {
                        RenderApogee(graphics, localPoint);
                    }
                    else if (i == _perigeeIndex)
                    {
                        RenderPerigee(graphics, localPoint);
                    }
                    else
                    {
                        traceBounds.Add(new RectangleF(localPoint.X, localPoint.Y, 2, 2));
                    }
                }
            }

            if (_points.Count > 0 && cameraBounds.Contains(_points[0]))
            {
                RenderStart(graphics, cameraBounds, orbitingBody, _points[0]);
            }

            RenderUtils.DrawRectangles(graphics, traceBounds, orbitingBody.IconColor);
        }
Example #3
0
        public void Draw(Graphics graphics, RectangleD cameraBounds, IMassiveBody parentBody)
        {
            var poweredTrails = new List<RectangleF>();
            var coastTrails = new List<RectangleF>();

            for (int i = 0; i < _trailAngles.Count; i++)
            {
                double angle = _trailAngles[i] + parentBody.Pitch;
                double distance = _trailDistances[i];

                DVector2 worldPoint = DVector2.FromAngle(angle) * distance + parentBody.Position;

                if (cameraBounds.Contains(worldPoint))
                {
                    PointF localPoint = RenderUtils.WorldToScreen(worldPoint, cameraBounds);

                    if (_trailPowered[i])
                    {
                        poweredTrails.Add(new RectangleF(localPoint.X, localPoint.Y, 2, 2));
                    }
                    else
                    {
                        coastTrails.Add(new RectangleF(localPoint.X, localPoint.Y, 2, 2));
                    }
                }
            }

            RenderUtils.DrawRectangles(graphics, poweredTrails, Color.Red);
            RenderUtils.DrawRectangles(graphics, coastTrails, Color.White);
        }
Example #4
0
        public void Render(Graphics graphics, RectangleD cameraBounds)
        {
            var end = new PointF(_center.X + (float)Math.Cos(_thrustAngle) * 50, _center.Y + (float)Math.Sin(_thrustAngle) * 50);

            graphics.DrawLine(new Pen(Color.Red, 2), _center, end);

            graphics.DrawEllipse(new Pen(Color.White, 2), Bounds);
        }
Example #5
0
        public static PointF WorldToScreen(DVector2 point, RectangleD cameraBounds)
        {
            var normalizedPoint = new DVector2((point.X - cameraBounds.Left) / cameraBounds.Width,
                                               (point.Y - cameraBounds.Top) / cameraBounds.Height);

            return new PointF((float)(normalizedPoint.X * ScreenWidth),
                              (float)(normalizedPoint.Y * ScreenHeight));
        }
Example #6
0
        public void Render(Graphics graphics, RectangleD cameraBounds)
        {
            graphics.FillRectangle(new SolidBrush(Color.White), _center.X - 1, _center.Y - 52, 2, 104);

            graphics.FillRectangle(new SolidBrush(Color.White), _center.X - 5, _center.Y - 52, 10, 3);
            graphics.FillRectangle(new SolidBrush(Color.White), _center.X - 5, _center.Y + 52, 10, 3);

            int thrustX = (int)(_thrustMagnitude * 104) - 52;

            graphics.FillRectangle(new SolidBrush(Color.Red), _center.X -5, _center.Y - thrustX, 10, 4);
        }
Example #7
0
        public void Render(Graphics graphics, RectangleD cameraBounds)
        {
            if (IsActive)
            {
                graphics.FillEllipse(new SolidBrush(Color.Red), Bounds);
            }

            graphics.DrawString("R", _font, new SolidBrush(Color.White), _center.X - 8, _center.Y - 8);

            graphics.DrawEllipse(new Pen(Color.White, 2), Bounds);
        }
Example #8
0
        public void Render(Graphics graphics, RectangleD cameraBounds)
        {
            double scale = cameraBounds.Width * _widthPercentage;

            graphics.FillRectangle(new SolidBrush(Color.White), _center.X - 50, _center.Y - 2, 100, 4);

            graphics.FillRectangle(new SolidBrush(Color.White), _center.X - 51, _center.Y - 10, 4, 20);
            graphics.FillRectangle(new SolidBrush(Color.White), _center.X + 51, _center.Y - 10, 4, 20);

            graphics.DrawString(UnitDisplay.Distance(scale), _font, new SolidBrush(Color.White), _center.X + 65, _center.Y - 10);
        }
Example #9
0
        public static void DrawLine(Graphics graphics, RectangleD cameraBounds, DVector2 start, DVector2 end, Color color)
        {
            PointF localStart = WorldToScreen(start, cameraBounds);
            PointF localEnd = WorldToScreen(end, cameraBounds);

            localStart.X = MathHelper.Clamp(localStart.X, 0, ScreenWidth);
            localStart.Y = MathHelper.Clamp(localStart.Y, 0, ScreenHeight);

            localEnd.X = MathHelper.Clamp(localEnd.X, 0, ScreenWidth);
            localEnd.Y = MathHelper.Clamp(localEnd.Y, 0, ScreenHeight);

            graphics.DrawLine(new Pen(color, 2), localStart, localEnd);
        }
Example #10
0
        public void RenderGdi(Graphics graphics, RectangleD cameraBounds)
        {
            // Update position and rotation given the parent's motion
            double currentRotation = (_parent.Pitch - _initialRotation) + _rotationOffset;

            DVector2 rotationNormal = DVector2.FromAngle(currentRotation);

            Position = _parent.Position + rotationNormal * _initialDistance;

            var bounds = new RectangleD(Position.X - Width * 0.5, Position.Y - Height * 0.5, Width, Height);

            // Not in range easy return
            if (!cameraBounds.IntersectsWith(bounds))
            {
                return;
            }

            RectangleF screenBounds = RenderUtils.ComputeBoundingBox(Position, cameraBounds, Width, Height);

            // Saftey
            if (screenBounds.Width > RenderUtils.ScreenWidth * 500) return;

            double drawingRotation = currentRotation + Math.PI * 0.5;

            var offset = new PointF(screenBounds.X + screenBounds.Width * 0.5f,
                                    screenBounds.Y + screenBounds.Height * 0.5f);

            graphics.TranslateTransform(offset.X, offset.Y);

            graphics.RotateTransform((float)(drawingRotation * 180 / Math.PI));

            graphics.TranslateTransform(-offset.X, -offset.Y);

            graphics.DrawImage(_texture, screenBounds.X, screenBounds.Y, screenBounds.Width, screenBounds.Height);

            graphics.ResetTransform();

            double visibility = Visibility(cameraBounds);

            if (visibility < 1)
            {
                PointF iconPoint = RenderUtils.WorldToScreen(Position, cameraBounds);

                var iconBounds = new RectangleF(iconPoint.X - 5, iconPoint.Y - 5, 10, 10);

                var iconColor = Color.FromArgb((int)((1 - visibility) * 255), IconColor.R, IconColor.G, IconColor.B);

                graphics.FillEllipse(new SolidBrush(iconColor), iconBounds);
            }
        }
Example #11
0
        public void Draw(Graphics graphics, RectangleD cameraBounds, IIconRenderable orbitingBody)
        {
            var traceBounds = new List<RectangleF>();

            for (int i = 1; i < _points.Count; i++)
            {
                DVector2 orbitPoint = _points[i];

                if (cameraBounds.Contains(orbitPoint))
                {
                    PointF localPoint = RenderUtils.WorldToScreen(orbitPoint, cameraBounds);

                    if (i == _apogeeIndex)
                    {
                        RenderApogee(graphics, localPoint);
                    }
                    else if (i == _perigeeIndex)
                    {
                        RenderPerigee(graphics, localPoint);
                    }
                    else
                    {
                        traceBounds.Add(new RectangleF(localPoint.X, localPoint.Y, 2, 2));
                    }
                }
            }

               if (cameraBounds.Contains(_points[0]))
            {
                double visibility = orbitingBody.Visibility(cameraBounds);

                if (visibility < 1)
                {
                    PointF iconPoint = RenderUtils.WorldToScreen(_points[0], cameraBounds);

                    var iconBounds = new RectangleF(iconPoint.X - 5, iconPoint.Y - 5, 10, 10);

                    var iconColor = Color.FromArgb((int)((1 - visibility) * 255),
                                                   orbitingBody.IconColor.R,
                                                   orbitingBody.IconColor.G,
                                                   orbitingBody.IconColor.B);

                    graphics.FillEllipse(new SolidBrush(iconColor), iconBounds);
                }
            }

               RenderUtils.DrawRectangles(graphics, traceBounds, orbitingBody.IconColor);
        }
Example #12
0
        public static RectangleF ComputeEllipseSize(DVector2 position, RectangleD cameraBounds, double radius)
        {
            double screenRadius = (radius / cameraBounds.Width) * ScreenWidth;

            DVector2 screenPosition = position - new DVector2(cameraBounds.Left, cameraBounds.Top);

            double screenU = screenPosition.X / cameraBounds.Width;
            double screenV = screenPosition.Y / cameraBounds.Height;

            double screenX = screenU * ScreenWidth;
            double screenY = screenV * ScreenHeight;

            return new RectangleF((float) (screenX - screenRadius),
                                  (float) (screenY - screenRadius),
                                  (float) (screenRadius*2.0), (float) (screenRadius*2.0));
        }
Example #13
0
        public static RectangleF ComputeBoundingBox(DVector2 position, RectangleD cameraBounds, double width, double height)
        {
            double screenWidth = (width / cameraBounds.Width) * ScreenWidth;
            double screenHeight = (height / cameraBounds.Height) * ScreenHeight;

            DVector2 screenPosition = position - new DVector2(cameraBounds.Left, cameraBounds.Top);

            double screenU = screenPosition.X / cameraBounds.Width;
            double screenV = screenPosition.Y / cameraBounds.Height;

            double screenX = screenU * ScreenWidth;
            double screenY = screenV * ScreenHeight;

            return new RectangleF((float) (screenX - screenWidth*0.5),
                                  (float) (screenY - screenHeight*0.5),
                                  (float) screenWidth, (float) screenHeight);
        }
Example #14
0
        public void Draw(Graphics graphics, RectangleD cameraBounds)
        {
            var particleBounds = new List<RectangleF>();

            foreach (Particle particle in _particles)
            {
                if (particle.IsActive)
                {
                    if (cameraBounds.Contains(particle.Position))
                    {
                        PointF localPoint = RenderUtils.WorldToScreen(particle.Position, cameraBounds);

                        particleBounds.Add(new RectangleF(localPoint.X - 1.5f, localPoint.Y - 1.5f, 3, 3));
                    }
                }
            }

            RenderUtils.DrawRectangles(graphics, particleBounds, Color.FromArgb(50, 255, 255, 0));
        }
Example #15
0
        public void RenderGdi(Graphics graphics, RectangleD cameraBounds)
        {
            double drawingRotation = _parent.Pitch + Pitch;

            DVector2 drawingOffset = new DVector2(Math.Cos(drawingRotation), Math.Sin(drawingRotation)) * -4.2;

            RectangleF screenBounds = RenderUtils.ComputeBoundingBox(Position - drawingOffset, cameraBounds, Width,Height);

            var offset = new PointF(screenBounds.X + screenBounds.Width*0.5f, screenBounds.Y + screenBounds.Height*0.5f);

            graphics.TranslateTransform(offset.X, offset.Y);

            graphics.RotateTransform((float) ((drawingRotation + Math.PI*0.5)*180/Math.PI));

            graphics.TranslateTransform(-offset.X, -offset.Y);

            graphics.DrawImage(_texture, screenBounds.X, screenBounds.Y, screenBounds.Width, screenBounds.Height);

            graphics.ResetTransform();
        }
Example #16
0
        public void RenderGdiFallback(Graphics graphics, RectangleD cameraBounds, IPhysicsBody sun)
        {
            RectangleD bounds = ComputeBoundingBox();

            // Not in range easy return
            if (!cameraBounds.IntersectsWith(bounds))
            {
                return;
            }

            if (AtmosphereHeight > 0)
            {
                RectangleF atmosphereBounds = RenderUtils.ComputeEllipseSize(Position, cameraBounds, BoundingRadius);

                // Saftey
                if (atmosphereBounds.Width > RenderUtils.ScreenWidth * 5000) return;

                graphics.FillEllipse(new SolidBrush(IconAtmopshereColor), atmosphereBounds);
            }

            RectangleF surfaceBounds = RenderUtils.ComputeEllipseSize(Position, cameraBounds, SurfaceRadius);

            // Saftey
            if (surfaceBounds.Width > RenderUtils.ScreenWidth * 5000) return;

            graphics.FillEllipse(new SolidBrush(IconColor), surfaceBounds);
        }
Example #17
0
 public void Draw(Graphics graphics, RectangleD cameraBounds)
 {
     _engineFlame.Draw(graphics, cameraBounds);
 }
Example #18
0
 public override double Visibility(RectangleD cameraBounds)
 {
     throw new NotImplementedException();
 }
Example #19
0
        private static void RenderStart(Graphics graphics, RectangleD cameraBounds, IMapRenderable orbitingBody, DVector2 start)
        {
            double visibility = orbitingBody.Visibility(cameraBounds);

            if (visibility < 1)
            {
                PointF iconPoint = RenderUtils.WorldToScreen(start, cameraBounds);

                var iconBounds = new RectangleF(iconPoint.X - 5, iconPoint.Y - 5, 10, 10);

                var iconColor = Color.FromArgb((int)((1 - visibility) * 255),
                                               orbitingBody.IconColor.R,
                                               orbitingBody.IconColor.G,
                                               orbitingBody.IconColor.B);

                graphics.FillEllipse(new SolidBrush(iconColor), iconBounds);
            }
        }
Example #20
0
        public virtual double Visibility(RectangleD cameraBounds)
        {
            double distanceRatio = BoundingRadius / cameraBounds.Width;

            if (distanceRatio > 0.0025)
            {
                return 1;
            }

            if (distanceRatio > 0.002)
            {
                return (distanceRatio - 0.002) * 2000;
            }

            return 0;
        }
Example #21
0
        protected virtual void RenderAbove(Graphics graphics, RectangleD cameraBounds)
        {
            if (EntryFlame != null)
            {
                EntryFlame.Draw(graphics, cameraBounds);
            }

            // Only show the vectors when it's requested and the craft is not parented
            if (_showDisplayVectors && Parent == null)
            {
                // The length of the vector is based on the width of the camera bounds
                float lengthFactor = (float)(cameraBounds.Width * 0.1);

                PointF start = RenderUtils.WorldToScreen(Position, cameraBounds);

                DVector2 relativeVelocity = GetRelativeVelocity();

                // Only draw the velocity vector when it can be normalized
                if (relativeVelocity.Length() > 0)
                {
                    relativeVelocity.Normalize();

                    PointF velocityEnd = RenderUtils.WorldToScreen(Position + relativeVelocity * lengthFactor, cameraBounds);

                    graphics.DrawLine(Pens.White, start, velocityEnd);
                }

                DVector2 pitchVector = DVector2.FromAngle(Pitch);
                pitchVector.Normalize();

                PointF pitchEnd = RenderUtils.WorldToScreen(Position + pitchVector * lengthFactor, cameraBounds);

                graphics.DrawLine(Pens.Red, start, pitchEnd);
            }
        }
Example #22
0
        protected override void RenderShip(Graphics graphics, RectangleD cameraBounds, RectangleF screenBounds)
        {
            double drawingRotation = Pitch + Math.PI * 0.5;

            var offset = new PointF(screenBounds.X + screenBounds.Width * 0.5f,
                                    screenBounds.Y + screenBounds.Height * 0.5f);

            graphics.TranslateTransform(offset.X, offset.Y);

            graphics.RotateTransform((float)(drawingRotation * 180 / Math.PI));
            graphics.TranslateTransform(-offset.X, -offset.Y);

            // Normalize the angle to [0,360]
            int rollAngle = (int)(Roll * MathHelper.RadiansToDegrees) % 360;

            // Index into the sprite
            int ships = _spriteSheet.Cols * _spriteSheet.Rows;
            int spriteIndex = (rollAngle * ships) / 120;
            while (spriteIndex >= ships)
                spriteIndex -= ships;

            _spriteSheet.Draw(spriteIndex, graphics, screenBounds);

            graphics.ResetTransform();

            //Debug.WriteLine(string.Format("spriteIndex={0}", spriteIndex));
        }
Example #23
0
        protected override void RenderShip(Graphics graphics, RectangleD cameraBounds, RectangleF screenBounds)
        {
            // Build the main texture (a combination of base and soot)
            using (Graphics graphics2 = RenderUtils.GetContext(false, _drawingBuffer))
            {
                if (_sootRatio > 0.99)
                {
                    graphics2.DrawImage(_sootTexture, new Rectangle(0, 0, _drawingBuffer.Width, _drawingBuffer.Height));
                }
                else if (_sootRatio < 0.05)
                {
                    graphics2.DrawImage(Texture, new Rectangle(0, 0, _drawingBuffer.Width, _drawingBuffer.Height));
                }
                else
                {
                    graphics2.DrawImage(Texture, new Rectangle(0, 0, _drawingBuffer.Width, _drawingBuffer.Height));

                    float[][] matrixAlpha =
                    {
                        new float[] {1, 0, 0, 0, 0},
                        new float[] {0, 1, 0, 0, 0},
                        new float[] {0, 0, 1, 0, 0},
                        new float[] {0, 0, 0, (float)_sootRatio, 0},
                        new float[] {0, 0, 0, 0, 1}
                    };

                    ColorMatrix colorMatrix = new ColorMatrix(matrixAlpha);

                    ImageAttributes iaAlphaBlend = new ImageAttributes();
                    iaAlphaBlend.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

                    graphics2.DrawImage(_sootTexture, new Rectangle(0, 0, _drawingBuffer.Width, _drawingBuffer.Height), 0, 0,
                                        _drawingBuffer.Width, _drawingBuffer.Height, GraphicsUnit.Pixel, iaAlphaBlend);
                }
            }

            double drawingRotation = Pitch + Math.PI * 0.5;

            var offset = new PointF(screenBounds.X + screenBounds.Width * 0.5f,
                                    screenBounds.Y + screenBounds.Height * 0.5f);

            graphics.TranslateTransform(offset.X, offset.Y);

            graphics.RotateTransform((float)(drawingRotation * 180 / Math.PI));

            graphics.TranslateTransform(-offset.X, -offset.Y);

            graphics.DrawImage(_drawingBuffer, screenBounds.X, screenBounds.Y, screenBounds.Width, screenBounds.Height);

            graphics.ResetTransform();

            foreach (GridFin gridFin in _gridFins)
            {
                gridFin.RenderGdi(graphics, cameraBounds);
            }

            foreach (LandingLeg landingLeg in _landingLegs)
            {
                landingLeg.RenderGdi(graphics, cameraBounds);
            }
        }
Example #24
0
 public override double Visibility(RectangleD cameraBounds)
 {
     return 1;
 }
Example #25
0
        protected virtual void RenderShip(Graphics graphics, RectangleD cameraBounds, RectangleF screenBounds)
        {
            double drawingRotation = Pitch + Math.PI * 0.5;

            var offset = new PointF(screenBounds.X + screenBounds.Width * 0.5f,
                                    screenBounds.Y + screenBounds.Height * 0.5f);

            graphics.TranslateTransform(offset.X, offset.Y);

            graphics.RotateTransform((float)(drawingRotation * 180 / Math.PI));

            graphics.TranslateTransform(-offset.X, -offset.Y);

            graphics.DrawImage(Texture, screenBounds.X, screenBounds.Y, screenBounds.Width, screenBounds.Height);

            graphics.ResetTransform();
        }
Example #26
0
        /// <summary>
        /// Renders the space craft at it's correct scale and rotation according to the camera.
        /// The engines are rendered first and then the space craft body.
        /// </summary>
        public virtual void RenderGdi(Graphics graphics, RectangleD cameraBounds)
        {
            RectangleF screenBounds = RenderUtils.ComputeBoundingBox(Position, cameraBounds, Width, Height);

            // Saftey
            if (screenBounds.Width > RenderUtils.ScreenWidth * 500) return;

            foreach (IEngine engine in Engines)
            {
                engine.Draw(graphics, cameraBounds);
            }

            double drawingRotation = Rotation + Math.PI * 0.5;

            var offset = new PointF(screenBounds.X + screenBounds.Width * 0.5f,
                                    screenBounds.Y + screenBounds.Height * 0.5f);

            graphics.TranslateTransform(offset.X, offset.Y);

            graphics.RotateTransform((float)(drawingRotation * 180 / Math.PI));

            graphics.TranslateTransform(-offset.X, -offset.Y);

            graphics.DrawImage(Texture, screenBounds.X, screenBounds.Y, screenBounds.Width, screenBounds.Height);

            graphics.ResetTransform();
        }
Example #27
0
        protected override void RenderShip(Graphics graphics, RectangleD cameraBounds, RectangleF screenBounds)
        {
            double drawingRotation = Pitch + Math.PI * 0.5;

            var offset = new PointF(screenBounds.X + screenBounds.Width * 0.5f,
                                    screenBounds.Y + screenBounds.Height * 0.5f);

            graphics.TranslateTransform(offset.X, offset.Y);

            float pitchAngle = (float)(drawingRotation * 180 / Math.PI);
            float rollFactor = (float)Math.Cos(Roll);
            float alphaAngle = (float)(GetAlpha() * 180 / Math.PI);
            float rotateAngle = (pitchAngle - alphaAngle) + alphaAngle * rollFactor;

            if(this.MissionName.Contains("EDL") || this.MissionName.Contains("Aerocapture") || this.MissionName.Contains("Direct"))
                graphics.RotateTransform(rotateAngle);
            else
                graphics.RotateTransform(pitchAngle);

            graphics.TranslateTransform(-offset.X, -offset.Y);

            // Normalize the angle to [0,360]
            int rollAngle = (int)(Roll * MathHelper.RadiansToDegrees) % 360;

            // Index into the sprite
            int ships = _spriteSheet.Cols * _spriteSheet.Rows;
            int spriteIndex = (rollAngle * ships) / 360;
            while (spriteIndex < 0)
                spriteIndex += ships;

            _spriteSheet.Draw(spriteIndex, graphics, screenBounds);

            graphics.ResetTransform();

            //if (DateTime.Now - timestamp > TimeSpan.FromSeconds(1))
            //{
            //    string filename = MissionName + ".csv";

            //    if (!File.Exists(filename))
            //    {
            //        File.AppendAllText(filename, "Ma, FormDragCoefficient, SkinFrictionCoefficient, LiftCoefficient, pitchAngle\r\n");
            //    }

            //    timestamp = DateTime.Now;
            //    string contents = string.Format("{0:N3}, {1:N3}, {2:N3}, {3:N3},  {4:N3}\r\n",
            //        MachNumber, FormDragCoefficient, SkinFrictionCoefficient, LiftCoefficient, pitchAngle);
            //    File.AppendAllText(filename, contents);
            //}
        }
Example #28
0
        /// <summary>
        /// Renders the space craft at it's correct scale and rotation according to the camera.
        /// The engines are rendered first and then the space craft body.
        /// </summary>
        public override void RenderGdi(Graphics graphics, RectangleD cameraBounds)
        {
            // Only draws the ship if it's visible
            if (Visibility(cameraBounds) > 0)
            {
                RectangleD bounds = ComputeBoundingBox();

                // In range for render
                if (cameraBounds.IntersectsWith(bounds))
                {
                    RectangleF screenBounds = RenderUtils.ComputeBoundingBox(Position, cameraBounds, Width, Height);

                    // Saftey
                    if (screenBounds.Width > RenderUtils.ScreenWidth * 500) return;

                    RenderBelow(graphics, cameraBounds);

                    RenderShip(graphics, cameraBounds, screenBounds);

                    RenderAbove(graphics, cameraBounds);
                }
            }

            // Only draw orbit traces and launch trails for detatched ships
            if (Parent == null)
            {
                if (cameraBounds.Width > 1000)
                {
                    _launchTrail.Draw(graphics, cameraBounds, GravitationalParent);
                }

                // Don't draw orbit traces on the ground
                base.RenderGdi(graphics, cameraBounds);
            }
        }
Example #29
0
        public double Visibility(RectangleD cameraBounds)
        {
            double distanceRatio = TotalHeight / cameraBounds.Width;

            if (distanceRatio > 0.0025)
            {
                return 1;
            }

            if (distanceRatio > 0.002)
            {
                return (distanceRatio - 0.002) * 2000;
            }

            return 0;
        }
Example #30
0
 protected virtual void RenderBelow(Graphics graphics, RectangleD cameraBounds)
 {
     foreach (IEngine engine in Engines)
     {
         engine.Draw(graphics, cameraBounds);
     }
 }