Esempio n. 1
0
        protected override void RenderShip(Graphics graphics, Camera camera, 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);

            camera.ApplyScreenRotation(graphics);
            camera.ApplyRotationMatrix(graphics, offset, drawingRotation);

            graphics.DrawImage(Texture, screenBounds.X - screenBounds.Width * 0.05f, screenBounds.Y, screenBounds.Width * 1.1f, screenBounds.Height);

            graphics.ResetTransform();

            if (_drogueChute.IsDeploying() || _drogueChute.IsDeployed())
            {
                _drogueChute.RenderGdi(graphics, camera);
            }

            if (_parafoil.IsDeploying() || _parafoil.IsDeployed())
            {
                _parafoil.RenderGdi(graphics, camera);
            }
        }
Esempio n. 2
0
        protected override void RenderShip(Graphics graphics, Camera camera, RectangleF screenBounds)
        {
            foreach (Skid skid in _skids)
            {
                if (skid.IsDeploying() || skid.IsDeployed())
                {
                    skid.RenderGdi(graphics, camera);
                }
            }

            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;

            int heatingRate = Math.Min((int)this.HeatingRate, 2000000);

            if (heatingRate > 100000)
            {
                Random     rnd        = new Random();
                float      noise      = (float)rnd.NextDouble();
                float      width      = screenBounds.Width / (3 + noise);
                float      height     = screenBounds.Height / (18 + noise);
                RectangleF plasmaRect = screenBounds;
                plasmaRect.Inflate(new SizeF(width, height));

                int   alpha = Math.Min(heatingRate / 7800, 255);
                int   red   = alpha;
                int   green = Math.Max(red - 128, 0) * 2;
                int   blue  = 0;
                Color glow  = Color.FromArgb(alpha, red, green, blue);

                float penWidth = width / 12;
                Pen   glowPen  = new Pen(glow, penWidth);
                glowPen.StartCap = System.Drawing.Drawing2D.LineCap.Round;
                glowPen.EndCap   = System.Drawing.Drawing2D.LineCap.Round;
                graphics.DrawArc(glowPen, plasmaRect, 220, 100);

                glowPen.Color = Color.FromArgb((int)(alpha * 0.75), glow);
                plasmaRect.Inflate(-penWidth, -penWidth);
                graphics.DrawArc(glowPen, plasmaRect, 200, 140);

                glowPen.Color = Color.FromArgb((int)(alpha * 0.5), glow);
                plasmaRect.Inflate(-penWidth, -penWidth);
                graphics.DrawArc(glowPen, plasmaRect, 180, 180);

                glowPen.Color = Color.FromArgb((int)(alpha * 0.25), glow);
                plasmaRect.Inflate(-penWidth, -penWidth);
                graphics.DrawArc(glowPen, plasmaRect, 160, 220);
            }

            // 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 (_drogueChute.IsDeploying() || _drogueChute.IsDeployed())
            {
                _drogueChute.RenderGdi(graphics, camera);
            }

            if (_parachute.IsDeploying() || _parachute.IsDeployed())
            {
                _parachute.RenderGdi(graphics, camera);
            }

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

                if (!File.Exists(filename))
                {
                    File.AppendAllText(filename, "Velocity, Acceleration, Altitude, Alpha\r\n");
                }

                timestamp = DateTime.Now;

                string contents = string.Format("{0}, {1}, {2}, {3}\r\n",
                                                this.GetRelativeVelocity().Length(),
                                                this.GetRelativeAcceleration().Length() * 100,
                                                this.GetRelativeAltitude() / 10,
                                                this.GetAlpha() * 10);
                File.AppendAllText(filename, contents);
            }
        }