Пример #1
0
        /// <summary>
        /// Create an access link between AGI HQ and the satellite.
        /// </summary>
        private void CreateSatelliteAccessLink()
        {
            m_satelliteFacilityLink = new LinkInstantaneous(m_facility, m_satellite);

            // Set the identifier for the link in the CZML document.
            m_satelliteFacilityLink.Extensions.Add(new IdentifierExtension("SatelliteFacilityAccess"));

            // Specify how access should be constrained.  In this case,
            // access will only exist when no part of the earth is between AGI HQ and the satellite.
            m_accessQuery = new CentralBodyObstructionConstraint(m_satelliteFacilityLink, m_earth);

            // Configure graphical display of the access link.
            m_satelliteFacilityLink.Extensions.Add(new LinkGraphicsExtension(new LinkGraphics
            {
                // Show the access link only when access is satisfied.
                Show     = new AccessQueryCesiumProperty <bool>(m_accessQuery, true, false, false),
                Material = new SolidColorMaterialGraphics(Color.Yellow),
            }));
        }
Пример #2
0
        /// <summary>
        /// Create an aircraft with two sensors.
        /// The aircraft will be visually represented by a labeled glTF model.
        /// </summary>
        private void CreateAircraft()
        {
            // Define waypoints for the aircraft's path and use the propagated point as the location point.
            Cartographic point1             = new Cartographic(Trig.DegreesToRadians(-122.0), Trig.DegreesToRadians(46.3), 4000.0);
            Cartographic point2             = new Cartographic(Trig.DegreesToRadians(-122.28), Trig.DegreesToRadians(46.25), 4100.0);
            Cartographic point3             = new Cartographic(Trig.DegreesToRadians(-122.2), Trig.DegreesToRadians(46.1), 6000.0);
            Cartographic point4             = new Cartographic(Trig.DegreesToRadians(-121.5), Trig.DegreesToRadians(46.0), 7000.0);
            Waypoint     waypoint1          = new Waypoint(m_epoch, point1, 20.0, 0.0);
            Waypoint     waypoint2          = new Waypoint(waypoint1, m_earth.Shape, point2, 20.0);
            Waypoint     waypoint3          = new Waypoint(waypoint2, m_earth.Shape, point3, 20.0);
            Waypoint     waypoint4          = new Waypoint(waypoint3, m_earth.Shape, point4, 20.0);
            var          waypointPropagator = new WaypointPropagator(m_earth, waypoint1, waypoint2, waypoint3, waypoint4);
            var          locationPoint      = waypointPropagator.CreatePoint();

            m_aircraft = new Platform
            {
                Name            = "Aircraft",
                LocationPoint   = locationPoint,
                OrientationAxes = new AxesVehicleVelocityLocalHorizontal(m_earth.FixedFrame, locationPoint),
            };

            // Set the identifier for the aircraft in the CZML document.
            m_aircraft.Extensions.Add(new IdentifierExtension("Aircraft"));

            // Hermite interpolation works better for aircraft-like vehicles.
            m_aircraft.Extensions.Add(new CesiumPositionExtension
            {
                InterpolationAlgorithm = CesiumInterpolationAlgorithm.Hermite
            });

            // Configure a glTF model for the aircraft.
            m_aircraft.Extensions.Add(new ModelGraphicsExtension(new ModelGraphics
            {
                // Link to a binary glTF file.
                Model = new CesiumResource(GetModelUri("aircraft.glb"), CesiumResourceBehavior.LinkTo),
                // Flip the model visually to point Z in the correct direction.
                NodeTransformations = new Dictionary <string, NodeTransformationGraphics>
                {
                    {
                        "Aircraft", new NodeTransformationGraphics
                        {
                            Rotation = new UnitQuaternion(new ElementaryRotation(AxisIndicator.Third, Math.PI))
                        }
                    }
                },
                RunAnimations = false,
            }));

            // Show the path of the aircraft.
            m_aircraft.Extensions.Add(new PathGraphicsExtension(new PathGraphics
            {
                Width     = 2.0,
                LeadTime  = Duration.FromHours(1.0).TotalSeconds,
                TrailTime = Duration.FromHours(1.0).TotalSeconds,
                Material  = new PolylineOutlineMaterialGraphics
                {
                    Color        = Color.White,
                    OutlineColor = Color.Black,
                    OutlineWidth = 1.0,
                },
            }));

            // Configure label for the aircraft.
            m_aircraft.Extensions.Add(new LabelGraphicsExtension(new LabelGraphics
            {
                Text = m_aircraft.Name,
                // Change label color over time.
                FillColor = new TimeIntervalCollection <Color>
                {
                    // Green by default...
                    TimeInterval.Infinite.AddData(Color.Green),
                    // Red between first and second waypoints.
                    new TimeInterval <Color>(waypoint1.Date, waypoint2.Date, Color.Red),
                },
                // Only show label when camera is far enough from the aircraft,
                // to avoid visually clashing with the model.
                DistanceDisplayCondition = new Bounds(1000.0, double.MaxValue),
            }));

            // Define a description for the aircraft which will be shown when selected in Cesium.
            m_aircraft.Extensions.Add(new DescriptionExtension(new Description("Aircraft with two offset sensors")));

            // Create 30 degree simple conic sensor definition
            var sensorCone = new ComplexConic();

            sensorCone.SetHalfAngles(0.0, Trig.DegreesToRadians(15));
            sensorCone.SetClockAngles(Trig.DegreesToRadians(20), Trig.DegreesToRadians(50));
            sensorCone.Radius = double.PositiveInfinity;

            // Create a sensor pointing "forward".
            // Position sensor underneath the wing.
            var sensorOneLocationPoint = new PointFixedOffset(m_aircraft.ReferenceFrame, new Cartesian(-3.0, 8.0, 0.0));
            var sensorAxesOne          = new AxesAlignedConstrained(m_aircraft.OrientationAxes.GetVectorElement(CartesianElement.Z), AxisIndicator.Third,
                                                                    m_aircraft.OrientationAxes.GetVectorElement(CartesianElement.X), AxisIndicator.First);
            // This rotation points the z-axis of the volume back along the x-axis of the ellipsoid.
            var rotationOne = new UnitQuaternion(new ElementaryRotation(AxisIndicator.Second, Constants.HalfPi / 4));

            m_aircraftSensorOne = new Platform
            {
                LocationPoint   = sensorOneLocationPoint,
                OrientationAxes = new AxesFixedOffset(sensorAxesOne, rotationOne),
            };

            // Set the identifier for the sensor in the CZML document.
            m_aircraftSensorOne.Extensions.Add(new IdentifierExtension("AircraftSensorOne"));

            m_aircraftSensorOne.Extensions.Add(new CesiumPositionExtension
            {
                InterpolationAlgorithm = CesiumInterpolationAlgorithm.Hermite
            });

            // Define the sensor geometry.
            m_aircraftSensorOne.Extensions.Add(new FieldOfViewExtension(sensorCone));

            // Configure graphical display of the sensor.
            m_aircraftSensorOne.Extensions.Add(new FieldOfViewGraphicsExtension(new SensorFieldOfViewGraphics
            {
                // Configure the outline of the projection onto the earth.
                EllipsoidSurfaceMaterial = new SolidColorMaterialGraphics(Color.White),
                IntersectionWidth        = 2.0,
                LateralSurfaceMaterial   = new GridMaterialGraphics
                {
                    Color = Color.FromArgb(171, Color.Blue),
                },
            }));

            // Create sensor pointing to the "side".
            // Position sensor underneath the wing.
            var sensorTwoLocationPoint = new PointFixedOffset(m_aircraft.ReferenceFrame, new Cartesian(-3.0, -8.0, 0.0));
            var sensorAxesTwo          = new AxesAlignedConstrained(m_aircraft.OrientationAxes.GetVectorElement(CartesianElement.Z), AxisIndicator.Third,
                                                                    m_aircraft.OrientationAxes.GetVectorElement(CartesianElement.Y), AxisIndicator.Second);

            // This rotation points the z-axis of the volume back along the x-axis of the ellipsoid.
            var rotationTwo = new UnitQuaternion(new ElementaryRotation(AxisIndicator.First, Constants.HalfPi / 2));

            m_aircraftSensorTwo = new Platform
            {
                LocationPoint   = sensorTwoLocationPoint,
                OrientationAxes = new AxesFixedOffset(sensorAxesTwo, rotationTwo),
            };

            // Set the identifier for the sensor in the CZML document.
            m_aircraftSensorTwo.Extensions.Add(new IdentifierExtension("AircraftSensorTwo"));

            m_aircraftSensorTwo.Extensions.Add(new CesiumPositionExtension
            {
                InterpolationAlgorithm = CesiumInterpolationAlgorithm.Hermite
            });

            // Define the sensor geometry.
            m_aircraftSensorTwo.Extensions.Add(new FieldOfViewExtension(sensorCone));

            // Configure graphical display of the sensor.
            m_aircraftSensorTwo.Extensions.Add(new FieldOfViewGraphicsExtension(new SensorFieldOfViewGraphics
            {
                // Configure the outline of the projection onto the earth.
                EllipsoidSurfaceMaterial = new SolidColorMaterialGraphics(Color.White),
                IntersectionWidth        = 2.0,
                LateralSurfaceMaterial   = new GridMaterialGraphics
                {
                    Color = Color.FromArgb(171, Color.Red),
                },
            }));

            // Create an access link between the aircraft and the observer position
            // on Mount St. Helens, using the same azimuth elevation mask to constrain access.

            m_aircraftAzimuthElevationMaskLink = new LinkInstantaneous(m_maskPlatform, m_aircraft);

            // Set the identifier for the link in the CZML document.
            m_aircraftAzimuthElevationMaskLink.Extensions.Add(new IdentifierExtension("AircraftMountStHelensAccess"));

            // Constrain access using the azimuth-elevation mask.
            var query = new AzimuthElevationMaskConstraint(m_aircraftAzimuthElevationMaskLink, LinkRole.Transmitter);

            // Configure graphical display of the access link.
            m_aircraftAzimuthElevationMaskLink.Extensions.Add(new LinkGraphicsExtension(new LinkGraphics
            {
                // Show the access link only when access is satisfied.
                Show     = new AccessQueryCesiumProperty <bool>(query, true, false, false),
                Material = new SolidColorMaterialGraphics(Color.Yellow),
            }));
        }