コード例 #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 TextLabelGenerator()
 {
     Text      = "(label)";
     TextAlign = TextAlignment.Center;
     Scale     = 0.1f;
     Translate = new Vector3f(0, 0, 0);
     Color     = ColorUtil.make(10, 10, 10);
     ZOffset   = -1.0f;
 }
コード例 #3
0
        public void Initialize(Cockpit cockpit, float fCockpitRadius)
        {
            activeCockpit = cockpit;
            activeCockpit.PositionMode = Cockpit.MovementMode.Static;
            activeCockpit.GrabFocus    = true;
            activeHUDRadius            = fCockpitRadius;

            string[] files, folders;
            try {
                files   = Source.GetFiles(FolderPath);
                folders = Source.GetFolders(FolderPath);
            } catch (Exception e) {
                Debug.Log("[CurrentFolderList.Initialize] exception! " + e.Message);
                return;
            }

            float fMinHorz = -45.0f, fMaxHorz = 45.0f;
            float fStartVert = 15.0f;
            float fTop       = HUDUtil.GetSphereFrame(fCockpitRadius, 0.0f, fStartVert).Origin.y;

            int folderi = 0, filei = 0;

            Mesh  folderMesh              = Resources.Load <Mesh>("icon_meshes/folder_v1");
            Color folderColor             = ColorUtil.make(241, 213, 146);
            Color inaccessibleFolderColor = ColorUtil.make(100, 100, 100);
            Mesh  fileMesh                = Resources.Load <Mesh>("icon_meshes/file_v1");
            Color fileColor               = ColorUtil.make(250, 250, 250);

            // [TODO] something wrong here, icons are loading backwards...??
            Quaternion meshRotation =
                Quaternion.AngleAxis(270.0f, Vector3.right) *
                Quaternion.AngleAxis(180.0f + 25.0f, Vector3.forward);
            float meshScale = IconSize * 0.9f;

            HUDCylinder hudSurf = new HUDCylinder()
            {
                Radius = fCockpitRadius, VerticalCoordIsAngle = false
            };
            float fStepH     = VRUtil.HorizontalStepAngle(fCockpitRadius, 0, IconSize + IconPadding);
            int   nStepsHorz = (int)((fMaxHorz - fMinHorz) / fStepH);

            fMinHorz = -(nStepsHorz * fStepH * 0.5f);
            fMaxHorz = (nStepsHorz * fStepH * 0.5f);
            float fStepV = IconSize + IconPadding;


            IconCollection = new HUDCollection();
            IconCollection.Create();

            bool bDone = false;
            int  yi    = 0;

            while (!bDone)
            {
                float fCurV = fTop - yi * fStepV;
                yi++;

                for (int xi = 0; xi < nStepsHorz && bDone == false; ++xi)
                {
                    float fCurH = fMinHorz + ((float)xi + 0.5f) * fStepH;

                    string name        = "x";
                    fMesh  useMesh     = null;
                    Color  useColor    = Color.white;
                    bool   bAccessible = true;
                    bool   bIsFile     = false;
                    if (folderi < folders.Length)
                    {
                        name     = folders[folderi++];
                        useMesh  = new fMesh(UnityEngine.Object.Instantiate <Mesh>(folderMesh));
                        useColor = folderColor;
                        if (Source.FilterInaccessibleFolders == false &&
                            FileSystemUtils.CanAccessFolder(Path.Combine(FolderPath, name)) == false)
                        {
                            bAccessible = false;
                            useColor    = inaccessibleFolderColor;
                        }
                    }
                    else if (filei < files.Length)
                    {
                        name     = files[filei++];
                        useMesh  = new fMesh(UnityEngine.Object.Instantiate <Mesh>(fileMesh));
                        useColor = fileColor;
                        bIsFile  = true;
                    }
                    else
                    {
                        bDone = true;
                        break;
                    }
                    //useColor.a = 0.999f;        // [RMS] can use this to force into alpha pass

                    string displayName = name;
                    if (displayName.Length > 12)
                    {
                        displayName = name.Substring(0, 12) + "...";
                    }

                    //float TextScale = 0.01f, ShiftX = -IconSize * 0.5f;
                    float TextScale = 0.005f, ShiftX = -IconSize * 0.5f;

                    HUDButton iconButton = HUDBuilder.CreateMeshClickButton(
                        useMesh, useColor, meshScale, meshRotation,
                        hudSurf, fCurH, fCurV,
                        new TextLabelGenerator()
                    {
                        Text = displayName, Scale = TextScale, Translate = new Vector3(ShiftX, 0.0f, 0.0f)
                    });
                    iconButton.Name = name;
                    //cockpit.AddUIElement(iconButton, true);
                    IconCollection.AddChild(iconButton);

                    if (bIsFile)
                    {
                        iconButton.OnClicked += (o, e) => {
                            if (this.OnFileClicked != null)
                            {
                                this.OnFileClicked(name);
                            }
                        };
                    }

                    if (bAccessible)
                    {
                        iconButton.OnDoubleClicked += IconButton_DoubleClick;
                    }
                }
            }

            cockpit.AddUIElement(IconCollection, true);
            fCurMaxScroll = Mathf.Max(0, (yi - 4) * fStepV);
        }