Beispiel #1
0
        /// <summary>
        /// Update date on the text panel
        /// </summary>
        private void SetText(string text)
        {
            Size     textSize   = Insight3DHelper.MeasureString(text, m_dateTimeFont);
            Bitmap   textBitmap = new Bitmap(textSize.Width, textSize.Height);
            Graphics gfx        = Graphics.FromImage(textBitmap);

            gfx.DrawString(text, m_dateTimeFont, Brushes.LightGreen, new PointF(0, 0));
            m_textOverlay.Texture = SceneManager.Textures.FromBitmap(textBitmap);
        }
Beispiel #2
0
        /// <summary>
        /// Construct a default instance.
        /// </summary>
        public Main()
        {
            InitializeComponent();

            m_insight3D      = new Insight3D();
            m_insight3D.Dock = DockStyle.Fill;
            m_insight3DPanel.Controls.Add(m_insight3D);

            m_defaultStart = GregorianDate.Now;
            m_defaultEnd   = m_defaultStart.AddDays(1);

            m_animation            = new SimulationAnimation();
            SceneManager.Animation = m_animation;

            m_display = new ServiceProviderDisplay();

            m_forceModelSettings = new ForceModelSettings(s_jplData, GetDataFilePath("EarthGravityFile_EGM2008.grv"));
            m_integratorSettings = new IntegratorSettings();
            m_area.Text          = "20";
            m_mass.Text          = "500";

            // Create overlay toolbar and panels
            m_overlayToolbar = new OverlayToolbar(m_insight3D);
            m_overlayToolbar.Overlay.Origin = ScreenOverlayOrigin.BottomCenter;

            // Initialize the text panel
            TextureScreenOverlay textPanel = new TextureScreenOverlay(0, 0, 220, 35)
            {
                Origin             = ScreenOverlayOrigin.TopRight,
                BorderSize         = 0,
                BorderColor        = Color.Transparent,
                BorderTranslucency = 1.0f,
                Color        = Color.Transparent,
                Translucency = 1.0f
            };

            SceneManager.ScreenOverlays.Add(textPanel);

            m_dateTimeFont = new Font("Courier New", 12, FontStyle.Bold);
            Size textSize = Insight3DHelper.MeasureString(m_defaultStart.ToString(), m_dateTimeFont);

            m_textOverlay = new TextureScreenOverlay(0, 0, textSize.Width, textSize.Height)
            {
                Origin     = ScreenOverlayOrigin.Center,
                BorderSize = 0
            };
            textPanel.Overlays.Add(m_textOverlay);

            // Show label for the moon
            m_insight3D.Scene.CentralBodies[CentralBodiesFacet.GetFromContext().Moon].ShowLabel = true;

            // Set the name for the element that will get propagated
            m_elementID = "Satellite";

            // Subscribe to the time changed event
            SceneManager.TimeChanged += OnTimeChanged;

            // Set the start and stop times
            m_start.CustomFormat = DateFormat;
            m_end.CustomFormat   = DateFormat;

            m_start.Text = m_defaultStart.ToString(DateFormat);
            m_end.Text   = m_defaultEnd.ToString(DateFormat);

            m_animation.Time      = m_defaultStart.ToJulianDate();
            m_animation.StartTime = m_defaultStart.ToJulianDate();
            m_animation.EndTime   = m_defaultEnd.ToJulianDate();

            // Dynamically set the camera's position and direction so that the camera will always be pointed at the daylit portion of the earth.
            EarthCentralBody       earth               = CentralBodiesFacet.GetFromContext().Earth;
            SunCentralBody         sun                 = CentralBodiesFacet.GetFromContext().Sun;
            VectorTrueDisplacement earthToSunVector    = new VectorTrueDisplacement(earth.CenterOfMassPoint, sun.CenterOfMassPoint);
            VectorEvaluator        earthToSunEvaluator = earthToSunVector.GetEvaluator();
            Cartesian     earthToSunCartesian          = earthToSunEvaluator.Evaluate(new JulianDate(m_defaultStart));
            UnitCartesian earthToSunUnitCartesian      = new UnitCartesian(earthToSunCartesian);
            UnitCartesian cameraDirection              = new UnitCartesian(earthToSunUnitCartesian.Invert());
            Cartesian     cameraPosition               = new Cartesian(earthToSunUnitCartesian.X * 50000000, earthToSunUnitCartesian.Y * 50000000, earthToSunUnitCartesian.Z * 50000000);

            m_insight3D.Scene.Camera.Position  = cameraPosition;
            m_insight3D.Scene.Camera.Direction = cameraDirection;
        }