Example #1
0
        private void AddLodComponent(int level, int slice, int ring)
        {
            var coef   = F6Math.Pow2(level);
            var slices = 2 * coef;
            var rings  = 1 * coef;

            _textures.Add(new LeveledTexturePointer(level, slice, ring), TexturePointer.Create($"Resources/Textures/tiles/{level}/{slice:D4}_{ring:D4}.png"));
            _meshes.Add(new MeshSphereLocalLod((float)(SgpConstants.EarthRadiusKm / 100), slices, rings, level, slice, ring));
        }
Example #2
0
        private void CreateBaseSphere()
        {
            var level  = 1;
            var coef   = F6Math.Pow2(level);
            var slices = 2 * coef;
            var rings  = 1 * coef;

            for (var slice = 0; slice < slices; slice++)
            {
                for (var ring = 0; ring < rings; ring++)
                {
                    AddLodComponent(level, slice, ring);
                }
            }
        }
Example #3
0
        /// <inheritdoc />
        protected override void OnPaint(object sender, NvgContext e)
        {
            int i;

            float x = Location.X;
            float y = Location.Y;

            e.BeginPath();
            e.Rect(x, y, Width, Height);
            e.FillColor(NanoVg.Rgba(255, 255, 255, 64));
            e.Fill();

            e.BeginPath();

            if (Fill)
            {
                e.MoveTo(x, y + Height);
            }
            else
            {
                var v0 = _values[_head % HistoryCount];
                v0 = F6Math.RemapClamp(v0, Min, Max, 0, Height);
                e.MoveTo(x, y + Height - v0);
            }

            for (i = 0; i < HistoryCount; i++)
            {
                var v  = _values[(_head + i) % HistoryCount];
                var vx = x + (float)i / (HistoryCount - 1) * Width;
                var vy = y + Height - F6Math.RemapClamp(v, Min, Max, 0, Height);
                e.LineTo(vx, vy);
            }

            if (Fill)
            {
                e.LineTo(x + Width, y + Height);
                e.FillColor(NanoVg.Rgba(Color));
                e.Fill();
            }
            else
            {
                e.StrokeColor(NanoVg.Rgba(Color));
                e.Stroke();
            }

            var avgY = F6Math.RemapClamp(_avg, Min, Max, 0, Height);

            e.BeginPath();
            e.MoveTo(x, y + Height - avgY);
            e.LineTo(x + Width, y + Height - avgY);
            e.StrokeColor(NanoVg.Rgba(255, 255, 255, 128));
            e.Stroke();

            e.FontFace(FontFamily);

            if (Title != null)
            {
                e.FontSize(14.0f);
                e.TextAlign(NvgAlign.Left | NvgAlign.Top);
                e.FillColor(NanoVg.Rgba(240, 240, 240, 192));
                e.Text(x + 3, y + 1, Title);
            }

            e.FontSize(16.0f);
            e.TextAlign(NvgAlign.Right | NvgAlign.Top);
            e.FillColor(NanoVg.Rgba(240, 240, 240, 255));
            var str = string.Format(Number, _avg.ToString(NumberFormatStyle));

            e.Text(x + Width - 3, y + 1, str);

            if (Unit != null)
            {
                e.FontSize(15.0f);
                e.TextAlign(NvgAlign.Right | NvgAlign.Bottom);
                e.FillColor(NanoVg.Rgba(240, 240, 240, 160));
                e.Text(x + Width - 3, y + Height - 1, Unit);
            }

            base.OnPaint(sender, e);
        }