Esempio n. 1
0
        // creates navigation mode toggle group
        void AddNavModeToggleGroup(Cockpit cockpit)
        {
            float h  = 25.0f;
            float dh = 13.0f;
            float v  = -50.0f;
            float dv = 13.0f;

            HUDToggleButton tumbleButton = HUDBuilder.CreateToggleButton(
                fDiscButtonRadius1, fCockpitRadiusButton, h, v,
                "cockpit_icons/view_controls/bunny_enabled", "cockpit_icons/view_controls/bunny_disabled",
                new IconMeshGenerator()
            {
                Path      = "icon_meshes/camera",
                Scale     = 0.07f, Color = ColorUtil.make(30, 30, 30),
                Translate = new Vector3(0.04f, -0.07f, 0.04f),
                Rotate    = Quaternion.AngleAxis(30.0f, Vector3.up) * Quaternion.AngleAxis(-90.0f, Vector3.right)
            }
                );

            tumbleButton.Name = "tumbleNavMode";
            cockpit.AddUIElement(tumbleButton, true);

            HUDToggleButton flyButton = HUDBuilder.CreateToggleButton(
                fDiscButtonRadius1, fCockpitRadiusButton, h + dh, v,
                "cockpit_icons/view_controls/sponza_enabled", "cockpit_icons/view_controls/sponza_disabled");

            flyButton.Name = "flyNavMode";
            cockpit.AddUIElement(flyButton, true);

            HUDToggleGroup group = new HUDToggleGroup();

            group.AddButton(tumbleButton);
            group.AddButton(flyButton);
            group.Selected   = 1;
            group.OnToggled += (sender, nSelected) => {
                if (nSelected == 0)
                {
                    cockpit.Context.MouseCameraController = new MayaCameraHotkeys();
                }
                else
                {
                    cockpit.Context.MouseCameraController = new RateControlledEgocentricCamera();
                }
            };

            // set initial state
            group.Selected = 0;


            HUDButton resetButton = HUDBuilder.CreateRectIconClickButton(
                0.1f, 0.05f, 0.7f, h + 0.3f * dh, v - 0.7f * dv,
                "icons/reset_v1");

            resetButton.Name = "export";
            cockpit.AddUIElement(resetButton, true);
            resetButton.OnClicked += (s, e) => {
                cockpit.Context.ResetView(true);
            };
        }
Esempio n. 2
0
        void AddTransformToolToggleGroup(Cockpit cockpit)
        {
            float va      = -42.0f;
            float vb      = -32.0f;
            float vbdelta = 12.0f;

            HUDToggleButton widgetButton = HUDBuilder.CreateToggleButton(
                fDiscButtonRadius1, fCockpitRadiusButton, vb - vbdelta, va,
                "cockpit_icons/transform_modes/transformmode_widget_enabled_v1",
                "cockpit_icons/transform_modes/transformmode_widget_disabled_v1");

            widgetButton.Name = "transformWidgetToggle";
            cockpit.AddUIElement(widgetButton, true);

            HUDToggleButton snapButton = HUDBuilder.CreateToggleButton(
                fDiscButtonRadius1, fCockpitRadiusButton, vb, va,
                "cockpit_icons/transform_modes/transformmode_snap_enabled_v1",
                "cockpit_icons/transform_modes/transformmode_snap_disabled_v1");

            snapButton.Name = "transformSnapToggle";
            cockpit.AddUIElement(snapButton, true);

            HUDToggleButton editButton = HUDBuilder.CreateToggleButton(
                fDiscButtonRadius1, fCockpitRadiusButton, vb + vbdelta, va,
                "cockpit_icons/transform_modes/transformmode_edit_enabled_v1",
                "cockpit_icons/transform_modes/transformmode_edit_disabled_v1");

            editButton.Name = "transformEditToggle";
            cockpit.AddUIElement(editButton, true);


            HUDToggleGroup group = new HUDToggleGroup();

            group.AddButton(widgetButton);
            group.AddButton(snapButton);
            group.AddButton(editButton);
            group.Selected   = 0;
            group.OnToggled += (sender, nSelected) => {
                if (nSelected == 1)
                {
                    cockpit.Context.TransformManager.SetActiveGizmoType("snap_drag");
                }
                else if (nSelected == 2)
                {
                    cockpit.Context.TransformManager.SetActiveGizmoType("object_edit");
                }
                else
                {
                    cockpit.Context.TransformManager.SetActiveGizmoType("default");
                }
            };
            // [TODO] remember last setting? per object?
        }
Esempio n. 3
0
        // creates world/local frame toggle buttons, that are grouped so clicking
        // one disables the other. Connect up to TransformManager for events/etc.
        void AddFrameToggleGroup(Cockpit cockpit)
        {
            HUDToggleButton worldButton = HUDBuilder.CreateToggleButton(
                fDiscButtonRadius1, fCockpitRadiusButton, -38.0f, -50.0f,
                "icons/frame_world_enabled", "icons/frame_world_disabled",
                new IconMeshGenerator()
            {
                Path  = "icon_meshes/axis_frame",
                Scale = 0.08f, Translate = new Vector3(0.06f, -0.06f, 0.05f), Color = ColorUtil.ForestGreen
            }
                );

            worldButton.Name = "worldFrameToggle";
            cockpit.AddUIElement(worldButton, true);

            HUDToggleButton localButton = HUDBuilder.CreateToggleButton(
                fDiscButtonRadius1, fCockpitRadiusButton, -25.0f, -50.0f, "icons/frame_local_enabled", "icons/frame_local_disabled");

            localButton.Name = "localFrameToggle";
            cockpit.AddUIElement(localButton, true);

            HUDToggleGroup group = new HUDToggleGroup();

            group.AddButton(worldButton);
            group.AddButton(localButton);
            group.Selected   = 1;
            group.OnToggled += (sender, nSelected) => {
                FrameType eSetType = (nSelected == 0) ?
                                     FrameType.WorldFrame : FrameType.LocalFrame;
                cockpit.Context.TransformManager.ActiveFrameType = eSetType;
            };
            cockpit.Context.TransformManager.OnActiveGizmoModified += (s, e) => {
                FrameType eSet = cockpit.Context.TransformManager.ActiveFrameType;
                group.Selected = (eSet == FrameType.WorldFrame) ? 0 : 1;
            };

            // set initial state
            FrameType eInitial = cockpit.Context.TransformManager.ActiveFrameType;

            group.Selected = (eInitial == FrameType.WorldFrame) ? 0 : 1;
        }
Esempio n. 4
0
        public void Initialize(Cockpit cockpit)
        {
            cockpit.Name = "cadSceneCockpit";

            // configure tracking
            SmoothCockpitTracker.Enable(cockpit);
            cockpit.TiltAngle = 10.0f;


            RegisterMessageHandlers(cockpit);

            // set up sphere layout
            SphereBoxRegion region3d = new SphereBoxRegion()
            {
                Radius           = fCockpitRadiusPanel,
                HorzDegreeLeft   = 50.0f, HorzDegreeRight = 15.0f,
                VertDegreeBottom = 40.0f, VertDegreeTop = 15.0f
            };
            BoxContainer uiContainer             = new BoxContainer(new BoxRegionContainerProvider(cockpit, region3d));
            PinnedBoxes3DLayoutSolver layoutCalc = new PinnedBoxes3DLayoutSolver(uiContainer, region3d);
            PinnedBoxesLayout         layout     = new PinnedBoxesLayout(cockpit, layoutCalc)
            {
                StandardDepth = 0   // widgets are on sphere
            };

            cockpit.AddLayout(layout, "PrimarySphere", true);


            HUDToggleGroup panelGroup = BuildPanels(cockpit);


            //BuildParameterPanel(cockpit);


            try {
                AddUndoRedo(cockpit);
                AddTransformToolToggleGroup(cockpit);
                AddFrameToggleGroup(cockpit);
                AddNavModeToggleGroup(cockpit);
                AddMenuButtonsGroup(cockpit);
            } catch (Exception e) {
                Debug.Log("[SetupCADCockpit.Initialize::buttons/etc] exception: " + e.Message);
            }

            // setup key handlers (need to move to behavior...)
            cockpit.AddKeyHandler(new CADKeyHandler(cockpit.Context)
            {
                PanelGroup = panelGroup
            });

            // setup mouse handling
            cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context)
            {
                Priority = 0
            });
            cockpit.InputBehaviors.Add(new VRGamepadUIBehavior(cockpit.Context)
            {
                Priority = 0
            });
            cockpit.InputBehaviors.Add(new VRSpatialDeviceUIBehavior(cockpit.Context)
            {
                Priority = 0
            });

            cockpit.InputBehaviors.Add(new TwoHandViewManipBehavior(cockpit)
            {
                Priority = 1
            });
            //cockpit.InputBehaviors.Add(new SpatialDeviceGrabViewBehavior(cockpit) { Priority = 2 });
            cockpit.InputBehaviors.Add(new SpatialDeviceViewManipBehavior(cockpit)
            {
                Priority = 2
            });

            RemoteGrabBehavior grabBehavior = new RemoteGrabBehavior(cockpit)
            {
                Priority = 5
            };
            SecondaryGrabBehavior secondGrab = new SecondaryGrabBehavior(cockpit, grabBehavior)
            {
                Priority = 4
            };

            grabBehavior.OnEndGrab += (sender, target) => {
                if (secondGrab.InGrab && secondGrab.GrabbedSO is GroupSO)
                {
                    cockpit.Context.RegisterNextFrameAction(() => {
                        GroupSO group           = secondGrab.GrabbedSO as GroupSO;
                        AddToGroupChange change = new AddToGroupChange(cockpit.Scene, group, target);
                        cockpit.Scene.History.PushChange(change, false);
                        cockpit.Scene.ClearSelection();
                        cockpit.Scene.Select(group, false);
                    });
                }
            };

            cockpit.InputBehaviors.Add(secondGrab);
            cockpit.InputBehaviors.Add(grabBehavior);

            cockpit.InputBehaviors.Add(new MouseMultiSelectBehavior(cockpit.Context)
            {
                Priority = 10
            });
            cockpit.InputBehaviors.Add(new GamepadMultiSelectBehavior(cockpit.Context)
            {
                Priority = 10
            });
            cockpit.InputBehaviors.Add(new SpatialDeviceMultiSelectBehavior(cockpit.Context)
            {
                Priority = 10
            });

            cockpit.InputBehaviors.Add(new MouseDeselectBehavior(cockpit.Context)
            {
                Priority = 999
            });
            cockpit.InputBehaviors.Add(new GamepadDeselectBehavior(cockpit.Context)
            {
                Priority = 999
            });
            cockpit.InputBehaviors.Add(new SpatialDeviceDeselectBehavior(cockpit.Context)
            {
                Priority = 999
            });

            cockpit.InputBehaviors.Add(new SceneRightClickBehavior(cockpit)
            {
                Priority = 20
            });
            cockpit.InputBehaviors.Add(new ClearBehavior(cockpit.Context)
            {
                Priority = 999
            });
            cockpit.InputBehaviors.Add(new UndoShortcutBehavior(cockpit.Context)
            {
                Priority = 999
            });

            cockpit.InputBehaviors.Add(new StickCycleBehavior(cockpit.Context)
            {
                Priority = 999, Side = CaptureSide.Left,
                Cycle    = (n) => { panelGroup.SelectModulo(panelGroup.Selected - n); }
            });


            //cockpit.OverrideBehaviors.Add(new ScreenCaptureBehavior() { Priority = 0,
            //    ScreenshotPath = Environment.GetEnvironmentVariable("homepath") + "\\DropBox\\ScreenShots\\" });
            cockpit.OverrideBehaviors.Add(new FBEncoderCaptureBehavior()
            {
                Priority       = 0,
                ScreenshotPath = Environment.GetEnvironmentVariable("homepath") + "\\DropBox\\ScreenShots\\"
            });

            // start auto-update check
            AutoUpdate.DoUpdateCheck(cockpit, 10.0f);
        }
Esempio n. 5
0
        HUDToggleGroup BuildPanels(Cockpit cockpit)
        {
            float vx = -50.0f;
            float vy = 10.0f;

            float fButtonW = fDiscButtonRadius1;


            HUDPrimitivesPanel primPanel = new HUDPrimitivesPanel();

            primPanel.Create(cockpit);
            primPanel.Name = "PrimitivesPanel";
            cockpit.AddUIElement(primPanel, true);

            HUDToolsPanel toolPanel = new HUDToolsPanel();

            toolPanel.Create(cockpit);
            toolPanel.Name = "ToolPanel";
            cockpit.AddUIElement(toolPanel, true);
            toolPanel.IsVisible = false;

            HUDMaterialsPanel matPanel = new HUDMaterialsPanel();

            matPanel.Create(cockpit);
            matPanel.Name = "MaterialPanel";
            cockpit.AddUIElement(matPanel, true);
            matPanel.IsVisible = false;

            float fIconAspect = 1.25f;

            HUDToggleButton materialsButton = HUDBuilder.CreateToggleButton(
                new HUDShape(HUDShapeType.Rectangle, fButtonW, fButtonW / fIconAspect)
            {
                UseUVSubRegion = true
            },
                fCockpitRadiusButton, vx, vy,
                "panel_tabs/materials_active_v1", "panel_tabs/materials_inactive_v1");

            UnityUtil.TranslateInFrame(materialsButton.RootGameObject, -fButtonW * 1.5f, 0, 0, CoordSpace.WorldCoords);
            materialsButton.Name = "toggleMaterials";
            cockpit.AddUIElement(materialsButton, true);

            HUDToggleButton toolsButton = HUDBuilder.CreateToggleButton(
                new HUDShape(HUDShapeType.Rectangle, fButtonW, fButtonW / fIconAspect)
            {
                UseUVSubRegion = true
            },
                fCockpitRadiusButton, vx, vy,
                "panel_tabs/tools_active_v1", "panel_tabs/tools_inactive_v1");

            UnityUtil.TranslateInFrame(toolsButton.RootGameObject, -fButtonW * 0.5f, 0, 0, CoordSpace.WorldCoords);
            toolsButton.Name = "toggleTools";
            cockpit.AddUIElement(toolsButton, true);


            HUDToggleButton shapesButton = HUDBuilder.CreateToggleButton(
                new HUDShape(HUDShapeType.Rectangle, fButtonW, fButtonW / fIconAspect)
            {
                UseUVSubRegion = true
            },
                fCockpitRadiusButton, vx, vy,
                "panel_tabs/shapes_active_v1", "panel_tabs/shapes_inactive_v1");

            UnityUtil.TranslateInFrame(shapesButton.RootGameObject, fButtonW * 0.5f, 0, 0, CoordSpace.WorldCoords);
            shapesButton.Name = "toggleShapes";
            cockpit.AddUIElement(shapesButton, true);

            HUDToggleGroup group = new HUDToggleGroup();

            group.AddButton(shapesButton);
            group.AddButton(toolsButton);
            group.AddButton(materialsButton);
            group.Selected   = 0;
            group.OnToggled += (sender, nSelected) => {
                if (nSelected == 0)
                {
                    matPanel.IsVisible  = toolPanel.IsVisible = false;
                    primPanel.IsVisible = true;
                }
                else if (nSelected == 1)
                {
                    primPanel.IsVisible = matPanel.IsVisible = false;
                    toolPanel.IsVisible = true;
                }
                else
                {
                    primPanel.IsVisible = toolPanel.IsVisible = false;
                    matPanel.IsVisible  = true;
                }
            };

            return(group);
        }
Esempio n. 6
0
 public void AddToGroup(HUDToggleGroup group)
 {
     Debug.Assert(parentGroup == null);
     parentGroup = group;
 }
        public void Initialize(Cockpit cockpit)
        {
            cockpit.Name = "splashCockpit";
            cockpit.DefaultCursorDepth = 3.0f;
            cockpit.PositionMode       = Cockpit.MovementMode.Static;

            // create black sphere around camera to hide existing scene
            fGameObject blackBackground = new fGameObject(
                UnityUtil.CreateMeshGO("background_delete", "icon_meshes/inverted_sphere_tiny", 1.0f,
                                       UnityUtil.MeshAlignOption.AllAxesCentered, MaterialUtil.CreateFlatMaterial(Color.black), false));

            // add as bounds object to do mouse hit-test
            cockpit.Context.Scene.AddWorldBoundsObject(blackBackground);

            // re-parent from Scene so the sphere tracks the camera
            cockpit.FixedCameraTrackingGO.AddChild(blackBackground, false);

            HUDButton title = HUDBuilder.CreateIconClickButton(
                new HUDShape(HUDShapeType.Rectangle, 2.0f, 0.8f),
                3.0f, 0.0f, 2.5f, "simplex_startup/simplex_v2");

            title.Name    = "title";
            title.Enabled = false;
            cockpit.AddUIElement(title, true);

            HUDButton start = HUDBuilder.CreateIconClickButton(
                new HUDShape(HUDShapeType.Rectangle, 0.5f, 0.25f),
                3.0f, 8.0f, -10, "simplex_startup/start_v1");

            start.Name       = "start";
            start.OnClicked += (s, e) => {
                cockpit.ActiveCamera.Animator().DoActionDuringDipToBlack(() => {
                    cockpit.Context.Scene.RemoveWorldBoundsObject(blackBackground);
                    UnityEngine.GameObject.Destroy(blackBackground);
                    cockpit.Context.PushCockpit(
                        new SetupCADCockpit_V1());
                }, 1.0f);
            };
            cockpit.AddUIElement(start, true);

            HUDButton quit = HUDBuilder.CreateIconClickButton(
                new HUDShape(HUDShapeType.Rectangle, 0.5f, 0.25f),
                3.0f, -8.0f, -10, "simplex_startup/quit_v1");

            quit.Name       = "quit";
            quit.OnClicked += (s, e) => {
                FPlatform.QuitApplication();
            };
            cockpit.AddUIElement(quit, true);

            HUDButton logo = HUDBuilder.CreateIconClickButton(
                new HUDShape(HUDShapeType.Rectangle, 0.8f, 0.2f),
                3.0f, 0.0f, -25.0f, "simplex_startup/gradientspace_splash");

            logo.Name    = "logo";
            logo.Enabled = false;
            cockpit.AddUIElement(logo, true);



            HUDButton about_arrow = HUDBuilder.CreateIconClickButton(
                new HUDShape(HUDShapeType.Rectangle, 0.75f, 0.75f),
                3.0f, -30.0f, -10.0f, "simplex_startup/about_arrow");

            about_arrow.Name    = "about_arrow";
            about_arrow.Enabled = false;
            cockpit.AddUIElement(about_arrow, true);


            float     about_text_scale = 3.0f;
            float     angle_left       = -65.0f;
            HUDButton about_text       = HUDBuilder.CreateIconClickButton(
                new HUDShape(HUDShapeType.Rectangle,
                             0.8f * about_text_scale, 1.0f * about_text_scale)
            {
                UseUVSubRegion = false
            },
                3.0f, angle_left, 0.0f, "simplex_startup/about_text");

            UnityUtil.TranslateInFrame(about_text.RootGameObject, 0.0f, -0.5f, 0, CoordSpace.WorldCoords);
            about_text.Name    = "about_text";
            about_text.Enabled = false;
            cockpit.AddUIElement(about_text, true);



            HUDButton controls_arrow = HUDBuilder.CreateIconClickButton(
                new HUDShape(HUDShapeType.Rectangle, 0.75f, 0.75f),
                3.0f, 30.0f, -10.0f, "simplex_startup/controls_arrow");

            controls_arrow.Name    = "controls_arrow";
            controls_arrow.Enabled = false;
            cockpit.AddUIElement(controls_arrow, true);



            float     text_scale     = 3.0f;
            float     angle_right    = 65.0f;
            HUDButton controls_mouse = HUDBuilder.CreateIconClickButton(
                new HUDShape(HUDShapeType.Rectangle, 0.7f * text_scale, 0.7f * text_scale)
            {
                UseUVSubRegion = false
            },
                3.0f, angle_right, 0.0f, "simplex_startup/controls_mouse");

            UnityUtil.TranslateInFrame(controls_mouse.RootGameObject, 0.25f, 0.1f, 0, CoordSpace.WorldCoords);
            controls_mouse.Name    = "controls_mouse";
            controls_mouse.Enabled = false;
            cockpit.AddUIElement(controls_mouse, true);

            HUDButton controls_gamepad = HUDBuilder.CreateIconClickButton(
                new HUDShape(HUDShapeType.Rectangle, 0.7f * text_scale, 0.7f * text_scale)
            {
                UseUVSubRegion = false
            },
                3.0f, angle_right, 0.0f, "simplex_startup/controls_gamepad");

            UnityUtil.TranslateInFrame(controls_gamepad.RootGameObject, 0.25f, 0.1f, 0, CoordSpace.WorldCoords);
            controls_gamepad.Name    = "controls_gamepad";
            controls_gamepad.Enabled = false;
            cockpit.AddUIElement(controls_gamepad, true);
            controls_gamepad.RootGameObject.Hide();



            HUDToggleButton mouse_button = HUDBuilder.CreateToggleButton(
                new HUDShape(HUDShapeType.Rectangle, 1.0f, 1.0f),
                2.9f, angle_right, 0.0f, "simplex_startup/mouse", "simplex_startup/mouse_disabled");

            UnityUtil.TranslateInFrame(mouse_button.RootGameObject, -0.5f, -1.0f, 0, CoordSpace.WorldCoords);
            mouse_button.Name = "mouse_button";
            cockpit.AddUIElement(mouse_button, true);

            HUDToggleButton gamepad_button = HUDBuilder.CreateToggleButton(
                new HUDShape(HUDShapeType.Rectangle, 1.0f, 1.0f),
                2.9f, angle_right, 0.0f, "simplex_startup/gamepad_with_labels", "simplex_startup/gamepad_disabled");

            UnityUtil.TranslateInFrame(gamepad_button.RootGameObject, 0.5f, -1.0f, 0, CoordSpace.WorldCoords);
            gamepad_button.Name = "gamepad_button";
            cockpit.AddUIElement(gamepad_button, true);


            HUDToggleGroup group = new HUDToggleGroup();

            group.AddButton(mouse_button);
            group.AddButton(gamepad_button);
            group.Selected   = 0;
            group.OnToggled += (sender, nSelected) => {
                if (nSelected == 0)
                {
                    controls_gamepad.RootGameObject.Hide();
                    controls_mouse.RootGameObject.Show();
                }
                else
                {
                    controls_gamepad.RootGameObject.Show();
                    controls_mouse.RootGameObject.Hide();
                }
            };



            // setup key handlers (need to move to behavior...)
            cockpit.AddKeyHandler(new SplashScreenKeyHandler(cockpit.Context));

            cockpit.InputBehaviors.Add(new VRMouseUIBehavior(cockpit.Context)
            {
                Priority = 0
            });
            cockpit.InputBehaviors.Add(new VRGamepadUIBehavior(cockpit.Context)
            {
                Priority = 0
            });
            cockpit.InputBehaviors.Add(new VRSpatialDeviceUIBehavior(cockpit.Context)
            {
                Priority = 0
            });
        }