public void Draw(GuiWidget sender, IObject3D item, bool isSelected, DrawEventArgs e, Matrix4X4 itemMaxtrix, WorldView world)
        {
            if (isSelected)
            {
                var center = item.GetAxisAlignedBoundingBox().Center;

                var traceData = item.GetBVHData();

                var xy = traceData.Contains(center);

                var items = traceData.FilterX(p =>
                {
                    var worldToAxis = Matrix4X4.Invert(p.WorldMatrix);

                    var localPoint = Vector3Ex.Transform(center, worldToAxis);
                    return(p.BvhItem.GetAxisAlignedBoundingBox().Contains(localPoint));
                }).ToArray();

                if (items.Any())
                {
                    int i = 0;
                    foreach (var(BvhItem, Matrix) in items)
                    {
                        Object3DControlsLayer.RenderBounds(e, world, Matrix, BvhItem, i++);
                    }
                }
            }
        }
 public static void RenderBounds(DrawEventArgs e, WorldView world, IEnumerable <BvhIterator> allResults)
 {
     foreach (var bvhIterator in allResults)
     {
         Object3DControlsLayer.RenderBounds(e, world, bvhIterator.TransformToWorld, bvhIterator.Bvh, bvhIterator.Depth);
     }
 }
Пример #3
0
        public TumbleCubeControl(Object3DControlsLayer object3DControlLayer, ThemeConfig theme, TrackballTumbleWidgetExtended trackballTumbleWidgetExtended)
            : base(100 * GuiWidget.DeviceScale, 100 * GuiWidget.DeviceScale)
        {
            this.theme = theme;
            this.object3DControlLayer          = object3DControlLayer;
            this.trackballTumbleWidgetExtended = trackballTumbleWidgetExtended;

            // this data needs to be made on the ui thread
            UiThread.RunOnIdle(() =>
            {
                TextureFace(0, "Top");
                TextureFace(2, "Left", Matrix4X4.CreateRotationZ(MathHelper.Tau / 4));
                TextureFace(4, "Right", Matrix4X4.CreateRotationZ(-MathHelper.Tau / 4));
                TextureFace(6, "Bottom", Matrix4X4.CreateRotationZ(MathHelper.Tau / 2));
                TextureFace(8, "Back", Matrix4X4.CreateRotationZ(MathHelper.Tau / 2));
                TextureFace(10, "Front");
                cube.MarkAsChanged();

                connections.Add(new ConnectedFaces(2, 1, 1, 5, 2, 4));
                connections.Add(new ConnectedFaces(0, -1, 4, 3, 5, 0));
                connections.Add(new ConnectedFaces(0, 1, 5, 3, 4, 0));
                connections.Add(new ConnectedFaces(2, -1, 1, 4, 2, 5));
                connections.Add(new ConnectedFaces(1, 1, 2, 3, 1, 0));
                connections.Add(new ConnectedFaces(1, -1, 1, 3, 2, 0));

                cubeTraceData = cube.CreateBVHData();
            });

            MouseLeave += (s, e) =>
            {
                ResetTextures();
            };
        }
 public TrackballTumbleWidgetExtended(WorldView world, GuiWidget sourceWidget, Object3DControlsLayer Object3DControlLayer, ThemeConfig theme)
 {
     AnchorAll();
     TrackBallController       = new TrackBallController(world);
     this.theme                = theme;
     this.world                = world;
     this.sourceWidget         = sourceWidget;
     this.Object3DControlLayer = Object3DControlLayer;
 }
Пример #5
0
        public GridOptionsPanel(Object3DControlsLayer object3DControlLayer, ThemeConfig theme)
            : base(theme)
        {
            this.object3DControlLayer = object3DControlLayer;
            this.PopupContent         = () => ShowGridOptions(theme);

            this.AddChild(new IconButton(AggContext.StaticData.LoadIcon("1694146.png", 16, 16, theme.InvertIcons), theme)
            {
                Selectable = false
            });
            this.HAnchor = HAnchor.Fit;
            this.VAnchor = VAnchor.Fit;
        }
Пример #6
0
        public void Draw(GuiWidget sender, DrawEventArgs e, Matrix4X4 itemMaxtrix, WorldView world)
        {
            // RenderSceneTraceData
            var bvhIterator = new BvhIterator(scene?.GetBVHData(), decentFilter: (x) =>
            {
                var center      = x.Bvh.GetCenter();
                var worldCenter = Vector3Ex.Transform(center, x.TransformToWorld);
                if (worldCenter.Z > 0)
                {
                    return(true);
                }

                return(false);
            });

            Object3DControlsLayer.RenderBounds(e, world, bvhIterator);
        }
Пример #7
0
        public GridOptionsPanel(Object3DControlsLayer object3DControlLayer, ThemeConfig theme)
            : base(theme)
        {
            this.object3DControlLayer = object3DControlLayer;
            this.PopupContent         = () => ShowGridOptions(theme);

            var gridDistance = object3DControlLayer.SnapGridDistance;

            textButton = this.AddChild(new TextButton(gridDistance.ToString(), theme)
            {
                Selectable = false,
                HAnchor    = HAnchor.Center
            });
            this.VAnchor = VAnchor.Fit;
            // make sure the button is square
            this.Width = this.Height;

            UserSettings.Instance.SettingChanged += UserSettings_SettingChanged;

            SetToolTip();
        }
Пример #8
0
        public RenderOptionsButton(ThemeConfig theme, Object3DControlsLayer object3DControlLayer)
            : base(theme)
        {
            this.HAnchor = HAnchor.Fit;
            this.VAnchor = VAnchor.Fit;

            this.AddChild(new IconButton(StaticData.Instance.LoadIcon("web.png", 16, 16, theme.InvertIcons), theme)
            {
                Selectable = false
            });

            this.PopupContent = () =>
            {
                var menuTheme = AppContext.MenuTheme;

                var subPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
                {
                    Padding         = theme.DefaultContainerPadding,
                    BackgroundColor = menuTheme.BackgroundColor,
                    HAnchor         = HAnchor.Absolute,
                    VAnchor         = VAnchor.Fit
                };

                subPanel.BoundsChanged += (s, e) =>
                {
                    Console.WriteLine();
                };

                foreach (var drawable in ApplicationController.Instance.DragDropData.View3DWidget.Object3DControlLayer.Drawables)
                {
                    var row = new SettingsRow(drawable.Title, drawable.Description, theme);
                    subPanel.AddChild(row);

                    var toggleSwitch = new RoundedToggleSwitch(theme)
                    {
                        Checked = drawable.Enabled
                    };
                    toggleSwitch.CheckedStateChanged += (s, e) =>
                    {
                        drawable.Enabled = toggleSwitch.Checked;
                    };
                    row.AddChild(toggleSwitch);
                }

                foreach (var drawable in ApplicationController.Instance.DragDropData.View3DWidget.Object3DControlLayer.ItemDrawables)
                {
                    var row = new SettingsRow(drawable.Title, drawable.Description, theme);
                    subPanel.AddChild(row);

                    var toggleSwitch = new RoundedToggleSwitch(theme)
                    {
                        Checked = drawable.Enabled
                    };
                    toggleSwitch.CheckedStateChanged += (s, e) =>
                    {
                        drawable.Enabled = toggleSwitch.Checked;
                    };
                    row.AddChild(toggleSwitch);
                }

                subPanel.Width = 400;

                return(subPanel);
            };
        }