virtual protected void make_materials()
        {
            float fAlpha = 0.5f;

            srcMaterial      = MaterialUtil.CreateTransparentMaterial(ColorUtil.CgRed, fAlpha);
            srcHoverMaterial = MaterialUtil.CreateStandardMaterial(ColorUtil.CgRed);
        }
Esempio n. 2
0
        // 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);
        }
Esempio n. 3
0
        /// <summary>
        /// This is very hacky.
        /// </summary>
        public static void AddDropShadow(HUDStandardItem item, Colorf color, float falloffWidth, Vector2f offset, float fZShift)
        {
            if (item is IBoxModelElement == false)
            {
                throw new Exception("HUDUtil.AddDropShadow: can only add drop shadow to IBoxModelElement");
            }

            // [TODO] need interface that provides a HUDShape?
            var   shape = item as IBoxModelElement;
            float w     = shape.Size2D.x + falloffWidth;
            float h     = shape.Size2D.y + falloffWidth;

            fRectangleGameObject meshGO = GameObjectFactory.CreateRectangleGO("shadow", w, h, color, false);

            meshGO.RotateD(Vector3f.AxisX, -90.0f);
            fMaterial dropMat = MaterialUtil.CreateDropShadowMaterial(color, w, h, falloffWidth);

            meshGO.SetMaterial(dropMat);

            item.AppendNewGO(meshGO, item.RootGameObject, false);
            BoxModel.Translate(meshGO, offset, fZShift);

            Vector3 posW = item.RootGameObject.PointToWorld(meshGO.GetLocalPosition());

            ((Material)dropMat).SetVector("_Center", new Vector4(posW.x, posW.y, posW.z, 0));
        }
Esempio n. 4
0
        static public GameObject EmitDebugLine(string name, Vector3f start, Vector3f end, float diameter, Colorf startColor, Colorf endColor,
                                               GameObject parent = null, bool bIsInWorldPos = true)
        {
            if (FPlatform.InMainThread() == false)
            {
                ThreadMailbox.PostToMainThread(() => { DebugUtil.EmitDebugLine(name, start, end, diameter, startColor, endColor, parent, bIsInWorldPos); });
                return(null);
            }

            GameObject line = new GameObject();

            line.SetName(name);
            line.transform.position = (bIsInWorldPos) ? start : Vector3f.Zero;
            line.AddComponent <LineRenderer>();
            LineRenderer lr = line.GetComponent <LineRenderer>();

            lr.material   = MaterialUtil.CreateParticlesMaterial();
            lr.startColor = startColor;
            lr.endColor   = endColor;
            lr.startWidth = lr.endWidth = diameter;
            lr.SetPosition(0, start);
            lr.SetPosition(1, end);

            if (parent != null)
            {
                lr.useWorldSpace = bIsInWorldPos;
                line.transform.SetParent(parent.transform, bIsInWorldPos);
            }

            return(line);
        }
Esempio n. 5
0
        // Use this for initialization
        public void Start()
        {
            dx = 0;
            dy = 0;
            vPlaneCursorPos = Vector3.zero;
            vSceneCursorPos = vPlaneCursorPos;

            CursorDefaultMaterial   = MaterialUtil.CreateTransparentMaterial(Color.grey, 0.2f);
            CursorHitMaterial       = MaterialUtil.CreateTransparentMaterial(Color.yellow, 0.8f);
            CursorCapturingMaterial = MaterialUtil.CreateTransparentMaterial(Color.cyan, 0.3f);

            CursorVisualAngleInDegrees = 1.5f;

            Cursor      = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            Cursor.name = "cursor";
            Cursor.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
            MeshRenderer ren = Cursor.GetComponent <MeshRenderer> ();

            ren.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            ren.receiveShadows    = false;
            ren.material          = CursorDefaultMaterial;

            xformObject      = GameObject.CreatePrimitive(PrimitiveType.Plane);
            xformObject.name = "cursor_plane";
            MeshRenderer ren2 = xformObject.GetComponent <MeshRenderer> ();

            ren2.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
            ren2.receiveShadows    = false;
            ren2.material          = MaterialUtil.CreateTransparentMaterial(Color.cyan, 0.2f);
            ren2.enabled           = false;
        }
Esempio n. 6
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();
        }
Esempio n. 7
0
        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);
        }
 // 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;
 }
Esempio n. 9
0
        public PivotSO Create(SOMaterial sphereMaterial, Material frameMaterial, int nSphereLayer = -1)
        {
            // [TODO] replace frame geometry with line renderer ?
            // [TODO] still cast shadows  (semitransparent objects don't cast shadows, apparently)
            // [TODO] maybe render solid when not obscured by objects? use raycast in PreRender?

            AssignSOMaterial(sphereMaterial);       // need to do this to setup BaseSO material stack

            pivot  = new GameObject(UniqueNames.GetNext("Pivot"));
            meshGO = AppendUnityPrimitiveGO("pivotMesh", PrimitiveType.Sphere, CurrentMaterial, pivot);
            meshGO.transform.localScale = 0.9f * Vector3.one;

            if (frameMaterial != null)
            {
                frameMesh = UnityUtil.CreateMeshGO("pivotFrame", "icon_meshes/axis_frame", 1.0f,
                                                   UnityUtil.MeshAlignOption.NoAlignment, frameMaterial, false);
                frameMesh.AddComponent <IgnoreMaterialChanges>();
                MaterialUtil.DisableShadows(frameMesh);
                AppendNewGO(frameMesh, pivot, false);
            }

            if (nSphereLayer >= 0)
            {
                meshGO.SetLayer(nSphereLayer);
            }

            increment_timestamp();
            return(this);
        }
Esempio n. 10
0
        public virtual PivotSO Create(SOMaterial shapeMaterial, SOMaterial frameMaterial = null, int nShapeLayer = -1)
        {
            // [TODO] replace frame geometry with line renderer ?
            // [TODO] still cast shadows  (semitransparent objects don't cast shadows, apparently)
            // [TODO] maybe render solid when not obscured by objects? use raycast in PreRender?

            AssignSOMaterial(shapeMaterial);       // need to do this to setup BaseSO material stack

            pivotGO = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("Pivot"));

            shapeGO = create_pivot_shape();
            AppendNewGO(shapeGO, pivotGO, false);

            pivotGO.AddChild(shapeGO);

            if (frameMaterial != null)
            {
                this.frameMaterial = frameMaterial;

                frameGO = UnityUtil.CreateMeshGO("pivotFrame", "icon_meshes/axis_frame", 1.0f,
                                                 UnityUtil.MeshAlignOption.NoAlignment, MaterialUtil.ToUnityMaterial(frameMaterial), false);
                MaterialUtil.SetIgnoreMaterialChanges(frameGO);
                MaterialUtil.DisableShadows(frameGO);
                AppendNewGO(frameGO, pivotGO, false);
            }

            if (nShapeLayer >= 0)
            {
                shapeGO.SetLayer(nShapeLayer);
            }

            increment_timestamp();
            return(this);
        }
Esempio n. 11
0
        public static void ShowToastStaticPopupMessage(string sImagePath, Cockpit cockpit)
        {
            Material mat     = MaterialUtil.CreateTransparentImageMaterial(sImagePath);
            float    fAspect = (float)mat.mainTexture.width / (float)mat.mainTexture.height;
            float    fScale  = 2.0f;    // 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, 3.0f, 30, -10);
            UnityUtil.TranslateInFrame(message.RootGameObject, 0.75f, -0.5f, 0.0f, CoordSpace.WorldCoords);
            message.Name = "popup";
            cockpit.AddUIElement(message, true);
            message.OnDismissed += (s, e) => {
                AnimatedDimiss_Cockpit(message, cockpit);
            };
            AnimatedShow(message, 0.5f);
        }
Esempio n. 12
0
        virtual public bool EndCapture(InputEvent e)
        {
            if (activeWidget != null)
            {
                activeWidget.EndCapture(targetWrapper);
                MaterialUtil.SetMaterial(activeWidget.RootGameObject, activeWidget.StandardMaterial);

                // tell wrapper we are done with capture, so it should bake transform/etc
                bool bModified = targetWrapper.DoneTransformation(EmitChanges);
                if (bModified)
                {
                    // update gizmo
                    onTransformModified(null);
                    // allow client/subclass to add any other change records
                    OnTransformInteractionEnd();
                    // gizmos drop change events by default
                    if (EmitChanges)
                    {
                        Scene.History.PushInteractionCheckpoint();
                    }
                }

                activeWidget = null;
            }
            return(true);
        }
Esempio n. 13
0
 public override void Setup()
 {
     sphereGO       = GameObjectFactory.CreateMeshGO("sphere", UnityUtil.GetSphereMesh(), false);
     sphereMaterial = MaterialF();
     sphereGO.SetMaterial(sphereMaterial);
     sphereMaterial.color = ColorF();
     MaterialUtil.DisableShadows(sphereGO);
 }
Esempio n. 14
0
 public virtual void EndHover(Ray3f ray)
 {
     if (hoverWidget != null)
     {
         MaterialUtil.SetMaterial(hoverWidget.RootGameObject, hoverWidget.StandardMaterial);
         hoverWidget = null;
     }
 }
Esempio n. 15
0
 override public void DisableShadows()
 {
     MaterialUtil.DisableShadows(shapeGO, true, true);
     if (frameGO != null)
     {
         MaterialUtil.DisableShadows(frameGO, true, true);
     }
 }
Esempio n. 16
0
 override public void DisableShadows()
 {
     MaterialUtil.DisableShadows(meshGO, true, true);
     if (frameMesh != null)
     {
         MaterialUtil.DisableShadows(frameMesh, true, true);
     }
 }
Esempio n. 17
0
        public virtual fMaterial MakeHoverMaterial(AxisGizmoFlags widget)
        {
            switch (widget)
            {
            case AxisGizmoFlags.AxisRotateX:
            case AxisGizmoFlags.AxisTranslateX:
            case AxisGizmoFlags.PlaneTranslateX:
                if (XHover == null)
                {
                    XHover = MaterialUtil.CreateTransparentMaterial(Colorf.VideoRed);
                    if (OverrideRenderQueue != -1)
                    {
                        XHover.renderQueue = OverrideRenderQueue;
                    }
                }
                return(XHover);

            case AxisGizmoFlags.AxisRotateY:
            case AxisGizmoFlags.AxisTranslateY:
            case AxisGizmoFlags.PlaneTranslateY:
                if (YHover == null)
                {
                    YHover = MaterialUtil.CreateTransparentMaterial(Colorf.VideoGreen);
                    if (OverrideRenderQueue != -1)
                    {
                        YHover.renderQueue = OverrideRenderQueue;
                    }
                }
                return(YHover);

            case AxisGizmoFlags.AxisRotateZ:
            case AxisGizmoFlags.AxisTranslateZ:
            case AxisGizmoFlags.PlaneTranslateZ:
                if (ZHover == null)
                {
                    ZHover = MaterialUtil.CreateTransparentMaterial(Colorf.VideoBlue);
                    if (OverrideRenderQueue != -1)
                    {
                        ZHover.renderQueue = OverrideRenderQueue;
                    }
                }
                return(ZHover);

            case AxisGizmoFlags.UniformScale:
                if (AllHover == null)
                {
                    AllHover = MaterialUtil.CreateTransparentMaterial(Colorf.VideoWhite);
                    if (OverrideRenderQueue != -1)
                    {
                        AllHover.renderQueue = OverrideRenderQueue;
                    }
                }
                return(AllHover);

            default:
                throw new Exception("DefaultAxisGizmoWidgetFactory.MakeHoverMaterial: invalid widget type " + widget.ToString());
            }
        }
Esempio n. 18
0
 public void BeginSetWorldScale(Frame3f center, Frame3f plane, float minr)
 {
     deadzone_r = minr;
     hitFrame   = plane;
     mYes       = MaterialUtil.CreateTransparentMaterial(ColorUtil.PivotYellow, 0.5f);
     mNo        = MaterialUtil.CreateTransparentMaterial(ColorUtil.MiddleGrey, 0.3f);
     go         = UnityUtil.CreatePrimitiveGO("worldscale_ball", PrimitiveType.Sphere, mNo);
     UnityUtil.SetGameObjectFrame(go, center, CoordSpace.WorldCoords);
 }
Esempio n. 19
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);
 }
Esempio n. 20
0
        /// <summary>
        /// Create GO / geometry for a single tick, centered at origin
        /// </summary>
        protected virtual fGameObject create_tick_go(Vector2f tickSize, fMaterial baseMaterial)
        {
            fRectangleGameObject go = GameObjectFactory.CreateRectangleGO("tick", tickSize.x, tickSize.y,
                                                                          baseMaterial, true, false);

            MaterialUtil.DisableShadows(go);
            go.RotateD(Vector3f.AxisX, -90.0f);
            return(go);
        }
Esempio n. 21
0
        /// <summary>
        /// Create the GO that acts as the "handle", ie identifies selected position on timelin
        /// Default is a kind of ugly large triangle underneath midline...
        /// Override to provide your own visuals. Return null for no handle.
        /// </summary>
        protected virtual fGameObject create_handle_go(fMaterial handleMaterial)
        {
            fTriangleGameObject handle = GameObjectFactory.CreateTriangleGO(
                "handle", Height, Height, handleMaterial.color, true);

            MaterialUtil.DisableShadows(handle);
            handle.RotateD(Vector3f.AxisX, -90.0f); // ??
            return(handle);
        }
        public void Create(SOMaterial useMaterial, GameObject parent, float fMinDimension)
        {
            meshObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            meshObject.GetComponent <MeshRenderer>().material = MaterialUtil.ToUnityMaterial(useMaterial);
            bUpdatePending = true;

            meshObject.transform.SetParent(parent.transform, false);

            Height = Width = Depth = fMinDimension;
        }
Esempio n. 23
0
 public void Start()
 {
     fadeObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
     //fadeObject.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
     fadeObject.GetComponent <MeshRenderer>().material = MaterialUtil.CreateFlatMaterial(Color.black, 0.0f);
     fadeObject.SetName("fade_sphere");
     UnityUtil.ReverseMeshOrientation(fadeObject.GetMesh());
     fadeObject.transform.SetParent(UseCamera.transform, false);
     fadeObject.SetLayer(FPlatform.HUDLayer);
 }
Esempio n. 24
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);
 }
Esempio n. 25
0
        // creates a button that is just the mesh
        public void Create(fMesh mesh, fMaterial meshMaterial, float fScale, Quaternionf transform)
        {
            button = GameObjectFactory.CreateParentGO(UniqueNames.GetNext("HUDButton"));

            iconMesh = AppendMeshGO("shape", mesh, meshMaterial, button);
            iconMesh.SetLocalScale(new Vector3f(fScale, fScale, fScale));
            iconMesh.SetLocalRotation(iconMesh.GetLocalRotation() * transform);
            MaterialUtil.DisableShadows(iconMesh);

            standard_mat = new fMaterial(meshMaterial);
        }
Esempio n. 26
0
 protected void update_material()
 {
     if (Enabled == false && DisabledMaterial != null)
     {
         MaterialUtil.SetMaterial(buttonMesh, DisabledMaterial);
     }
     else
     {
         MaterialUtil.SetMaterial(buttonMesh, StandardMaterial);
     }
 }
Esempio n. 27
0
        public FScene(FContext context)
        {
            this.context = context;

            history       = new ChangeHistory();
            history_stack = new List <ChangeHistory>();
            TypeRegistry  = new SORegistry();

            initialize_scene_root();

            // initialize materials
            DefaultSOMaterial = new SOMaterial()
            {
                Name = "DefaultSO",
                Type = SOMaterial.MaterialType.StandardRGBColor, RGBColor = ColorUtil.StandardBeige
            };
            DefaultCurveSOMaterial = new SOMaterial()
            {
                Name = "DefaultCurveSO",
                Type = SOMaterial.MaterialType.UnlitRGBColor, RGBColor = Colorf.DarkSlateGrey
            };
            DefaultMeshSOMaterial = new SOMaterial()
            {
                Name = "DefaultMeshSO",
                Type = SOMaterial.MaterialType.PerVertexColor, RGBColor = Colorf.White
            };
            NewSOMaterial = new SOMaterial()
            {
                Name = "NewSO",
                Type = SOMaterial.MaterialType.StandardRGBColor, RGBColor = Colorf.CornflowerBlue
            };
            TransparentNewSOMaterial = new SOMaterial()
            {
                Name = "NewSO",
                Type = SOMaterial.MaterialType.TransparentRGBColor, RGBColor = new Colorf(Colorf.CornflowerBlue, 0.5f)
            };
            PivotSOMaterial = new SOMaterial()
            {
                Name = "PivotSO",
                Type = SOMaterial.MaterialType.TransparentRGBColor, RGBColor = ColorUtil.PivotYellow.SetAlpha(0.75f)
            };
            FrameSOMaterial = new SOMaterial()
            {
                Name = "PivotFrame",
                Type = SOMaterial.MaterialType.StandardRGBColor, RGBColor = ColorUtil.DarkGrey
            };

            SelectedMaterial = MaterialUtil.CreateStandardMaterial(ColorUtil.SelectionGold);
            FrameMaterial    = MaterialUtil.CreateStandardMaterial(ColorUtil.DarkGrey);
            PivotMaterial    = MaterialUtil.ToMaterialf(PivotSOMaterial);

            defaultPrimitiveType = SOTypes.Cylinder;
        }
Esempio n. 28
0
 public virtual void UpdateHover(Ray3f ray, UIRayHit hit)
 {
     if (hoverWidget != null)
     {
         EndHover(ray);
     }
     if (Widgets.ContainsKey(hit.hitGO))
     {
         hoverWidget = Widgets[hit.hitGO];
         MaterialUtil.SetMaterial(hoverWidget.RootGameObject, hoverWidget.HoverMaterial);
     }
 }
Esempio n. 29
0
 virtual public bool UpdateCapture(InputEvent e)
 {
     // update capture if we have an active widget
     if (activeWidget != null)
     {
         // [TODO] can remove this once we fix test/begin capture
         MaterialUtil.SetMaterial(activeWidget.RootGameObject, activeWidget.HoverMaterial);
         activeWidget.UpdateCapture(targetWrapper, e.ray);
         return(true);
     }
     return(false);
 }
Esempio n. 30
0
        public void Start()
        {
            ShowTarget = false;

            targetGO        = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            visibleMaterial = MaterialUtil.CreateTransparentMaterial(Color.red, 0.8f);
            hiddenMaterial  = MaterialUtil.CreateTransparentMaterial(Color.red, 0.4f);
            targetGO.GetComponent <MeshRenderer>().material = hiddenMaterial;
            targetGO.SetLayer(FPlatform.WidgetOverlayLayer);
            MaterialUtil.DisableShadows(targetGO);
            targetGO.SetName("camera_target");
        }