Exemplo n.º 1
0
        /// <summary>
        /// Draw the ephemeris in the Insight3D window.
        /// </summary>
        /// <param name="ephemeris">The date, position (and velocity) information of the object being displayed.</param>
        /// <param name="inertialFrame">The inertial frame to display the graphics in.</param>
        private void DrawSatellite(DateMotionCollection <Cartesian> ephemeris, ReferenceFrame inertialFrame)
        {
            // Clean up the previous run's graphics
            foreach (Primitive primitive in m_primitivesAddedToScene)
            {
                SceneManager.Primitives.Remove(primitive);
            }
            m_primitivesAddedToScene.Clear();
            if (m_platform != null)
            {
                m_display.ServiceProviders.Remove(m_platform);
            }

            // Draw the orbit
            List <PathPoint> points = new List <PathPoint>();

            for (int i = 0; i < ephemeris.Count; i++)
            {
                points.Add(new PathPointBuilder(ephemeris.Values[i], ephemeris.Dates[i]).ToPathPoint());
            }
            PathPrimitive path = new PathPrimitive {
                ReferenceFrame = inertialFrame
            };

            path.AddRangeToFront(points);
            SceneManager.Primitives.Add(path);
            m_primitivesAddedToScene.Add(path);

            // Put a marker where the satellite is at a given time
            LagrangePolynomialApproximation interpolationAlgorithm = new LagrangePolynomialApproximation();
            TranslationalMotionInterpolator interpolator           = new TranslationalMotionInterpolator(interpolationAlgorithm, 2, ephemeris);

            m_platform = new Platform
            {
                LocationPoint = new PointInterpolator(inertialFrame, interpolator)
            };

            Texture2D texture = SceneManager.Textures.FromUri(@"Data\Markers\Satellite.png");

            m_platform.Extensions.Add(new MarkerGraphicsExtension(new MarkerGraphics
            {
                Texture = new ConstantGraphicsParameter <Texture2D>(texture)
            }));
            m_display.ServiceProviders.Add(m_platform);
            m_display.ApplyChanges();

            // Set the date to the start of the ephemeris
            SceneManager.Animation.Time = ephemeris.Dates[0];
        }