Exemplo n.º 1
0
        private async Task <Placemark> GetUnit(RenderEntry data)
        {
            if (!data.Entry.Where.Latitude.HasValue || !data.Entry.Where.Longtitude.HasValue)
            {
                return(null);
            }

            var latitude   = data.Entry.Where.Latitude.Value;
            var longtitude = data.Entry.Where.Longtitude.Value;

            var point = new SharpKml.Dom.Point
            {
                Coordinate = new SharpKml.Base.Vector(latitude, longtitude),
            };


            var placemark = new Placemark
            {
                Geometry    = point,
                Name        = data.Entry.ToString() + " Location",
                Time        = GetTimespan(data.Entry.When),
                Description = await GetDescription(data),
                StyleUrl    = GetStyle("location", 1.0, data.Color)
            };

            return(placemark);
        }
Exemplo n.º 2
0
        public bool Render()
        {
            D3D.BeginScene(0.0f, 0f, 0f, 1.0f);
            Camera.Render();

            foreach (BaseShader Shader in RenderStorageSingleton.Instance.ShaderManager.shaders.Values)
            {
                Shader.InitCBuffersFrame(D3D.DeviceContext, Camera, WorldSettings);
            }

            foreach (IRenderer RenderEntry in Assets.Values)
            {
                RenderEntry.UpdateBuffers(D3D.Device, D3D.DeviceContext);
                RenderEntry.Render(D3D.Device, D3D.DeviceContext, Camera);
            }

            //navigationGrids[0].Render(D3D.Device, D3D.DeviceContext, Camera);
            foreach (var grid in navigationGrids)
            {
                grid.Render(D3D.Device, D3D.DeviceContext, Camera);
            }

            translokatorGrid.Render(D3D.Device, D3D.DeviceContext, Camera);
            selectionBox.UpdateBuffers(D3D.Device, D3D.DeviceContext);
            selectionBox.Render(D3D.Device, D3D.DeviceContext, Camera);
            TranslationGizmo.UpdateBuffers(D3D.Device, D3D.DeviceContext);
            TranslationGizmo.Render(D3D.Device, D3D.DeviceContext, Camera);
            clouds.UpdateBuffers(D3D.Device, D3D.DeviceContext);
            clouds.Render(D3D.Device, D3D.DeviceContext, Camera);
            sky.DoRender = WorldSettings.RenderSky;
            sky.UpdateBuffers(D3D.Device, D3D.DeviceContext);
            sky.Render(D3D.Device, D3D.DeviceContext, Camera);
            D3D.EndScene();
            return(true);
        }
Exemplo n.º 3
0
        private async Task <List <Placemark> > GetLinesOfCommand(RenderEntry data)
        {
            var placemarks = new List <Placemark>();

            if (!data.Entry.What.Hierarchy.Any())
            {
                return(placemarks);
            }



            data.Entry.What.Hierarchy
            .Where(h => h.Superior.Equals(data.Entry.What))
            .Where(h => WasPresent(data.Entry.When.StartDateTime.DateTime, data.Entry.When.EndDateTime?.DateTime, h.StartDateTime.DateTime, h.EndDateTime?.DateTime))
            .ToList()
            .ForEach(h =>
            {
                var superiorLocation = data.Entry.Where;
                if (!superiorLocation.Latitude.HasValue || !superiorLocation.Longtitude.HasValue)
                {
                    return;
                }


                var inferiorLocations = h.Inferior.Locations.Where(l => WasPresent(l.StartDateTime.DateTime, l.EndDateTime?.DateTime, h.StartDateTime.DateTime, h.EndDateTime?.DateTime)).ToList();
                inferiorLocations.ForEach(il =>
                {
                    if (!il.Location.Latitude.HasValue || !il.Location.Longtitude.HasValue)
                    {
                        return;
                    }
                    var lineString         = new LineString();
                    lineString.Coordinates = new CoordinateCollection();
                    lineString.Coordinates.Add(new SharpKml.Base.Vector(superiorLocation.Latitude.Value, superiorLocation.Longtitude.Value));
                    lineString.Coordinates.Add(new SharpKml.Base.Vector(il.Location.Latitude.Value, il.Location.Longtitude.Value));


                    var placemark = new Placemark
                    {
                        Geometry = lineString,
                        Name     = data.Entry.ToString() + " Line of Command",
                        Time     = GetTimespan(GetActiveDateRange(h, il)),
                        StyleUrl = GetStyle("lineofcommand", 1.0, data.Color)
                    };

                    placemarks.Add(placemark);
                });
            });



            return(placemarks);
        }
Exemplo n.º 4
0
        private string GetPersonelDescriptionLine(RenderEntry data)
        {
            var organisation = data.Entry.What as IOrganisation;

            if (organisation == null)
            {
                return(string.Empty);
            }

            var peopleOfInterest = organisation.Personel.Where(a => WasPresent(a.StartDateTime.DateTime, a.EndDateTime?.DateTime, data.Entry.When.StartDateTime.DateTime, GetEndDateTime(data))).Select(p => p.ToString());

            return($"{String.Join(" ", peopleOfInterest.ToArray())}<br/>\r\n");
        }
Exemplo n.º 5
0
        private static string GetTimelineLine(RenderEntry data)
        {
            var when = data.Entry.When;
            var beginningFormatted = when.StartDateTime.DateTime.ToString(when.StartDateTime.Format);
            var endingFormatted    = when.EndDateTime?.DateTime.ToString(when.EndDateTime?.Format);

            if (endingFormatted == null)
            {
                endingFormatted = "unknown";
            }

            return($"{beginningFormatted}-{endingFormatted}<br/>\r\n");
        }
Exemplo n.º 6
0
 private async Task <Description> GetDescription(RenderEntry data)
 {
     return(new Description
     {
         Text = $"<![CDATA[" +
                $"<h1>{data.Entry.What.Name}</h1>\r\n" +
                GetRolesLine(data) +
                GetTimelineLine(data) +
                GetPersonelDescriptionLine(data) +
                await GetUnitSymbolLine(data) +
                $"]]>"
     });
 }
Exemplo n.º 7
0
        private async Task <Placemark> GetZoneOfInfluence(RenderEntry data)
        {
            Polygon polygon = GetInfluencePolygon(data.Entry.Where.Latitude, data.Entry.Where.Longtitude, data.Entry.What.ZoneOfInfluence.Range);

            var placemark = new Placemark
            {
                Geometry = polygon,
                Name     = data.Entry.ToString() + " Zone of Influence",
                Time     = GetTimespan(data.Entry.When),
                StyleUrl = GetStyle("zoneofinfluence", data.Entry.What.ZoneOfInfluence.Density, data.Color)
            };

            return(placemark);
        }
Exemplo n.º 8
0
        private static async Task <string> GetUnitSymbolLine(RenderEntry data)
        {
            var symbolFactory = new WikimediaImageFactory();

            var organisation = data.Entry.What as IOrganisation;

            if (organisation == null)
            {
                return(string.Empty);
            }

            var unitSymbolUrl = await symbolFactory.GetUnitSymbolUrl(organisation.Roles[0].Role.Name);

            // "Reconnaissance");

            var unitSizeUrl = await symbolFactory.GetUnitSizeUrl(organisation.Size); // "Regiment_or_Group");

            return($"<img src=\"{unitSymbolUrl}\" width=\"100\"><br/>\r\n<img src=\"{unitSizeUrl}\"  width=\"100\" ><br/>\r\n");
        }
Exemplo n.º 9
0
        private async Task <Placemark> GetRouteTo(RenderEntry data)
        {
            if (data.RouteTo == null)
            {
                return(null);
            }

            var lineString = new LineString();

            lineString.Coordinates = new CoordinateCollection();

            data.RouteTo.ToList().ForEach(ll => lineString.Coordinates.Add(new SharpKml.Base.Vector(ll.Latitude, ll.Longtitude)));

            var placemark = new Placemark
            {
                Geometry = lineString,
                Name     = data.Entry.ToString() + " Path To",
                Time     = GetTimespan(data.Entry.When),
                StyleUrl = GetStyle("routeto", 1.0, data.Color)
            };

            return(placemark);
        }
Exemplo n.º 10
0
        public async Task Write(RenderEntry re)
        {
            var units    = _document.FindFeature("Units") as Folder;
            var location = await GetUnit(re);

            if (location != null)
            {
                units.AddFeature(location);
            }


            var zoneOfControl = await GetZoneOfControl(re);

            var zonesOfControl = _document.FindFeature("ZonesOfControl") as Folder;

            zonesOfControl.AddFeature(zoneOfControl);

            var zoneOfInfluence = await GetZoneOfInfluence(re);

            var zonesOfInfluence = _document.FindFeature("ZonesOfInfluence") as Folder;

            zonesOfInfluence.AddFeature(zoneOfInfluence);

            var linesOfCommand = await GetLinesOfCommand(re);

            var linesOfCommands = _document.FindFeature("LinesOfCommand") as Folder;

            linesOfCommand.ForEach(loc => linesOfCommands.AddFeature(loc));

            var routesTo = _document.FindFeature("RoutesTo") as Folder;
            var pathTo   = await GetRouteTo(re);

            if (pathTo != null)
            {
                routesTo.AddFeature(pathTo);
            }
        }
Exemplo n.º 11
0
        public void AcceptForRender(GeometryNode drawNode, EffectApplication material)
        {
            RenderEntry newEntry = new RenderEntry(drawNode, material);
            if (material.UseAlphaPass)
            {
                Vector3 homogeneousClipSpacePos = Vector3.Transform(Transform.Top.Translation, VisibilityFrustum.Matrix);
                newEntry.SceneDepth = -homogeneousClipSpacePos.Z; // Negate because we want to sort far-to-near.
            }
            newEntry.Transform = Transform.Top;

            mRenderEntries.Add(newEntry);
        }
Exemplo n.º 12
0
        private string GetRolesLine(RenderEntry data)
        {
            var rolesOfInterest = data.Entry.What.Roles.Where(r => WasPresent(r.StartDateTime.DateTime, r.EndDateTime?.DateTime, data.Entry.When.StartDateTime.DateTime, GetEndDateTime(data))).Select(p => p.ToString());

            return($"{String.Join(" ", rolesOfInterest.ToArray())}<br/>\r\n");
        }
Exemplo n.º 13
0
 private DateTime?GetEndDateTime(RenderEntry data)
 {
     return(data.Entry.When.EndDateTime.DateTime);// != null ? data.Entry.When.EndDateTime.DateTime : data.FixedEndDateTime != null ? data.FixedEndDateTime.DateTime : (DateTime?)null;
 }