protected virtual void DrawSpritesInner()
        {
            if (!VisibleUi)
            {
                return;
            }

            if (_textBlock == null)
            {
                _textBlock = new TextBlockRenderer(Sprite, "Arial", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 20f);
            }

            if (TrianglesCount == 0)
            {
                _textBlock.DrawString("Nothing found",
                                      new RectangleF(0, 0, Width, Height), TextAlignment.VerticalCenter | TextAlignment.HorizontalCenter, 20f,
                                      new Color4(1.0f, 1.0f, 1.0f), CoordinateType.Absolute);
            }
            else
            {
                _textBlock.DrawString($"Triangles: {TrianglesCount}\nZoom: {Zoom:F3}×\nResult image most likely will be different size",
                                      new RectangleF(8, 8, Width - 16, Height - 16), TextAlignment.Bottom | TextAlignment.Left, 12f,
                                      new Color4(1.0f, 1.0f, 1.0f), CoordinateType.Absolute);
            }
        }
Exemple #2
0
 public StringMetrics DrawString(string fontName, string text, Vector2 location, Color4 color)
 {
     if (!_fonts.ContainsKey(fontName))
     {
         return(_default.DrawString(text, location, color));
     }
     return(_fonts[fontName].DrawString(text, location, color));
 }
Exemple #3
0
        protected override void DrawSpritesInner()
        {
            if (VisibleUi && !ShotInProcess)
            {
                _textBlock.DrawString($@"
FPS: {FramesPerSecond:F1}{(SyncInterval ? " (limited)" : "")}
Mode: {Mode}
KN5 objs.: {Kn5MaterialDeferred.Drawed}
SSLR: {(!UseLocalReflections ? "No" : BlurLocalReflections ? "Yes, blurred" : "Yes")}
Cubemap refl.: {(UseCubemapReflections ? "Yes" : "No")}
Shadows: {(!UseShadows ? "No" : UseDebugShadows ? "Debug" : UseShadowsFilter ? "With Filtering" : "Yes")}
FXAA: {(!UseFxaa ? "No" : UseExperimentalSmaa ? "No, SMAA" : UseExperimentalFxaa ? "Experim." : "Yes")}
Lights: {(Lights.Count > 0 ? Lights.Count.ToString() : "")}".Trim(),
                                      new Vector2(Width - 300, 20), 16f, new Color4(1.0f, 1.0f, 1.0f),
                                      CoordinateType.Absolute);
            }

            Kn5MaterialDeferred.Drawed = 0;
        }
        public void TestRenderText()
        {
            var game = new DX11Game();

            game.InitDirectX();

            var Sprite = new SpriteRenderer(game.Device);

            Sprite.ScreenSize = new SlimDX.Vector2(800, 600);


            var myTextBlockRenderer = new TextBlockRenderer(Sprite, "Arial", FontWeight.Bold, FontStyle.Normal, FontStretch.Normal, 12);



            game.GameLoopEvent += delegate
            {
                myTextBlockRenderer.DrawString("Hello Wizard", new SlimDX.Vector2(20, 20),
                                               new SlimDX.Color4(1, 1, 1));
                Sprite.Flush();
            };
        }
Exemple #5
0
        protected override void DrawSpritesInner()
        {
            if (!VisibleUi)
            {
                return;
            }

            if (_textBlock == null)
            {
                _textBlock = new TextBlockRenderer(Sprite, "Arial", FontWeight.Normal, FontStyle.Normal, FontStretch.Normal, 24f);
            }

            _textBlock.DrawString(GetInformationString(),
                                  new Vector2(ActualWidth - 300, 20), 16f, UiColor,
                                  CoordinateType.Absolute);

            if (CarNode == null)
            {
                return;
            }

            var offset = 15;

            if (CarNode.LodsCount > 0)
            {
                var information = CarNode.CurrentLodInformation;
                _textBlock.DrawString(
                    $"LOD #{CarNode.CurrentLod + 1} ({CarNode.LodsCount} in total; shown from {information?.In.ToInvariantString() ?? "?"} to {information?.Out.ToInvariantString() ?? "?"})",
                    new RectangleF(0f, 0f, ActualWidth, ActualHeight - offset),
                    TextAlignment.HorizontalCenter | TextAlignment.Bottom, 16f, UiColor,
                    CoordinateType.Absolute);
                offset += 20;
            }

            var flags = new List <string>(4);

            if (CarNode.HasCockpitLr)
            {
                flags.Add(CarNode.CockpitLrActive ? "LR-cockpit" : "HR-cockpit");
            }

            if (CarNode.HasSeatbeltOn)
            {
                flags.Add(flags.Count > 0 ? ", seatbelt " : "Seatbelt ");
                flags.Add(CarNode.SeatbeltOnActive ? "is on" : "is off");
            }

            if (CarNode.HasBlurredNodes)
            {
                flags.Add(flags.Count > 0 ? ", blurred " : "Blurred ");
                flags.Add(CarNode.BlurredNodesActive ? "objects visible" : "objects hidden");
            }

            if (flags.Count > 0)
            {
                _textBlock.DrawString(flags.JoinToString(),
                                      new RectangleF(0f, 0f, ActualWidth, ActualHeight - offset),
                                      TextAlignment.HorizontalCenter | TextAlignment.Bottom, 16f, UiColor,
                                      CoordinateType.Absolute);
                offset += 20;
            }

            if (CarNode.Skins != null && CarNode.CurrentSkin != null)
            {
                _textBlock.DrawString($"{CarNode.CurrentSkin} ({CarNode.Skins.IndexOf(CarNode.CurrentSkin) + 1}/{CarNode.Skins.Count})",
                                      new RectangleF(0f, 0f, ActualWidth, ActualHeight - offset),
                                      TextAlignment.HorizontalCenter | TextAlignment.Bottom, 16f, UiColor,
                                      CoordinateType.Absolute);
            }
        }
Exemple #6
0
 /// <summary>
 /// Rendert den angegebenen Text an der angegebenen Position in der angegebenen
 /// Farbe.
 /// </summary>
 /// <param name="text">
 /// Der Text.
 /// </param>
 /// <param name="position">
 /// Die Position in absoluten Koordinaten.
 /// </param>
 /// <param name="color">
 /// Die Farbe in der der Text gezeichnet werden soll.
 /// </param>
 public void DrawString(string text, Vector2 position, Color color)
 {
     font.DrawString(text, position, color);
 }
Exemple #7
0
 public void DrawString(string text, Vector2 position, float realFontSize, Color4 color)
 {
     Monitor.Enter(DeviceManager.Instance.device);
     _textBlockRenderer.DrawString(text, position, realFontSize, color, CoordinateType.Absolute);
     Monitor.Exit(DeviceManager.Instance.device);
 }
Exemple #8
0
        void DrawBmp(SwapChain swapChain, Texture2D texture)
        {
            SpriteRenderer sprite = new SpriteRenderer(texture.Device);

            //            var srv = new ShaderResourceView(texture.Device,
            //                                             Texture2D.FromFile(texture.Device, "S:\\Downloads\font.jpg"));

            //            sprite.Draw(srv, new Vector2(30, 30), new Vector2(50, 50), CoordinateType.Absolute);

            var myTextBlockRenderer = new TextBlockRenderer(sprite, "Arial", FontWeight.Bold, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 12);
            myTextBlockRenderer.DrawString("Example Text", Vector2.Zero, Color.White);

            sprite.Flush();
        }