コード例 #1
0
        public virtual void Create()
        {
            rootGO = new GameObject(UniqueNames.GetNext("HUDSlider"));

            fMaterial useMaterial = MaterialUtil.CreateFlatMaterialF(bgColor);

            backgroundGO = GameObjectFactory.CreateRectangleGO("background",
                                                               SliderWidth, SliderHeight, useMaterial, true, true);
            MaterialUtil.DisableShadows(backgroundGO);
            backgroundGO.RotateD(Vector3f.AxisX, -90.0f); // ??
            AppendNewGO(backgroundGO, rootGO, false);

            handleMaterial = MaterialUtil.CreateFlatMaterialF(handleColor);
            handleGO       = create_handle_go(handleMaterial);
            if (handleGO != null)
            {
                handleGO.Translate(0.001f * Vector3f.AxisY, true);
                AppendNewGO(handleGO, rootGO, false);
                handleStart = handleGO.GetLocalFrame();
            }

            create_visuals_geometry();

            TickMaterial = MaterialUtil.CreateFlatMaterialF(tickColor);

            update_geometry();
        }
コード例 #2
0
ファイル: HUDLabel.cs プロジェクト: ly774508966/frame3Sharp
        // creates a button in the desired geometry shape
        public void Create()
        {
            entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDLabel"));

            bgMesh = new fGameObject(AppendMeshGO("background", make_background_mesh(),
                                                  MaterialUtil.CreateFlatMaterialF(BackgroundColor),
                                                  entry));
            bgMesh.RotateD(Vector3f.AxisX, -90.0f);

            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);

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

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

            AppendNewGO(textMesh, entry, false);
        }
コード例 #3
0
        // actually create GO elements, etc
        public void Create()
        {
            entry = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDPopupMessage"));

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


            IBoxModelElement contentArea = BoxModel.PaddedBounds(this, Padding);

            BoxPosition titleBoxPos = BoxModel.ToPosition(TitleAlignment, VerticalAlignment.Top);

            titleTextMesh = (titleText == "") ? null : GameObjectFactory.CreateTextMeshGO(
                "title", TitleText, TextColor, TitleTextHeight, titleBoxPos, SceneGraphConfig.TextLabelZOffset);
            float fTitleHeight = 0;

            if (titleTextMesh != null)
            {
                Vector2f titleToPos = BoxModel.GetBoxPosition(contentArea, titleBoxPos);
                BoxModel.Translate(titleTextMesh, Vector2f.Zero, titleToPos);
                AppendNewGO(titleTextMesh, entry, false);
                fTitleHeight = TitleTextHeight;
            }

            IBoxModelElement messageArea = BoxModel.PaddedBounds(contentArea, 0, 0, 0, Padding + fTitleHeight);
            Vector2f         textDims    = messageArea.Size2D;

            BoxPosition textBoxPos = BoxModel.ToPosition(Alignment, VerticalAlignment.Top);

            textMesh = GameObjectFactory.CreateTextAreaGO(
                "message", Text, TextColor, TextHeight, textDims, Alignment, textBoxPos, SceneGraphConfig.TextLabelZOffset);
            Vector2f textToPos = BoxModel.GetBoxPosition(messageArea, textBoxPos);

            BoxModel.Translate(textMesh, Vector2f.Zero, textToPos);
            AppendNewGO(textMesh, entry, false);



            if (EnableClickToDismiss)
            {
                footerTextMesh = GameObjectFactory.CreateTextMeshGO(
                    "footer", DismissText, DismissTextColor, TextHeight * 0.5f,
                    BoxPosition.CenterBottom, SceneGraphConfig.TextLabelZOffset);
                BoxModel.Translate(footerTextMesh, Vector2f.Zero, BoxModel.GetBoxPosition(contentArea, BoxPosition.CenterBottom));
                AppendNewGO(footerTextMesh, entry, false);
            }
        }
コード例 #4
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);
        }
コード例 #5
0
        // equilateral triangle lying in plane centered at (0,0)
        // with height = 1 (ie vertical extent is [-0.5,0.5], so base width is 2/sqrt(3)
        public static fTriangleGameObject CreateTriangleGO(string sName, float fWidth, float fHeight, Colorf color, bool bCollider)
        {
            GameObject go      = new GameObject(sName);
            Mesh       triMesh = new Mesh();
            float      h       = 1;
            float      w       = (float)(2 / Math.Sqrt(3));

            //float h = (float)(Math.Sqrt(3) / 2);      // width=1 instead (expose this as parameter?)
            //float w = 1;
            triMesh.vertices = new Vector3[3] {
                new Vector3(-w / 2, 0.0f, -h / 2), new Vector3(w / 2, 0.0f, -h / 2), new Vector3(0, 0, h / 2)
            };
            triMesh.triangles = new int[3] {
                0, 2, 1
            };
            initialize_meshgo(go, new fMesh(triMesh), bCollider, true);
            go.SetMaterial(MaterialUtil.CreateFlatMaterialF(color));
            return(new fTriangleGameObject(go, fWidth, fHeight));
        }
コード例 #6
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);
            }
        }
コード例 #7
0
        // creates a button in the desired geometry shape
        public void Create()
        {
            entry = new GameObject(UniqueNames.GetNext("HUDTextEntry"));
            Mesh mesh = MeshGenerators.CreateTrivialRect(Width, Height, MeshGenerators.UVRegionType.FullUVSquare);

            backgroundMaterial       = MaterialUtil.CreateFlatMaterialF(BackgroundColor);
            activeBackgroundMaterial = MaterialUtil.CreateFlatMaterialF(ActiveBackgroundColor);
            bgMesh = AppendMeshGO("background", mesh, backgroundMaterial, entry);
            bgMesh.transform.Rotate(Vector3.right, -90.0f); // ??

            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);

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

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

            AppendNewGO(textMesh, entry, false);

            cursor = GameObjectFactory.CreateRectangleGO("cursor", Height * 0.1f, Height * 0.8f, Colorf.VideoBlack, false);
            BoxModel.Translate(cursor, Vector2f.Zero, this.Bounds2D.CenterLeft, -Height * 0.1f);
            cursor.RotateD(Vector3f.AxisX, -90.0f);
            AppendNewGO(cursor, entry, false);
            cursor.SetVisible(false);
        }
コード例 #8
0
        // unit rectangle lying in plane
        public static fRectangleGameObject CreateRectangleGO(string sName, float fWidth, float fHeight, Colorf color, bool bCollider)
        {
            fMaterial mat = MaterialUtil.CreateFlatMaterialF(color);

            return(CreateRectangleGO(sName, fWidth, fHeight, mat, false, bCollider));
        }
コード例 #9
0
 // disc with radius=1, lying in plane, centered at (0,0)
 public static fDiscGameObject CreateDiscGO(string sName, float fRadius, Colorf color, bool bCollider)
 {
     return(CreateDiscGO(sName, fRadius, MaterialUtil.CreateFlatMaterialF(color), false, bCollider));
 }
コード例 #10
0
 // disc with radius=1, lying in plane, centered at (0,0)
 public static fRingGameObject CreateRingGO(string sName, float fInnerRadius, float fOuterRadius, Colorf color, bool bCollider)
 {
     return(CreateRingGO(sName, fInnerRadius, fOuterRadius, MaterialUtil.CreateFlatMaterialF(color), false, bCollider));
 }