コード例 #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);
            };
        }
コード例 #2
0
        public void add_text_entry_field(Cockpit cockpit)
        {
            float fUseRadius = HUDRadius * 0.85f;
            float fAngle     = -35.0f;

            entryField            = new HUDTextEntry();
            entryField.Text       = GetDefaultFileName();
            entryField.Width      = 1.0f;
            entryField.Height     = 0.08f;
            entryField.TextHeight = 0.06f;
            entryField.Create();
            entryField.Name = "selectFileName";
            HUDUtil.PlaceInSphere(entryField, fUseRadius, 0.0f, fAngle);
            cockpit.AddUIElement(entryField, true);

            tooltipText                 = new HUDLabel();
            tooltipText.Shape           = new HUDShape(HUDShapeType.Rectangle, 1.0f, 0.04f);
            tooltipText.Text            = Tooltip;
            tooltipText.TextHeight      = 0.03f;
            tooltipText.BackgroundColor = Colorf.TransparentBlack;
            tooltipText.TextColor       = Colorf.Silver;
            tooltipText.Create();
            tooltipText.Name = "tooltip";
            HUDUtil.PlaceInSphere(tooltipText, fUseRadius, 0.0f, fAngle);
            UnityUtil.TranslateInFrame(tooltipText.RootGameObject, 0.0f, -entryField.Height, 0, CoordSpace.WorldCoords);
            cockpit.AddUIElement(tooltipText, true);


            HUDButton saveButton = HUDBuilder.CreateRectIconClickButton(
                0.2f, 0.1f, fUseRadius, 0.0f, fAngle,
                "icons/save_v1");

            UnityUtil.TranslateInFrame(saveButton.RootGameObject, 0.2f, -0.1f, 0, CoordSpace.WorldCoords);
            saveButton.Name = "save";
            cockpit.AddUIElement(saveButton, true);
            saveButton.OnClicked += (s, e) => { SaveFromEntryText(); };

            HUDButton cancelButton = HUDBuilder.CreateRectIconClickButton(
                0.2f, 0.1f, fUseRadius, 0.0f, fAngle,
                "icons/cancel_v1");

            UnityUtil.TranslateInFrame(cancelButton.RootGameObject, 0.4f, -0.1f, 0, CoordSpace.WorldCoords);
            cancelButton.Name = "cancel";
            cockpit.AddUIElement(cancelButton, true);
            cancelButton.OnClicked += (s, e) => {
                cockpit.Context.PopCockpit(true);
            };
        }
コード例 #3
0
        void AddMenuButtonsGroup(Cockpit cockpit)
        {
            HUDButton importButton = HUDBuilder.CreateRectIconClickButton(
                0.1f, 0.05f, 0.7f, 55.0f, -50.0f,
                //0.1f, 0.05f, 0.7f, 5.0f, -5.0f,       // for debugging
                "icons/import_v1");

            importButton.Name = "import";
            cockpit.AddUIElement(importButton, true);
            importButton.OnClicked += (s, e) => {
                var cp = new FileImportCockpit()
                {
                    InitialPath = SceneGraphConfig.LastFileOpenPath
                };
                cockpit.Context.PushCockpit(cp);
            };

            HUDButton exportButton = HUDBuilder.CreateRectIconClickButton(
                0.1f, 0.05f, 0.7f, 55.0f, -50.0f,
                //0.1f, 0.05f, 0.7f, 5.0f, -5.0f,       // for debugging convenience
                "icons/export_v1");

            UnityUtil.TranslateInFrame(exportButton.RootGameObject, 0, -0.055f, 0, CoordSpace.WorldCoords);
            exportButton.Name = "export";
            cockpit.AddUIElement(exportButton, true);
            exportButton.OnClicked += (s, e) => {
                var cp = new FileExportCockpit()
                {
                    InitialPath = SceneGraphConfig.LastFileOpenPath
                };
                cockpit.Context.PushCockpit(cp);
            };


            HUDButton janusButton = HUDBuilder.CreateRectIconClickButton(
                0.1f, 0.05f, 0.7f, 55.0f, -50.0f,
                //0.1f, 0.05f, 0.7f, 5.0f, -5.0f,       // for debugging convenience
                "cockpit_icons/menu_buttons/janus_v1");

            UnityUtil.TranslateInFrame(janusButton.RootGameObject, 0, 2.0f * -0.055f, 0, CoordSpace.WorldCoords);
            janusButton.Name = "export";
            cockpit.AddUIElement(janusButton, true);
            janusButton.OnClicked += (s, e) => {
                var cp = new JanusVRExportCockpit()
                {
                    InitialPath = SceneGraphConfig.LastFileOpenPath
                };
                cockpit.Context.PushCockpit(cp);
            };


            HUDButton loadButton = HUDBuilder.CreateRectIconClickButton(
                0.1f, 0.05f, 0.7f, 55.0f, -50.0f,
                // 0.1f, 0.05f, 0.7f, 5.0f, -5.0f,       // for debugging convenience
                "icons/load_v1");

            UnityUtil.TranslateInFrame(loadButton.RootGameObject, 0.12f, 0, 0, CoordSpace.WorldCoords);
            loadButton.Name = "load";
            cockpit.AddUIElement(loadButton, true);
            loadButton.OnClicked += (s, e) => {
                var cp = new FileLoadSceneCockpit()
                {
                    InitialPath = SceneGraphConfig.LastFileOpenPath
                };
                cockpit.Context.PushCockpit(cp);
            };

            HUDButton saveButton = HUDBuilder.CreateRectIconClickButton(
                0.1f, 0.05f, 0.7f, 55.0f, -50.0f,
                // 0.1f, 0.05f, 0.7f, 5.0f, -5.0f,       // for debugging
                "icons/save_v1");

            UnityUtil.TranslateInFrame(saveButton.RootGameObject, 0.12f, -0.055f, 0, CoordSpace.WorldCoords);
            saveButton.Name = "save";
            cockpit.AddUIElement(saveButton, true);
            saveButton.OnClicked += (s, e) => {
                var cp = new FileSaveSceneCockpit()
                {
                    InitialPath = SceneGraphConfig.LastFileOpenPath
                };
                cockpit.Context.PushCockpit(cp);
            };



            HUDButton newButton = HUDBuilder.CreateRectIconClickButton(
                0.1f, 0.05f, 0.7f, 55.0f, -50.0f,
                "icons/new_v1");

            UnityUtil.TranslateInFrame(newButton.RootGameObject, 0.24f, 0, 0, CoordSpace.WorldCoords);
            newButton.Name = "new";
            cockpit.AddUIElement(newButton, true);
            newButton.OnClicked += (s, e) => {
                cockpit.Context.NewScene(true);
            };


            HUDButton quitButton = HUDBuilder.CreateRectIconClickButton(
                0.1f, 0.05f, 0.7f, 55.0f, -50.0f,
                "icons/quit_v1");

            UnityUtil.TranslateInFrame(quitButton.RootGameObject, 0.24f, -0.055f, 0, CoordSpace.WorldCoords);
            quitButton.Name = "quit";
            cockpit.AddUIElement(quitButton, true);
            quitButton.OnClicked += (s, e) => { FPlatform.QuitApplication(); };
        }