Пример #1
0
        static void Main(string[] args)
        {
            // 显示版本号
            Console.WriteLine("DisplayVersion: {0}", StkComponentsCore.DisplayVersion);
            Console.WriteLine("Version: {0}", StkComponentsCore.Version);

            // 显示当前时刻地球质心和月球质心之间的距离
            DateTime         now   = DateTime.Now;
            EarthCentralBody earth = CentralBodiesFacet.GetFromContext().Earth;
            MoonCentralBody  moon  = CentralBodiesFacet.GetFromContext().Moon;
            var    vector          = new VectorTrueDisplacement(earth.CenterOfMassPoint, moon.CenterOfMassPoint);
            double distance        = vector.GetEvaluator().Evaluate(new JulianDate(now)).Magnitude;

            Console.WriteLine("当前时间:{0:yyyy-MM-dd HH:mm:ss.fff},当前日月距离:{1:0.000}千米", now, distance / 1000);
            Console.Read();
        }
Пример #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;
        }