Пример #1
0
 protected void update_material()
 {
     if (Enabled == false && DisabledMaterial != null)
     {
         buttonMesh.SetMaterial(DisabledMaterial, true);
     }
     else
     {
         buttonMesh.SetMaterial(StandardMaterial, true);
     }
 }
Пример #2
0
 public override void Setup()
 {
     sphereGO       = GameObjectFactory.CreateMeshGO("sphere", UnityUtil.GetSphereMesh(), false);
     sphereMaterial = MaterialF();
     sphereGO.SetMaterial(sphereMaterial);
     sphereMaterial.color = ColorF();
     MaterialUtil.DisableShadows(sphereGO);
 }
Пример #3
0
 public override void Setup()
 {
     planeGO       = GameObjectFactory.CreateMeshGO("section_plane", UnityUtil.GetTwoSidedPlaneMesh(), false);
     planeMaterial = MaterialF();
     planeGO.SetMaterial(planeMaterial);
     planeMaterial.color = ColorF();
     MaterialUtil.DisableShadows(planeGO);
     //planeGO.SetLayer(FPlatform.WidgetOverlayLayer);
 }
Пример #4
0
 public void Start()
 {
     fadeObject = new fGameObject(GameObject.CreatePrimitive(PrimitiveType.Sphere), FGOFlags.NoFlags);
     //fadeObject.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
     fadeObject.SetMaterial(MaterialUtil.CreateFlatMaterial(Color.black, 0.0f), true);
     fadeObject.SetName("fade_sphere");
     UnityUtil.ReverseMeshOrientation(fadeObject.GetMesh());
     fadeObject.SetParent(UseCamera.GameObject(), false);
     fadeObject.SetLayer(FPlatform.HUDLayer);
 }
Пример #5
0
        public void Create(Cockpit cockpit)
        {
            base.Create();

            float fHUDRadius    = 0.75f;
            float fButtonRadius = 0.06f;

            Color bgColor = new Color(0.7f, 0.7f, 1.0f, 0.7f);

            Material bgMaterial = (bgColor.a == 1.0f) ?
                                  MaterialUtil.CreateStandardMaterial(bgColor) : MaterialUtil.CreateTransparentMaterial(bgColor);

            List <SOMaterial> materials = new List <SOMaterial>()
            {
                SOMaterial.CreateStandard("default", ColorUtil.StandardBeige),
                SOMaterial.CreateStandard("standard_white", Colorf.VideoWhite),
                SOMaterial.CreateStandard("standard_black", Colorf.VideoBlack),
                SOMaterial.CreateStandard("middle_grey", new Colorf(0.5f)),

                SOMaterial.CreateStandard("standard_green", Colorf.VideoGreen),
                SOMaterial.CreateStandard("forest_green", Colorf.ForestGreen),
                SOMaterial.CreateStandard("teal", Colorf.Teal),
                SOMaterial.CreateStandard("light_green", Colorf.LightGreen),

                SOMaterial.CreateStandard("standard_blue", Colorf.VideoBlue),
                SOMaterial.CreateStandard("navy", Colorf.Navy),
                SOMaterial.CreateStandard("cornflower_blue", Colorf.CornflowerBlue),
                SOMaterial.CreateStandard("light_steel_blue", Colorf.LightSteelBlue),

                SOMaterial.CreateStandard("standard_red", Colorf.VideoRed),
                SOMaterial.CreateStandard("fire_red", Colorf.FireBrick),
                SOMaterial.CreateStandard("hot_pink", Colorf.HotPink),
                SOMaterial.CreateStandard("light_pink", Colorf.LightPink),


                SOMaterial.CreateStandard("standard_yellow", Colorf.VideoYellow),
                SOMaterial.CreateStandard("standard_orange", Colorf.Orange),
                SOMaterial.CreateStandard("saddle_brown", Colorf.SaddleBrown),
                SOMaterial.CreateStandard("wheat", Colorf.Wheat),


                SOMaterial.CreateStandard("standard_cyan", Colorf.VideoCyan),
                SOMaterial.CreateStandard("standard_magenta", Colorf.VideoMagenta),
                SOMaterial.CreateStandard("silver", Colorf.Silver),
                SOMaterial.CreateStandard("dark_slate_grey", Colorf.DarkSlateGrey)
            };


            float        fRight     = -41.0f;
            float        df         = -7.25f;
            float        df_fudge   = -0.2f;
            List <float> AngleSteps = new List <float>()
            {
                fRight, fRight + df, fRight + 2 * df, fRight + 3 * df
            };
            float fVertStep = 6.75f;
            float fTop      = 2.0f;

            int ri = 0, ci = 0;

            foreach (SOMaterial m in materials)
            {
                float fXFudge = df_fudge * (float)ri * (float)ci;
                float fX      = AngleSteps[ci++] + fXFudge;
                float fY      = fTop - (float)ri * fVertStep;
                if (ci == AngleSteps.Count)
                {
                    ci = 0; ri++;
                }

                var button = add_material_button(cockpit, m.Name, fHUDRadius,
                                                 fX, fY, fButtonRadius, bgMaterial, m);
                AddChild(button);
                buttons.Add(button);
            }


            fMesh    iconMesh     = null;
            Material iconMaterial = null;

            try {
                iconMesh     = new fMesh(Resources.Load <Mesh>("tool_icons/star"));
                iconMaterial = MaterialUtil.CreateStandardVertexColorMaterial(Color.white);
            } catch { }
            if (iconMesh == null)
            {
                iconMesh     = new fMesh(UnityUtil.GetPrimitiveMesh(PrimitiveType.Sphere));
                iconMaterial = MaterialUtil.CreateStandardMaterial(Color.yellow);
            }
            indicatorGO = new fMeshGameObject(iconMesh);
            indicatorGO.SetName("active_star");
            indicatorGO.SetMesh(iconMesh);
            indicatorGO.SetMaterial(iconMaterial);
            indicatorGO.SetLocalScale(fIndicatorSize * Vector3f.One);
            indicatorGO.SetLocalPosition(indicatorGO.GetLocalPosition() +
                                         fIndicatorShift * (Vector3f.AxisY - 4 * Vector3f.AxisZ + Vector3f.AxisX));

            indicatorButton = buttons[0];   // this is default material
            indicatorButton.AppendNewGO(indicatorGO, indicatorButton.RootGameObject, false);
        }
Пример #6
0
        public void Create(Cockpit cockpit)
        {
            base.Create();

            float    fHUDRadius    = 0.7f;
            float    fButtonRadius = 0.08f;
            Color    bgColor       = new Color(0.7f, 0.7f, 1.0f, 0.7f);
            Material bgMaterial    = (bgColor.a == 1.0f) ?
                                     MaterialUtil.CreateStandardMaterial(bgColor) : MaterialUtil.CreateTransparentMaterial(bgColor);
            Material primMaterial = MaterialUtil.CreateStandardMaterial(Color.yellow);


            var addCylinderButton = add_primitive_button(cockpit, "addCylinder", fHUDRadius, -45.0f, 0.0f,
                                                         PrimitiveType.Cylinder, 0.7f, bgMaterial, primMaterial,
                                                         () => {
                return(new CylinderSO().Create(cockpit.Scene.DefaultSOMaterial));
            });

            AddChild(addCylinderButton);
            buttons.Add(addCylinderButton);
            buttonTypes[addCylinderButton] = SOTypes.Cylinder;


            var addBoxButton = add_primitive_button(cockpit, "addBox", fHUDRadius, -45.0f, -15.0f,
                                                    PrimitiveType.Cube, 0.7f, bgMaterial, primMaterial,
                                                    () => {
                return(new BoxSO().Create(cockpit.Scene.DefaultSOMaterial));
            });

            AddChild(addBoxButton);
            buttons.Add(addBoxButton);
            buttonTypes[addBoxButton] = SOTypes.Box;


            var addSphereButton = add_primitive_button(cockpit, "addSphere", fHUDRadius, -45.0f, -30.0f,
                                                       PrimitiveType.Sphere, 0.85f, bgMaterial, primMaterial,
                                                       () => {
                return(new SphereSO().Create(cockpit.Scene.DefaultSOMaterial));
            });

            AddChild(addSphereButton);
            buttons.Add(addSphereButton);
            buttonTypes[addSphereButton] = SOTypes.Sphere;


            var addPivotButton = add_primitive_button(cockpit, "addPivot", fHUDRadius, -60.0f, 0.0f,
                                                      PrimitiveType.Sphere, 0.7f, bgMaterial, primMaterial,
                                                      () => {
                return(new PivotSO().Create(cockpit.Scene.PivotSOMaterial, cockpit.Scene.FrameSOMaterial,
                                            FPlatform.WidgetOverlayLayer));
            },
                                                      new pivotIconGenerator()
            {
                SphereMaterial = cockpit.Scene.SelectedMaterial,
                FrameMaterial  = cockpit.Scene.FrameMaterial, PrimSize = fButtonRadius * 0.7f
            });

            AddChild(addPivotButton);
            buttons.Add(addPivotButton);
            buttonTypes[addPivotButton] = SOTypes.Pivot;


            //var addCurveButton = add_curve_button(cockpit, "addCurve", fHUDRadius, -60.0f, -15.0f,
            //    bgMaterial, primMaterial,
            //    () => {
            //        return new PolyCurveSO().Create(cockpit.ActiveScene.DefaultSOMaterial);
            //    });
            //AddChild(addCurveButton);


            /*
             *          HUDButton addBunnyButton = HUDBuilder.CreateGeometryIconClickButton(
             *              new HUDShape(HUDShapeType.Disc, fButtonRadius ),
             *              fHUDRadius, -45.0f, -30.0f, bgColor,
             *              new meshIconGenerator() { MeshPath = "icon_meshes/bunny_1k", UseMaterial = primMaterial, UseSize = fButtonRadius * 0.7f });
             *          addBunnyButton.Name = "addBunnyButton";
             *          addBunnyButton.OnClicked += (s, e) => {
             *              // TODO add existing mesh to scene
             *              cockpit.Parent.Scene.AddBox();
             *          };
             *          cockpit.AddUIElement(addBunnyButton, true);
             */



            // initialize selected-primitive indicator icon
            fMesh     iconMesh     = null;
            fMaterial iconMaterial = null;

            try {
                iconMesh     = new fMesh(Resources.Load <Mesh>("tool_icons/star"));
                iconMaterial = MaterialUtil.CreateStandardVertexColorMaterialF(Color.white);
            } catch { }
            if (iconMesh == null)
            {
                iconMesh     = new fMesh(UnityUtil.GetPrimitiveMesh(PrimitiveType.Sphere));
                iconMaterial = MaterialUtil.CreateStandardMaterialF(Color.yellow);
            }
            indicatorGO = new fMeshGameObject(iconMesh);
            indicatorGO.SetName("active_star");
            indicatorGO.SetMesh(iconMesh);
            indicatorGO.SetMaterial(iconMaterial);
            indicatorGO.SetLocalScale(fIndicatorSize * Vector3f.One);
            indicatorGO.SetLocalPosition(indicatorGO.GetLocalPosition() +
                                         fIndicatorShift * (Vector3f.AxisY - 1 * Vector3f.AxisZ + Vector3f.AxisX));

            indicatorButton = buttons[0];   // this is default material
            indicatorButton.AppendNewGO(indicatorGO, indicatorButton.RootGameObject, false);
        }