Esempio n. 1
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),
            }));
        }
Esempio n. 2
0
        /// <summary>
        /// Create another ground facility with a sensor dome, and a rotating sensor inside the dome.
        /// </summary>
        private void CreateSensorDome()
        {
            // Define the location of the facility using cartographic coordinates.
            var locationPoint = new PointCartographic(m_earth, new Cartographic(Trig.DegreesToRadians(-122.3), Trig.DegreesToRadians(46), 456.359));

            m_sensorDome = new Platform
            {
                Name            = "Sensor Dome",
                LocationPoint   = locationPoint,
                OrientationAxes = new AxesEastNorthUp(m_earth, locationPoint),
            };

            // Set the identifier for the facility in the CZML document.
            m_sensorDome.Extensions.Add(new IdentifierExtension("SensorDome"));

            // Define the sensor geometry.
            var dome = new ComplexConic();

            dome.SetHalfAngles(0.0, Math.PI);
            dome.SetClockAngles(0.0, Math.PI * 2);
            dome.Radius = 10000.0;
            m_sensorDome.Extensions.Add(new FieldOfViewExtension(dome));

            // Configure graphical display of the sensor dome.
            m_sensorDome.Extensions.Add(new FieldOfViewGraphicsExtension(new SensorFieldOfViewGraphics
            {
                DomeSurfaceMaterial = new GridMaterialGraphics
                {
                    Color     = Color.White,
                    CellAlpha = 0.1,
                },
            }));

            // Define a rotating axes.
            var rotatingAxes = new AxesLinearRate
            {
                ReferenceAxes             = new AxesEastNorthUp(m_earth, locationPoint),
                ReferenceEpoch            = m_epoch,
                InitialRotation           = UnitQuaternion.Identity,
                SpinAxis                  = UnitCartesian.UnitZ,
                InitialRotationalVelocity = Trig.DegreesToRadians(5.0), // 5 degrees per second
                RotationalAcceleration    = 0.0,
            };

            // Define a rotation around X.
            UnitQuaternion quaternion = new UnitQuaternion(new AngleAxisRotation(Math.PI / 3.0, UnitCartesian.UnitX));
            // Define an angular offset for the rotating axes.
            var rotatedOffsetAxes = new AxesFixedOffset(rotatingAxes, quaternion);

            m_rotatingSensor = new Platform
            {
                Name            = "Rotating Sensor",
                LocationPoint   = locationPoint,
                OrientationAxes = rotatedOffsetAxes
            };

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

            // Define the sensor geometry.
            m_rotatingSensor.Extensions.Add(new FieldOfViewExtension(new RectangularPyramid
            {
                XHalfAngle = Trig.DegreesToRadians(30),
                YHalfAngle = Trig.DegreesToRadians(30),
                Radius     = 10000.0,
            }));

            // Configure graphical display of the sensor.
            m_rotatingSensor.Extensions.Add(new FieldOfViewGraphicsExtension(new SensorFieldOfViewGraphics
            {
                DomeSurfaceMaterial = new GridMaterialGraphics
                {
                    Color     = Color.Green,
                    CellAlpha = 0.5,
                },
                LateralSurfaceMaterial = new GridMaterialGraphics
                {
                    Color     = Color.Pink,
                    CellAlpha = 0.5,
                },
                IntersectionColor            = Color.White,
                ShowIntersection             = true,
                ShowEllipsoidHorizonSurfaces = true,
            }));
        }