コード例 #1
0
        public TumbleCubeControl(InteractionLayer interactionLayer, ThemeConfig theme)
            : base(100 * GuiWidget.DeviceScale, 100 * GuiWidget.DeviceScale)
        {
            this.theme            = theme;
            this.interactionLayer = interactionLayer;

            // this data needs to be made on the ui thread
            UiThread.RunOnIdle(() =>
            {
                cube.CleanAndMergeMesh(CancellationToken.None);
                TextureFace(cube.Faces[0], "Top");
                TextureFace(cube.Faces[1], "Left", Matrix4X4.CreateRotationZ(MathHelper.Tau / 4));
                TextureFace(cube.Faces[2], "Right", Matrix4X4.CreateRotationZ(-MathHelper.Tau / 4));
                TextureFace(cube.Faces[3], "Bottom", Matrix4X4.CreateRotationZ(MathHelper.Tau / 2));
                TextureFace(cube.Faces[4], "Back", Matrix4X4.CreateRotationZ(MathHelper.Tau / 2));
                TextureFace(cube.Faces[5], "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.CreateTraceData();
            });

            MouseLeave += (s, e) =>
            {
                ResetTextures();
            };
        }
コード例 #2
0
        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 p in items)
                    {
                        InteractionLayer.RenderBounds(e, world, p.Matrix, p.BvhItem, i++);
                    }
                }
            }
        }
コード例 #3
0
 public static void RenderBounds(DrawEventArgs e, WorldView world, IEnumerable <BvhIterator> allResults)
 {
     foreach (var bvhIterator in allResults)
     {
         InteractionLayer.RenderBounds(e, world, bvhIterator.TransformToWorld, bvhIterator.Bvh, bvhIterator.Depth);
     }
 }
コード例 #4
0
        public GridOptionsPanel(InteractionLayer interactionLayer, ThemeConfig theme)
            : base(theme)
        {
            this.interactionLayer = interactionLayer;
            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;
        }
コード例 #5
0
        public GridOptionsPanel(InteractionLayer interactionLayer) : base(FlowDirection.TopToBottom)
        {
            var theme = ApplicationController.Instance.Theme;

            this.HAnchor = HAnchor.MaxFitOrStretch;

            this.AddChild(new TextWidget("Snap Grid".Localize())
            {
                Margin    = new BorderDouble(35, 2, 8, 8),
                TextColor = Color.Gray,
                HAnchor   = HAnchor.Left
            });

            var snapSettings = new Dictionary <double, string>()
            {
                { 0, "Off" },
                { .1, "0.1" },
                { .25, "0.25" },
                { .5, "0.5" },
                { 1, "1" },
                { 2, "2" },
                { 5, "5" },
            };

            var dropDownList = new DropDownList("Custom", theme.Colors.PrimaryTextColor, Direction.Down, pointSize: theme.DefaultFontSize)
            {
                TextColor   = Color.Black,
                Margin      = new BorderDouble(35, 15, 35, 5),
                HAnchor     = HAnchor.Left,
                BorderColor = theme.GetBorderColor(75)
            };

            foreach (var snapSetting in snapSettings)
            {
                MenuItem newItem = dropDownList.AddItem(snapSetting.Value);
                if (interactionLayer.SnapGridDistance == snapSetting.Key)
                {
                    dropDownList.SelectedLabel = snapSetting.Value;
                }

                newItem.Selected += (sender, e) =>
                {
                    interactionLayer.SnapGridDistance = snapSetting.Key;
                };
            }
            this.AddChild(dropDownList);
        }
コード例 #6
0
        public void Draw(GuiWidget sender, DrawEventArgs e, Matrix4X4 itemMaxtrix, WorldView world)
        {
            // RenderSceneTraceData
            var bvhIterator = new BvhIterator(scene?.TraceData(), decentFilter: (x) =>
            {
                var center      = x.Bvh.GetCenter();
                var worldCenter = Vector3Ex.Transform(center, x.TransformToWorld);
                if (worldCenter.Z > 0)
                {
                    return(true);
                }

                return(false);
            });

            InteractionLayer.RenderBounds(e, world, bvhIterator);
        }
コード例 #7
0
        public TumbleCubeControl(InteractionLayer interactionLayer)
            : base(100 * GuiWidget.DeviceScale, 100 * GuiWidget.DeviceScale)
        {
            this.interactionLayer = interactionLayer;

            // this data needs to be made on the ui thread
            UiThread.RunOnIdle(() =>
            {
                cube.CleanAndMergeMesh(CancellationToken.None);
                TextureFace(cube.Faces[0], "Top");
                TextureFace(cube.Faces[1], "Left", Matrix4X4.CreateRotationZ(MathHelper.Tau / 4));
                TextureFace(cube.Faces[2], "Right", Matrix4X4.CreateRotationZ(-MathHelper.Tau / 4));
                TextureFace(cube.Faces[3], "Bottom", Matrix4X4.CreateRotationZ(MathHelper.Tau / 2));
                TextureFace(cube.Faces[4], "Back", Matrix4X4.CreateRotationZ(MathHelper.Tau / 2));
                TextureFace(cube.Faces[5], "Front");
                cube.MarkAsChanged();

                cubeTraceData = cube.CreateTraceData();
            });
        }
コード例 #8
0
        public RenderOptionsButton(ThemeConfig theme, InteractionLayer interactionLayer)
            : base(theme)
        {
            this.HAnchor = HAnchor.Fit;
            this.VAnchor = VAnchor.Fit;

            this.AddChild(new IconButton(AggContext.StaticData.LoadIcon("web.png", 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.InteractionLayer.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.InteractionLayer.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);
            };
        }