Esempio n. 1
0
        ActivateToolButton add_tool_button(Cockpit cockpit, string sName,
                                           float fHUDRadius, float dx, float dy,
                                           float fButtonRadius, toolInfo info)
        {
            ActivateToolButton button = new ActivateToolButton()
            {
                TargetScene = cockpit.Scene,
                ToolType    = info.identifier
            };

            button.CreateMeshIconButton(fButtonRadius, info.sMeshPath, defaultMaterial, info.fMeshScaleFudge);
            HUDUtil.PlaceInSphere(button, fHUDRadius, dx, dy);
            button.Name = sName;

            if (info.identifier == "cancel")
            {
                button.OnClicked += (s, e) => {
                    bool bIsSpatial = InputState.IsDevice(e.device, InputDevice.AnySpatialDevice);
                    int  nSide      = bIsSpatial ? (int)e.side : 1;
                    cockpit.Context.ToolManager.DeactivateTool((ToolSide)nSide);

                    // remove icon from hand
                    if (bIsSpatial)
                    {
                        cockpit.Context.SpatialController.ClearHandIcon(nSide);
                    }

                    // hide indicator
                    remove_indicator(nSide);
                };
            }
            else
            {
                button.OnClicked += (s, e) => {
                    bool bIsSpatial = InputState.IsDevice(e.device, InputDevice.AnySpatialDevice);
                    int  nSide      = bIsSpatial ? (int)e.side : 1;
                    remove_indicator(nSide);

                    cockpit.Context.ToolManager.SetActiveToolType(info.identifier, (ToolSide)nSide);
                    if (cockpit.Context.ToolManager.ActivateTool((ToolSide)nSide))
                    {
                        if (bIsSpatial)
                        {
                            Mesh iconmesh = Resources.Load <Mesh>(info.sMeshPath);
                            if (iconmesh != null)
                            {
                                cockpit.Context.SpatialController.SetHandIcon(iconmesh, nSide);
                            }
                        }

                        add_indicator(button, nSide);
                    }
                };
            }
            return(button);
        }
Esempio n. 2
0
        public bool FindSORayIntersection_PivotPriority(Ray ray, out SORayHit hit, Func <SceneObject, bool> filter = null)
        {
            bool bHitPivot = HUDUtil.FindNearestRayIntersection(SceneObjects, ray, out hit, (s) => { return(s is PivotSO); });

            if (bHitPivot)
            {
                return(true);
            }
            return(HUDUtil.FindNearestRayIntersection(SceneObjects, ray, out hit, filter));
        }
Esempio n. 3
0
        public bool FindSORayIntersection_PivotPriority(Ray3f ray, out SORayHit hit, Func <SceneObject, bool> filter = null)
        {
            bool bHitPivot = HUDUtil.FindNearestRayIntersection(VisibleSceneObjects, ray, out hit, is_priority_pivot);

            if (bHitPivot)
            {
                return(true);
            }
            return(HUDUtil.FindNearestRayIntersection(VisibleSceneObjects, ray, out hit,
                                                      (SelectionMask == null) ? filter : mask_filter(filter)));
        }
Esempio n. 4
0
        public void Place(HUDStandardItem hudItem, float dx, float dy)
        {
            Frame3f initFrame = hudItem.GetObjectFrame();
            Frame3f hudFrame  = VerticalCoordIsAngle ?
                                HUDUtil.GetCylinderFrameFromAngles(Radius, dx, dy) :
                                HUDUtil.GetCylinderFrameFromAngleHeight(Radius, dx, dy);

            hudItem.SetObjectFrame(
                initFrame.Translated(hudFrame.Origin)
                .Rotated(Quaternionf.FromTo(initFrame.Z, hudFrame.Z)));
        }
Esempio n. 5
0
        /// <summary>
        /// Show the Toast widget with an animated fade in. The widget will fade out
        /// after Duration seconds, unless the user hovers over it, in which case it
        /// will stay until they end the hover.
        /// </summary>
        public void Show(Cockpit cockpit, float fDuration, float fFadeInOut = 0.25f)
        {
            AlphaFade = 0.0f;

            hovering  = false;
            disappear = false;

            // if this goes true, toast will begin animated-fade on next frame
            dismiss = false;

            // we register a basic animator that just watches for dismiss=true and
            // when that happens we fade out and remove the toast
            cockpit.HUDAnimator.Register(
                new GenericAnimatable(() => {
                if (dismiss)
                {
                    HUDUtil.AnimatedDimiss_Cockpit(this, cockpit, (disappear) ? 0.001f : fFadeInOut);
                    dismiss_timer.Dispose();
                    return(true);
                }
                return(false);
            })
                );


            // timer event that is called after the initial duration, and then ever
            // couple hundred MS to check that hover ended.
            // This is called from a Timer, which runs in a separate thread, and hence
            // we cannot manipulate the scene in this function
            // TODO: couldn't we just do this in animator above??
            Action timer_elapsed = () => {
                if (hovering)
                {
                    dismiss_timer.Interval = 300;
                    dismiss_timer.Start();
                }
                else
                {
                    dismiss = true;
                }
            };


            // ok, this kicks everything off - we do animated transition to show ourself,
            // and then start a timer that waits the initial duration
            HUDUtil.AnimatedShow(this, fFadeInOut, () => {
                dismiss_timer          = new Timer(fDuration * 1000);
                dismiss_timer.Elapsed += (o, e) => {
                    timer_elapsed();
                };
                dismiss_timer.Enabled = true;
            });
        }
Esempio n. 6
0
        void add(HUDStandardItem element, LayoutOptions options)
        {
            if (element.IsVisible == false)
            {
                element.IsVisible = true;
            }

            IBoxModelElement elemBoxModel = element as IBoxModelElement;

            // for 2D view (but doesn't matter if we are doing a layout anyway!)
            Frame3f viewFrame = Cockpit.GetViewFrame2D();

            // with 3D view we should use this...
            //Frame3f viewFrame = Frame3f.Identity;

            element.SetObjectFrame(Frame3f.Identity);
            HUDUtil.PlaceInViewPlane(element, viewFrame);
            Cockpit.AddUIElement(element);

            Func <Vector2f> pinSourceF = options.PinSourcePoint2D;

            if (pinSourceF == null)
            {
                pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center);
            }

            Func <Vector2f> pinTargetF = options.PinTargetPoint2D;

            if (pinTargetF == null)
            {
                pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center);
            }

            Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift);

            // if we want to shift result in its layout frame, do that via a post-transform
            if (options.FrameAxesShift != Vector3f.Zero)
            {
                Solver.AddPostTransform(element, (e) => {
                    Frame3f f = (e as IElementFrame).GetObjectFrame();
                    f.Translate(options.FrameAxesShift.x * f.X + options.FrameAxesShift.y * f.Y + options.FrameAxesShift.z * f.Z);
                    (e as IElementFrame).SetObjectFrame(f);
                });
            }


            // auto-show
            if ((options.Flags & LayoutFlags.AnimatedShow) != 0)
            {
                HUDUtil.AnimatedShow(element);
            }
        }
Esempio n. 7
0
        public void Create(fMaterial defaultMaterial)
        {
            button     = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDToggleButton"));
            buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape),
                                      defaultMaterial, button);

            buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ??

            if (text.Length > 0)
            {
                UpdateText();
            }
        }
Esempio n. 8
0
        // creates a button in the desired geometry shape
        public void Create(Material defaultMaterial, Material disabledMaterial = null)
        {
            button     = new GameObject(UniqueNames.GetNext("HUDButton"));
            buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape),
                                      defaultMaterial, button);

            buttonMesh.transform.Rotate(Vector3.right, -90.0f);              // ??
            MaterialUtil.DisableShadows(buttonMesh);

            standard_mat = new fMaterial(defaultMaterial);
            if (disabledMaterial != null)
            {
                disabled_mat = new fMaterial(disabledMaterial);
            }
        }
Esempio n. 9
0
        // creates a button in the desired geometry shape
        public void Create()
        {
            entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDLabel"));

            bgMesh = AppendMeshGO("background", HUDUtil.MakeBackgroundMesh(Shape),
                                  MaterialUtil.CreateFlatMaterialF(BackgroundColor),
                                  entry);
            bgMesh.RotateD(Vector3f.AxisX, -90.0f);


            if (EnableBorder)
            {
                HUDShape borderShape = Shape;
                borderShape.Radius += BorderWidth;
                borderShape.Height += 2 * BorderWidth;
                borderShape.Width  += 2 * BorderWidth;
                border              = AppendMeshGO("border", HUDUtil.MakeBackgroundMesh(borderShape),
                                                   MaterialUtil.CreateFlatMaterialF(BorderColor), entry);
                border.RotateD(Vector3f.AxisX, -90.0f);
                border.Translate(-0.001f * Vector3f.AxisY, true);
            }

            BoxPosition horzAlign = BoxPosition.CenterLeft;

            if (AlignmentHorz == HorizontalAlignment.Center)
            {
                horzAlign = BoxPosition.Center;
            }
            else if (AlignmentHorz == HorizontalAlignment.Right)
            {
                horzAlign = BoxPosition.CenterRight;
            }

            textMesh =
                GameObjectFactory.CreateTextMeshGO(
                    "text", Text, TextColor, TextHeight, horzAlign, SceneGraphConfig.TextLabelZOffset);

            textMesh.TextObject.SetFixedWidth(Shape.Width);
            textMesh.TextObject.SetOverflowMode(TextOverflowMode.Ellipses);

            Vector2f toPos = BoxModel.GetBoxPosition(this, horzAlign);

            BoxModel.Translate(textMesh, Vector2f.Zero, toPos);

            AppendNewGO(textMesh, entry, false);

            MaterialUtil.DisableShadows(RootGameObject);
        }
Esempio n. 10
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);
            };
        }
Esempio n. 11
0
        // creates a button with a background shape and a foreground mesh
        public void Create(fMaterial bgMaterial, fMesh mesh, fMaterial meshMaterial, float fScale, Frame3f deltaF)
        {
            button = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton"));

            buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape), bgMaterial, button);
            buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ??
            MaterialUtil.DisableShadows(buttonMesh);

            iconMesh = AppendMeshGO("shape", mesh, meshMaterial, button);
            iconMesh.SetLocalScale(new Vector3f(fScale, fScale, fScale));
            iconMesh.SetLocalPosition(deltaF.Origin);
            iconMesh.SetLocalRotation(deltaF.Rotation);
            MaterialUtil.DisableShadows(iconMesh);

            standard_mat = new fMaterial(bgMaterial);
        }
Esempio n. 12
0
        // creates a button with a floating primitive in front of the button shape
        public void Create(PrimitiveType eType, Material bgMaterial, Material primMaterial, float fPrimScale = 0.7f)
        {
            button     = new GameObject(UniqueNames.GetNext("HUDButton"));
            buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape), bgMaterial, button);
            buttonMesh.transform.Rotate(Vector3.right, -90.0f);              // ??
            MaterialUtil.DisableShadows(buttonMesh);

            GameObject prim     = AppendUnityPrimitiveGO("primitive", eType, primMaterial, button);
            float      primSize = Shape.EffectiveRadius() * fPrimScale;

            prim.transform.localScale = new Vector3(primSize, primSize, primSize);
            prim.transform.Translate(0.0f, 0.0f, -primSize);
            prim.transform.Rotate(-15.0f, 45.0f, 0.0f, Space.Self);
            MaterialUtil.DisableShadows(prim);

            standard_mat = new fMaterial(bgMaterial);
        }
Esempio n. 13
0
        // creates a button with a background shape and a foreground mesh
        public void Create(Material bgMaterial, fMesh mesh, Material meshMaterial, float fScale, Frame3f deltaF)
        {
            button = new GameObject(UniqueNames.GetNext("HUDButton"));

            buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape), bgMaterial, button);
            buttonMesh.transform.Rotate(Vector3.right, -90.0f); // ??
            MaterialUtil.DisableShadows(buttonMesh);

            GameObject meshGO = AppendMeshGO("shape", mesh, meshMaterial, button);

            meshGO.transform.localScale    = new Vector3(fScale, fScale, fScale);
            meshGO.transform.localPosition = deltaF.Origin;
            meshGO.transform.localRotation = deltaF.Rotation;
            MaterialUtil.DisableShadows(meshGO);

            standard_mat = new fMaterial(bgMaterial);
        }
Esempio n. 14
0
 void update_shape(HUDShape newShape)
 {
     shape = newShape;
     if (bgMesh == null)
     {
         return;
     }
     bgMesh.SetSharedMesh(
         HUDUtil.MakeBackgroundMesh(shape));
     if (EnableBorder)
     {
         HUDShape borderShape = shape;
         borderShape.Radius += BorderWidth;
         borderShape.Height += 2 * BorderWidth;
         borderShape.Width  += 2 * BorderWidth;
         border.SetSharedMesh(HUDUtil.MakeBackgroundMesh(borderShape));
     }
 }
Esempio n. 15
0
        // creates a button in the desired geometry shape
        public void Create(fMaterial defaultMaterial, fMaterial disabledMaterial = null, fMaterial hoverMaterial = null)
        {
            button     = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton"));
            buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape),
                                      defaultMaterial, button);
            buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ??
            MaterialUtil.DisableShadows(buttonMesh);

            standard_mat = defaultMaterial;
            if (disabledMaterial != null)
            {
                disabled_mat = disabledMaterial;
            }
            if (hoverMaterial != null)
            {
                hover_mat = hoverMaterial;
            }
        }
Esempio n. 16
0
        public static HUDButton CreateIconClickButton(HUDShape shape,
                                                      float fHUDRadius, float fAngleHorz, float fAngleVert,
                                                      string icon,
                                                      IGameObjectGenerator addGeometry = null)
        {
            Material  mat    = MaterialUtil.CreateTransparentImageMaterial(icon);
            HUDButton button = new HUDButton()
            {
                Shape = shape
            };

            button.Create(mat);
            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }
            HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert);
            return(button);
        }
Esempio n. 17
0
        public static HUDButton CreateMeshClickButton(
            Mesh mesh, Color color, float fMeshScale, Quaternion meshRotation,
            float fHUDRadius, float fAngleHorz, float fAngleVert,
            IGameObjectGenerator addGeometry = null)
        {
            Material mat = (color.a < 1.0f) ?
                           MaterialUtil.CreateTransparentMaterial(color, color.a) :
                           MaterialUtil.CreateStandardMaterial(color);

            HUDButton button = new HUDButton();

            button.Create(mesh, mat, fMeshScale, meshRotation);

            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }
            HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert);
            return(button);
        }
Esempio n. 18
0
        public static HUDButton CreateGeometryIconClickButton(HUDShape shape,
                                                              float fHUDRadius, float fAngleHorz, float fAngleVert,
                                                              Color bgColor,
                                                              IGameObjectGenerator addGeometry = null)
        {
            Material mat = (bgColor.a == 1.0f) ?
                           MaterialUtil.CreateStandardMaterial(bgColor) : MaterialUtil.CreateTransparentMaterial(bgColor);
            HUDButton button = new HUDButton()
            {
                Shape = shape
            };

            button.Create(mat);
            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }
            HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert);
            return(button);
        }
Esempio n. 19
0
        public override Capture UpdateCapture(InputState input, CaptureData data)
        {
            //CaptureControl.doSurroundCapture = false;
#if false
            if (input.bLeftMenuButtonPressed)
            {
                press_time = FPlatform.RealTime();
                if (input.bLeftShoulderDown)
                {
                    CaptureControl.EnableSurroundCapture = true;
                }
                else
                {
                    CaptureControl.EnableSurroundCapture = false;
                }
            }
            else if (input.bLeftMenuButtonReleased)
            {
                if (in_video_capture)
                {
                    CaptureControl.EndVideoCapture();
                    string s = string.Format("Captured {0} video!", CaptureControl.EnableSurroundCapture ? "360" : "WideAngle");
                    HUDUtil.ShowToastPopupMessage(s, FContext.ActiveContext_HACK.ActiveCockpit);
                    in_video_capture = false;
                    press_time       = 0;
                }
                else if (FPlatform.RealTime() - press_time > 1.0f)
                {
                    CaptureControl.BeginVideoCapture();
                    in_video_capture = true;
                }
                else
                {
                    CaptureControl.CaptureScreen();
                    string s = string.Format("Captured {0} screenshot!", CaptureControl.EnableSurroundCapture ? "360" : "WideAngle");
                    HUDUtil.ShowToastPopupMessage(s, FContext.ActiveContext_HACK.ActiveCockpit);
                }
            }
#endif
            return(Capture.Ignore);
        }
Esempio n. 20
0
        void add(HUDStandardItem element, LayoutOptions options)
        {
            if (element.IsVisible == false)
            {
                element.IsVisible = true;
            }

            IBoxModelElement elemBoxModel = element as IBoxModelElement;

            // for 2D view (but doesn't matter if we are doing a layout anyway!)
            Frame3f viewFrame = Cockpit.GetViewFrame2D();

            // with 3D view we should use this...
            //Frame3f viewFrame = Frame3f.Identity;

            element.SetObjectFrame(Frame3f.Identity);
            HUDUtil.PlaceInViewPlane(element, viewFrame);
            Cockpit.AddUIElement(element);

            Func <Vector2f> pinSourceF = options.PinSourcePoint2D;

            if (pinSourceF == null)
            {
                pinSourceF = LayoutUtil.BoxPointF(elemBoxModel, BoxPosition.Center);
            }

            Func <Vector2f> pinTargetF = options.PinTargetPoint2D;

            if (pinTargetF == null)
            {
                pinTargetF = LayoutUtil.BoxPointF(Solver.Container, BoxPosition.Center);
            }

            Solver.AddLayoutItem(element, pinSourceF, pinTargetF, this.StandardDepth + options.DepthShift);

            // auto-show
            if ((options.Flags & LayoutFlags.AnimatedShow) != 0)
            {
                HUDUtil.AnimatedShow(element);
            }
        }
Esempio n. 21
0
        // creates a button in the desired geometry shape
        public void Create()
        {
            entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDShapeElement"));

            bgMesh = new fGameObject(AppendMeshGO("background", HUDUtil.MakeBackgroundMesh(Shape),
                                                  MaterialUtil.CreateFlatMaterialF(Color),
                                                  entry));
            bgMesh.RotateD(Vector3f.AxisX, -90.0f);

            if (EnableBorder)
            {
                HUDShape borderShape = Shape;
                borderShape.Radius += BorderWidth;
                borderShape.Height += 2 * BorderWidth;
                borderShape.Width  += 2 * BorderWidth;
                border              = new fGameObject(AppendMeshGO("border", HUDUtil.MakeBackgroundMesh(borderShape),
                                                                   MaterialUtil.CreateFlatMaterialF(BorderColor), entry));
                border.RotateD(Vector3f.AxisX, -90.0f);
                border.Translate(-0.001f * Vector3f.AxisY, true);
            }
        }
Esempio n. 22
0
        public override void SaveFile(string sNewPath)
        {
            DebugUtil.Log(1, "Exporting scene to path " + sNewPath);
            SceneGraphConfig.LastFileOpenPath = ListView.FolderPath;

            string sTargetFolder = "";
            bool   use_auto      = sNewPath.EndsWith(GetDefaultFileName());

            if (use_auto == false)
            {
                sTargetFolder = Path.GetFileName(sNewPath);
            }

            string          sSavePath = Path.Combine(ListView.FolderPath, sNewPath);
            JanusVRExporter export    = new JanusVRExporter()
            {
                GlobalTranslation = -20 * Vector3f.AxisZ
            };

            export.WriteInBackgroundThreads = true;
            export.BackgroundWriteCompleteF = (exp, status) => {
                if (status.Ok)
                {
                    ActiveCockpit.Context.RegisterNextFrameAction(() => {
                        FContext context = ActiveCockpit.Context;
                        ActiveCockpit.Context.PopCockpit(true);
                        //HUDUtil.ShowCenteredPopupMessage("Done!", "Exported to subfolder " + export.ExportPath, context.ActiveCockpit);
                        HUDUtil.ShowToastPopupMessage("Exported JanusVR Room to subfolder " + export.ExportPath, context.ActiveCockpit, 1.25f, 0.8f);
                    });
                }
                else
                {
                    ActiveCockpit.Context.RegisterNextFrameAction(() => {
                        Debug.Log("[JanusExportScene] save at " + sNewPath + " failed: " + export.LastErrorMessage);
                        HUDUtil.ShowCenteredPopupMessage("Export Failed", "Sorry, could not export to path " + sNewPath, ActiveCockpit);
                    });
                }
            };
            export.Export(ActiveCockpit.Context.Scene, ListView.FolderPath, sTargetFolder);
        }
Esempio n. 23
0
        public static void ShowCenteredPopupMessage(string sTitleText, string sText, Cockpit cockpit)
        {
            HUDPopupMessage message = new HUDPopupMessage()
            {
                Width           = 500 * cockpit.GetPixelScale(), Height = 250 * cockpit.GetPixelScale(),
                TitleTextHeight = 30 * cockpit.GetPixelScale(),
                TextHeight      = 20 * cockpit.GetPixelScale(),
                BackgroundColor = Colorf.Silver,
                TextColor       = Colorf.VideoBlack,
                TitleText       = sTitleText,
                Text            = sText
            };

            message.Create();
            HUDUtil.PlaceInSphere(message, 0.5f, 0, 0);
            message.Name = "popup";
            cockpit.AddUIElement(message, true);
            message.OnDismissed += (s, e) => {
                AnimatedDimiss_Cockpit(message, cockpit, true);
            };
            AnimatedShow(message);
        }
Esempio n. 24
0
        public static void ShowToastPopupMessage(string sText, Cockpit cockpit, float heightScale = 1.0f, float textScale = 1.0f)
        {
            // [TODO] should size based on VR or not-VR...for VR use visual radius?

            HUDPopupMessage message = new HUDPopupMessage()
            {
                Width           = 500 * cockpit.GetPixelScale(), Height = heightScale * 150 * cockpit.GetPixelScale(),
                TextHeight      = textScale * 50 * cockpit.GetPixelScale(),
                BackgroundColor = Colorf.DarkYellow,
                TextColor       = Colorf.VideoBlack,
                Text            = sText
            };

            message.Create();
            HUDUtil.PlaceInSphere(message, 1.0f, 30, -30);
            message.Name = "popup";
            cockpit.AddUIElement(message, true);
            message.OnDismissed += (s, e) => {
                AnimatedDimiss_Cockpit(message, cockpit, true);
            };
            AnimatedShow(message, 0.5f);
        }
Esempio n. 25
0
        // creates a button with a floating primitive in front of the button shape
        public void Create(UnityEngine.PrimitiveType eType, fMaterial bgMaterial, fMaterial primMaterial, float fPrimScale = 0.7f)
        {
            button     = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton"));
            buttonMesh = AppendMeshGO("shape", HUDUtil.MakeBackgroundMesh(this.Shape), bgMaterial, button);
            buttonMesh.RotateD(Vector3f.AxisX, -90.0f); // ??
            MaterialUtil.DisableShadows(buttonMesh);

            iconMesh = AppendUnityPrimitiveGO("primitive", eType, primMaterial, button);
            float primSize = Shape.EffectiveRadius() * fPrimScale;

            iconMesh.SetLocalScale(new Vector3f(primSize, primSize, primSize));
            iconMesh.Translate(new Vector3f(0.0f, 0.0f, -primSize), false);
            Quaternionf rot = iconMesh.GetLocalRotation();

            rot = rot * Quaternionf.AxisAngleD(Vector3f.AxisY, 45.0f);
            rot = rot * Quaternionf.AxisAngleD(Vector3f.AxisX, -15.0f);
            iconMesh.SetLocalRotation(rot);
            //buttonMesh.transform.Rotate(-15.0f, 45.0f, 0.0f, Space.Self);
            MaterialUtil.DisableShadows(iconMesh);

            standard_mat = new fMaterial(bgMaterial);
        }
Esempio n. 26
0
        CreateDropPrimitiveButton add_primitive_button(Cockpit cockpit, string sName, float fHUDRadius, float dx, float dy,
                                                       PrimitiveType primType, float fPrimRadiusScale,
                                                       Material bgMaterial, Material primMaterial,
                                                       Func <TransformableSO> CreatePrimitiveF,
                                                       IGameObjectGenerator customGenerator = null
                                                       )
        {
            float fButtonRadius = 0.08f;

            CreateDropPrimitiveButton button = new CreateDropPrimitiveButton()
            {
                TargetScene     = cockpit.Scene,
                CreatePrimitive = CreatePrimitiveF
            };

            button.Create(fButtonRadius, bgMaterial);
            var gen = (customGenerator != null) ? customGenerator :
                      new primitiveIconGenerator()
            {
                PrimType = primType, PrimMaterial = primMaterial, PrimSize = fButtonRadius * fPrimRadiusScale
            };

            button.AddVisualElements(gen.Generate(), true);
            HUDUtil.PlaceInSphere(button, fHUDRadius, dx, dy);
            button.Name       = sName;
            button.OnClicked += (s, e) => {
                update_indicator(button, cockpit.Scene);
            };
            button.OnDoubleClicked += (s, e) => {
                // [TODO] could have a lighter record here because we can easily recreate primitive...
                cockpit.Scene.History.PushChange(
                    new AddSOChange()
                {
                    scene = cockpit.Scene, so = CreatePrimitiveF()
                });
                cockpit.Scene.History.PushInteractionCheckpoint();
            };
            return(button);
        }
Esempio n. 27
0
        DropMaterialButton add_material_button(Cockpit cockpit, string sName,
                                               float fHUDRadius, float dx, float dy,
                                               float fButtonRadius,
                                               Material bgMaterial, SOMaterial material)
        {
            DropMaterialButton button = new DropMaterialButton()
            {
                TargetScene = cockpit.Scene,
                Material    = material
            };

            button.Create(fButtonRadius, bgMaterial);
            HUDUtil.PlaceInSphere(button, fHUDRadius, dx, dy);
            button.Name = sName;

            button.OnClicked += (s, e) => {
                cockpit.Scene.DefaultSOMaterial = material;
                if (indicatorButton != null)
                {
                    indicatorButton.RemoveGO(indicatorGO);
                }
                indicatorButton = button;

                indicatorGO.SetPosition(Vector3f.Zero);
                indicatorGO.SetRotation(Quaternionf.Identity);
                indicatorGO.SetLocalScale(fIndicatorSize * Vector3f.One);
                indicatorGO.SetLocalPosition(
                    indicatorGO.GetLocalPosition() + fIndicatorShift * (Vector3f.AxisY - 4 * Vector3f.AxisZ + Vector3f.AxisX));
                indicatorButton.AppendNewGO(indicatorGO, indicatorButton.RootGameObject, false);
            };

            button.OnDoubleClicked += (s, e) => {
                if (cockpit.Scene.Selected.Count > 0)
                {
                    button.DoSetMaterial(cockpit.Scene.Selected, button.Material);
                }
            };
            return(button);
        }
Esempio n. 28
0
        public static void ShowCenteredStaticPopupMessage(string sImagePath, Cockpit cockpit)
        {
            Material mat     = MaterialUtil.CreateTransparentImageMaterial(sImagePath);
            float    fAspect = (float)mat.mainTexture.width / (float)mat.mainTexture.height;
            float    fScale  = 0.5f;    // should this be a parameter??

            HUDPopupMessage message = new HUDPopupMessage()
            {
                Shape = new HUDShape()
                {
                    Type           = HUDShapeType.Rectangle, Width = fScale * 1.0f, Height = fScale * 1.0f / fAspect,
                    UseUVSubRegion = false
                }
            };

            message.Create(mat);
            HUDUtil.PlaceInSphere(message, 0.5f, 0, 0);
            message.Name = "popup";
            cockpit.AddUIElement(message, true);
            message.OnDismissed += (s, e) => {
                AnimatedDimiss_Cockpit(message, cockpit);
            };
            AnimatedShow(message);
        }
Esempio n. 29
0
 public bool FindSORayIntersection(Ray3f ray, out SORayHit hit, Func <SceneObject, bool> filter = null)
 {
     return(HUDUtil.FindNearestRayIntersection(VisibleSceneObjects, ray, out hit,
                                               (SelectionMask == null) ? filter : mask_filter(filter)));
 }
Esempio n. 30
0
 public bool FindUIHoverRayIntersection(Ray3f ray, out UIRayHit hit)
 {
     return(HUDUtil.FindNearestHoverRayIntersection(vUIElements, ray, out hit));
 }