Mini map plugin?

Is it possible to create a minimap with python script and make it a part of rendering? Anybody has seen/has experience with minimap in the Visual component before?

Cool idea, sounds interesting!

With .NET API it is possible to create separate new viewports and then place them somewhere in the UI.
Of course you would be doubling your rendering load if you just render a topdown view of the world.

1 Like

Do you have more information how a second viewport can be made?
I tried earlier, but only 1 worked, as soon as I opened a new viewport, the first stopped rendering.

You would need to use .NET API. The view could either be separate panel or UI overlay. Generally, the mini map is a fixed camera position with top-down view. I have never used VC view of layout in panel. You could try to use WPF 2D or 3D control and sync it with layout and camera, but depends on how much detail is supposed to be in your minimap. If you expect same rendering and shading then I would use .NET API.

1 Like

Hy,

what die mean with minimap?

Thx & Regards
Feature

UI overlay? Does it mean I can place a canvas on top of the main 3D viewport? If yes, do you have .NET API sample code for this? Thank you.

Contact support. I don’t remember if there is SDK example, but there is overlay example mentioned in the development guide. Some overlays you currently see are the View Manipulator (the thing in bottom left corner of viewport for changing your view) and the manipulators for moving and jogging robot.

Cool, will do , thank you.

https://youtu.be/JHGLwDiJOQI

Done with .NET API, thanks to OP’s idea and VC’s API, useful tool, makes me think of StarCraft good old time.

2 Likes

You are amazing! Could you make a tutorial for that? It will be helpful for a newbie like me to develop plugin script for VC

Sure.

  1. Create background plugin
    https://academy.visualcomponents.com/lessons/add-a-background-plugin/

  2. Add canvas over viewport
    VC support sent me the sample code, how to add canvas over viewport.

using System.Windows.Controls;
using System.Windows.Media;
using VisualComponents.Create3D;
using VisualComponents.UX;
using VisualComponents.UX.Shared;
using VisualComponents.UX.Viewport;
{   
    [Export(typeof(IPlugin))]
    class ExportLayoutViewModel : IPlugin
    {
        public void Exit()
        {
            
        }
        public void Initialize()
        {
            var viewport = IoC.Get<IDirect3DViewportViewModel>();
            var myGrid = viewport.ControlGrid;
            var clear_btn = new Button();
            clear_btn.Content = "CLEAR";
            clear_btn.Background = Brushes.Gray;
            clear_btn.Foreground = Brushes.White;
            clear_btn.FontFamily = new FontFamily("Calibri Bold");
            clear_btn.Height = 30;
            clear_btn.Width = 50;
            clear_btn.Margin = new Thickness(10, 10, 10, 10);
            clear_btn.Click += clear_click;
            if (myGrid != null)
            {
                Canvas canvas = new Canvas
                {
                    //Background = Brushes.DeepSkyBlue,
                    Height = 40,
                    Width = 70,
                    HorizontalAlignment = HorizontalAlignment.Right,
                    VerticalAlignment = VerticalAlignment.Bottom,
                    Margin = new Thickness(0, 0, 0, 0),
                    ToolTip = "Clear output panel"
                };
                myGrid.Children.Add(canvas);
                canvas.Children.Add(clear_btn);
            }
        }
        private void clear_click(object sender, RoutedEventArgs e)
        {
            var console = IoC.Get<IConsoleViewModel>();
            console.Clear();
        }
    }

  1. Calculate relationship between VC components and canvas pixels
    You could either use System.Windows.Shapes.Rectangle or System.Windows.Shapes.Polygon or System.Windows.Shapes.Polyline, but no matter which one, need to handle orientation, or the minimap wont looks like the 3D top view. Then calculate the relationship between VC components and canvas pixels. Place the polygon to the correct position in canvas.

  2. Update Minimap
    Depend on your need, decide when to update Minimap.

app.LayoutModifiedChanged += App_LayoutModifiedChanged;
app.ComponentCreated += App_ComponentCreated;
render.OnRequestRender += Render_OnRequestRender;
  1. Update camera
    When your mouse PreviewMouseLeftButtonDown or PreviewMouseMove, update 3D world.
canvas.PreviewMouseLeftButtonDown += Canvas_PreviewMouseLeftButtonDown;
canvas.PreviewMouseMove += Canvas_PreviewMouseMove;

These are all about! The others are count on your own practice. :grinning_face_with_smiling_eyes:

4 Likes