コード例 #1
0
ファイル: HUDBuilder.cs プロジェクト: ly774508966/frame3Sharp
        public static HUDToggleButton CreateToggleButton(HUDShape shape, float fHUDRadius,
                                                         float fAngleHorz, float fAngleVert,
                                                         string enabledIcon, string disabledIcon,
                                                         IGameObjectGenerator addGeometry = null)
        {
            fMaterial enabledMat  = MaterialUtil.CreateTransparentImageMaterialF(enabledIcon);
            fMaterial disabledMat = MaterialUtil.CreateTransparentImageMaterialF(disabledIcon);

            HUDToggleButton button = new HUDToggleButton()
            {
                Shape = shape
            };

            button.Create(enabledMat);
            if (addGeometry != null)
            {
                button.AddVisualElements(addGeometry.Generate(), true);
            }

            HUDUtil.PlaceInSphere(button, fHUDRadius, fAngleHorz, fAngleVert);
            button.OnToggled += (s, bEnabled) => {
                button.SetAllGOMaterials(bEnabled ? enabledMat : disabledMat);
            };
            return(button);
        }
コード例 #2
0
 public HUDButton()
 {
     Shape = new HUDShape()
     {
         Type = HUDShapeType.Disc, Radius = 0.1f
     };
 }
コード例 #3
0
 // creates a button with a floating primitive in front of the button shape
 public void Create(float fRadius, Material bgMaterial)
 {
     Shape        = new HUDShape(HUDShapeType.Disc, fRadius);
     tempMaterial = MaterialUtil.ToUnityMaterial(Material);
     base.Create(PrimitiveType.Sphere, tempMaterial, 1.2f);
     ((GameObject)button).transform.localRotation = Quaternion.identity;
 }
コード例 #4
0
 public HUDPopupMessage()
 {
     Shape = new HUDShape()
     {
         Type = HUDShapeType.Disc, Radius = 0.1f
     };
 }
コード例 #5
0
ファイル: HUDBuilder.cs プロジェクト: Alan-Baylis/frame3Sharp
        public static HUDButton CreateDiscIconClickButton(float fButtonRadius,
                                                          float fHUDRadius, float fAngleHorz, float fAngleVert,
                                                          string icon,
                                                          IGameObjectGenerator addGeometry = null)
        {
            HUDShape shape = new HUDShape(HUDShapeType.Disc, fButtonRadius);

            return(CreateIconClickButton(shape, fHUDRadius, fAngleHorz, fAngleVert, icon, addGeometry));
        }
コード例 #6
0
        public HUDToggleButton()
        {
            Shape    = new HUDShape(HUDShapeType.Disc, 0.1f);
            bChecked = true;

            TextHeight = 0.8f;
            TextColor  = Colorf.Black;
            text       = "";
        }
コード例 #7
0
ファイル: HUDBuilder.cs プロジェクト: Alan-Baylis/frame3Sharp
        public static HUDButton CreateRectIconClickButton(float fButtonWidth, float fButtonHeight,
                                                          float fHUDRadius, float fAngleHorz, float fAngleVert,
                                                          string icon,
                                                          IGameObjectGenerator addGeometry = null)
        {
            HUDShape shape = new HUDShape(HUDShapeType.Rectangle, fButtonWidth, fButtonHeight);

            return(CreateIconClickButton(shape, fHUDRadius, fAngleHorz, fAngleVert, icon, addGeometry));
        }
コード例 #8
0
        public HUDLabel()
        {
            Shape      = new HUDShape(HUDShapeType.Rectangle, 10, 1);
            TextHeight = 0.8f;

            BackgroundColor   = Colorf.VideoWhite;
            TextColor         = Colorf.VideoBlack;
            DisabledTextColor = Colorf.DimGrey;
            AlignmentHorz     = HorizontalAlignment.Left;
            text = "(default)";
        }
コード例 #9
0
        public HUDLabel(float width, float height, ITextElementStyle textStyle)
        {
            Shape           = new HUDShape(HUDShapeType.Rectangle, width, height);
            BackgroundColor = Colorf.TransparentBlack;
            BorderWidth     = 0;
            BorderColor     = Colorf.TransparentBlack;
            EnableBorder    = false;

            TextHeight    = textStyle.TextHeight;
            TextColor     = textStyle.TextColor;
            AlignmentHorz = textStyle.AlignmentHorz;
            text          = "(default)";
        }
コード例 #10
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);
        }
コード例 #11
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));
     }
 }
コード例 #12
0
ファイル: HUDBuilder.cs プロジェクト: ly774508966/frame3Sharp
        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);
        }
コード例 #13
0
ファイル: HUDBuilder.cs プロジェクト: ly774508966/frame3Sharp
        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);
        }
コード例 #14
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);
            }
        }
コード例 #15
0
        // creates a button with a floating primitive in front of the button shape
        public void CreateMeshIconButton(float fRadius, string sMeshPath, Material bgMaterial,
                                         float fMeshScaleFudge)
        {
            Shape = new HUDShape(HUDShapeType.Disc, fRadius);

            fMesh    iconmesh     = null;
            Material meshMaterial = null;

            try {
                iconmesh     = FResources.LoadMesh(sMeshPath);
                meshMaterial = MaterialUtil.CreateStandardVertexColorMaterial(Color.white);
            } catch { }
            if (iconmesh == null)
            {
                iconmesh     = UnityUtil.GetPrimitiveMesh(PrimitiveType.Sphere);
                meshMaterial = MaterialUtil.CreateStandardMaterial(Color.red);
            }

            float fMeshRadius = fRadius * fMeshScaleFudge;

            base.Create(bgMaterial, iconmesh, meshMaterial, fMeshRadius,
                        Frame3f.Identity.Translated(-fMeshRadius * 0.25f, 2).Rotated(-15.0f, 1));
        }
コード例 #16
0
 /// <summary>
 /// Create a fMesh of the shape/dimensions specified by Shape
 /// </summary>
 public static fMesh MakeBackgroundMesh(HUDShape Shape)
 {
     if (Shape.Type == HUDShapeType.Disc)
     {
         return(MeshGenerators.CreateTrivialDisc(Shape.Radius, Shape.Slices));
     }
     else if (Shape.Type == HUDShapeType.Rectangle)
     {
         return(MeshGenerators.CreateTrivialRect(Shape.Width, Shape.Height,
                                                 Shape.UseUVSubRegion == true ?
                                                 MeshGenerators.UVRegionType.CenteredUVRectangle : MeshGenerators.UVRegionType.FullUVSquare));
     }
     else if (Shape.Type == HUDShapeType.RoundRect)
     {
         return(MeshGenerators.CreateRoundRect(Shape.Width, Shape.Height, Shape.Radius, Shape.Slices,
                                               Shape.UseUVSubRegion == true ?
                                               MeshGenerators.UVRegionType.CenteredUVRectangle : MeshGenerators.UVRegionType.FullUVSquare,
                                               Shape.RoundRectSharpCorners));
     }
     else
     {
         throw new Exception("HUDUtil.MakeBackgroundMesh: unknown shape type!");
     }
 }
コード例 #17
0
 public HUDShapeElement()
 {
     Shape = new HUDShape(HUDShapeType.Rectangle, 10, 1);
     Color = Colorf.VideoWhite;
 }
コード例 #18
0
 public HUDButton()
 {
     Shape = new HUDShape(HUDShapeType.Disc, 0.1f);
 }
コード例 #19
0
ファイル: HUDSpacer.cs プロジェクト: xiaodelea/frame3Sharp
 public HUDSpacer()
 {
     Shape = new HUDShape(HUDShapeType.Rectangle, 10, 1);
 }
コード例 #20
0
 // creates a button with a floating primitive in front of the button shape
 public void Create(float fRadius, Material bgMaterial)
 {
     Shape = new HUDShape(HUDShapeType.Disc, fRadius);
     base.Create(bgMaterial);
 }