private static void DrawSelectedObjectHighlight(MyHudSelectedObject selection, MyHudObjectHighlightStyleData?data)
        {
            if (selection.InteractiveObject.RenderObjectID == -1)
            {
                // Invalid render object ID
                return;
            }

            switch (selection.HighlightStyle)
            {
            case MyHudObjectHighlightStyle.HighlightStyle1:
            {
                DrawSelectedObjectHighlight1(selection, data.Value.AtlasTexture, data.Value.TextureCoord);
                break;
            }

            case MyHudObjectHighlightStyle.HighlightStyle2:
            {
                int[] sectionIndices = selection.SectionIndices;
                if (sectionIndices != null && selection.SectionIndices.Length == 0)
                {
                    // There was a problem with sections look-up, fallback to previous highlight style
                    DrawSelectedObjectHighlight1(selection, data.Value.AtlasTexture, data.Value.TextureCoord);
                    break;
                }

                DrawSelectedObjectHighlight2(selection);
                break;
            }
            }

            selection.Visible = true;
        }
        public static void HandleSelectedObjectHighlight(MyHudSelectedObject selection, MyHudObjectHighlightStyleData?data)
        {
            if (selection.PreviousObject.Instance != null)
            {
                RemoveObjectHighlightInternal(ref selection.PreviousObject, true);
            }

            switch (selection.State)
            {
            case MyHudSelectedObjectState.VisibleStateSet:
            {
                if (selection.Visible && (selection.HighlightStyle == MyHudObjectHighlightStyle.HighlightStyle1 ||
                                          selection.VisibleRenderID != selection.CurrentObject.Instance.RenderObjectID))
                {
                    MyGuiScreenHudBase.DrawSelectedObjectHighlight(selection, data);
                }

                break;
            }

            case MyHudSelectedObjectState.MarkedForVisible:
            {
                MyGuiScreenHudBase.DrawSelectedObjectHighlight(selection, data);
                break;
            }

            case MyHudSelectedObjectState.MarkedForNotVisible:
            {
                MyGuiScreenHudBase.RemoveObjectHighlight(selection);
                break;
            }
            }
        }
        private static void DrawSelectedObjectHighlight2(MyHudSelectedObject selection)
        {
            Color color     = MyDefinitionManager.Static.EnvironmentDefinition.ContourHighlightColor;
            float thickness = MyDefinitionManager.Static.EnvironmentDefinition.ContourHighlightThickness;

            MyRenderProxy.UpdateModelHighlight((uint)selection.InteractiveObject.RenderObjectID, 0, null, selection.SectionIndices, null, color, thickness);
        }
Exemplo n.º 4
0
        private static void DrawSelectedObjectHighlight2(MyHudSelectedObject selection)
        {
            Color color             = MyDefinitionManager.Static.EnvironmentDefinition.ContourHighlightColor;
            float thickness         = MyDefinitionManager.Static.EnvironmentDefinition.ContourHighlightThickness;
            ulong pulseTimeInFrames = (ulong)Math.Round(MyDefinitionManager.Static.EnvironmentDefinition.HighlightPulseInSeconds * MyEngineConstants.UPDATE_STEPS_PER_SECOND);

            MyRenderProxy.UpdateModelHighlight((uint)selection.InteractiveObject.RenderObjectID, selection.SectionIndices, selection.SubpartIndices, color, thickness, pulseTimeInFrames);
        }
        private static void RemoveObjectHighlight(MyHudSelectedObject selection)
        {
            RemoveObjectHighlightInternal(ref selection.CurrentObject, false);

            selection.Visible = false;
            if (!selection.KeepObjectReference)
            {
                selection.CurrentObject.Reset();
            }
        }
Exemplo n.º 6
0
        private static void DrawSelectedObjectHighlightOutline(MyHudSelectedObject selection)
        {
            Color color             = MySector.EnvironmentDefinition.ContourHighlightColor;
            float thickness         = MySector.EnvironmentDefinition.ContourHighlightThickness;
            ulong pulseTimeInFrames = (ulong)Math.Round(MySector.EnvironmentDefinition.HighlightPulseInSeconds * MyEngineConstants.UPDATE_STEPS_PER_SECOND);

            if (!MySession.Static.GetComponent <MyHighlightSystem>().IsReserved(selection.InteractiveObject.Owner.EntityId))
            {
                MyRenderProxy.UpdateModelHighlight((uint)selection.InteractiveObject.RenderObjectID, selection.SectionIndices, selection.SubpartIndices, color, thickness, pulseTimeInFrames, selection.InteractiveObject.InstanceID);
            }
        }
Exemplo n.º 7
0
        private static void DrawSelectedObjectHighlightOutline(MyHudSelectedObject selection)
        {
            Color color              = MySector.EnvironmentDefinition.ContourHighlightColor;
            float thickness          = MySector.EnvironmentDefinition.ContourHighlightThickness;
            float pulseTimeInSeconds = MySector.EnvironmentDefinition.HighlightPulseInSeconds;

            if (MySession.Static.GetComponent <MyHighlightSystem>() != null && !MySession.Static.GetComponent <MyHighlightSystem>().IsReserved(selection.InteractiveObject.Owner.EntityId))
            {
                MyRenderProxy.UpdateModelHighlight((uint)selection.InteractiveObject.RenderObjectID, selection.SectionNames, selection.SubpartIndices, color, thickness, pulseTimeInSeconds, selection.InteractiveObject.InstanceID);
            }
        }
Exemplo n.º 8
0
        private static void DrawSelectedObjectHighlightOutline(MyHudSelectedObject selection)
        {
            Color color             = MySector.EnvironmentDefinition.ContourHighlightColor;
            float thickness         = MySector.EnvironmentDefinition.ContourHighlightThickness;
            ulong pulseTimeInFrames = (ulong)Math.Round(MySector.EnvironmentDefinition.HighlightPulseInSeconds * MyEngineConstants.UPDATE_STEPS_PER_SECOND);
            var   data = new MyHighlightSystem.MyHighlightData(
                entityId: selection.InteractiveObject.Owner.EntityId,
                outlineColor: color,
                thickness: (int)thickness,
                pulseTimeInFrames: pulseTimeInFrames
                );

            MySession.Static.GetComponent <MyHighlightSystem>().RequestHighlightChange(data);
        }
Exemplo n.º 9
0
        public static void DrawSelectionCorner(string atlasTexture, MyHudSelectedObject selection, MyAtlasTextureCoordinate textureCoord, Vector2 scale, Vector2 pos, Vector2 rightVector, float textureScale)
        {
            if (MyVideoSettingsManager.IsTripleHead())
            {
                pos.X = pos.X * 3;
            }

            VRageRender.MyRenderProxy.DrawSpriteAtlas(
                atlasTexture,
                pos,
                textureCoord.Offset,
                textureCoord.Size,
                rightVector,
                scale,
                selection.Color,
                selection.HalfSize / MyGuiManager.GetHudSize() * textureScale);
        }
Exemplo n.º 10
0
        private static void DrawSelectedObjectHighlight(MyHudSelectedObject selection, MyHudObjectHighlightStyleData?data)
        {
            if (selection.InteractiveObject.RenderObjectID == -1)
            {
                // Invalid render object ID
                return;
            }

            switch (selection.HighlightStyle)
            {
            case MyHudObjectHighlightStyle.DummyHighlight:
            {
                DrawSelectedObjectHighlightDummy(selection, data.Value.AtlasTexture, data.Value.TextureCoord);
                break;
            }

            case MyHudObjectHighlightStyle.OutlineHighlight:
            {
                int[] sectionIndices = selection.SectionIndices;
                if (sectionIndices != null && selection.SectionIndices.Length == 0 &&
                    selection.SubpartIndices == null)
                {
                    // There was a problem with sections look-up, fallback to previous highlight style
                    DrawSelectedObjectHighlightDummy(selection, data.Value.AtlasTexture, data.Value.TextureCoord);
                }
                else
                {
                    DrawSelectedObjectHighlightOutline(selection);
                }
                break;
            }

            case MyHudObjectHighlightStyle.None:
            {
                return;
            }

            default:
                throw new Exception("Unknown highlight style");
            }

            selection.Visible = true;
        }
        public static void DrawSelectedObjectHighlight1(MyHudSelectedObject selection, string atlasTexture, MyAtlasTextureCoordinate textureCoord)
        {
            var rect = MyGuiManager.GetSafeFullscreenRectangle();

            Vector2 hudSize = new Vector2(rect.Width, rect.Height);

            var          worldViewProj   = selection.InteractiveObject.ActivationMatrix * MySector.MainCamera.ViewMatrix * (MatrixD)MySector.MainCamera.ProjectionMatrix;
            BoundingBoxD screenSpaceAabb = new BoundingBoxD(-Vector3D.One / 2, Vector3D.One / 2).Transform(worldViewProj);
            var          min             = new Vector2((float)screenSpaceAabb.Min.X, (float)screenSpaceAabb.Min.Y);
            var          max             = new Vector2((float)screenSpaceAabb.Max.X, (float)screenSpaceAabb.Max.Y);

            var minToMax = min - max;

            min = min * 0.5f + 0.5f * Vector2.One;
            max = max * 0.5f + 0.5f * Vector2.One;

            min.Y = 1 - min.Y;
            max.Y = 1 - max.Y;

            float textureScale = (float)Math.Pow(Math.Abs(minToMax.X), 0.35f) * 2.5f;

            if (selection.InteractiveObject.ShowOverlay)
            {
                BoundingBoxD one   = new BoundingBoxD(new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, 0.5f, 0.5f));
                Color        color = Color.Gold;
                color *= 0.4f;
                var m            = selection.InteractiveObject.ActivationMatrix;
                var localToWorld = MatrixD.Invert(selection.InteractiveObject.WorldMatrix);
                //MySimpleObjectDraw.DrawTransparentBox(ref m, ref one, ref color, MySimpleObjectRasterizer.Solid, 0, 0.05f, "Square", null, true);

                MySimpleObjectDraw.DrawAttachedTransparentBox(ref m, ref one, ref color, selection.InteractiveObject.RenderObjectID,
                                                              ref localToWorld, MySimpleObjectRasterizer.Solid, 0, 0.05f, "Square", null, true);
            }

            if (MyFakes.ENABLE_USE_OBJECT_CORNERS)
            {
                DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, min, -Vector2.UnitY, textureScale);
                DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, new Vector2(min.X, max.Y), Vector2.UnitX, textureScale);
                DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, new Vector2(max.X, min.Y), -Vector2.UnitX, textureScale);
                DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, max, Vector2.UnitY, textureScale);
            }
        }
 private static void DrawSelectedObjectHighlight2(MyHudSelectedObject selection)
 {
     Color color = MyDefinitionManager.Static.EnvironmentDefinition.ContourHighlightColor;
     float thickness = MyDefinitionManager.Static.EnvironmentDefinition.ContourHighlightThickness;
     ulong pulseTimeInFrames = (ulong)Math.Round(MyDefinitionManager.Static.EnvironmentDefinition.HighlightPulseInSeconds * MyEngineConstants.UPDATE_STEPS_PER_SECOND);
     MyRenderProxy.UpdateModelHighlight((uint)selection.InteractiveObject.RenderObjectID, selection.SectionIndices, selection.SubpartIndices, color, thickness, pulseTimeInFrames);
 }
Exemplo n.º 13
0
        private static void DrawSelectedObjectHighlight(MyHudSelectedObject selection, MyHudObjectHighlightStyleData? data)
        {
            if (selection.InteractiveObject.RenderObjectID == -1)
            {
                // Invalid render object ID
                return;
            }

            switch (selection.HighlightStyle)
            {
                case MyHudObjectHighlightStyle.HighlightStyle1:
                {
                    DrawSelectedObjectHighlight1(selection, data.Value.AtlasTexture, data.Value.TextureCoord);
                    break;
                }
                case MyHudObjectHighlightStyle.HighlightStyle2:
                {
                    int[] sectionIndices = selection.SectionIndices;
                    if (sectionIndices != null && selection.SectionIndices.Length == 0)
                    {
                        // There was a problem with sections look-up, fallback to previous highlight style
                        DrawSelectedObjectHighlight1(selection, data.Value.AtlasTexture, data.Value.TextureCoord);
                        break;
                    }

                    DrawSelectedObjectHighlight2(selection);
                    break;
                }
            }

            selection.Visible = true;
        }
Exemplo n.º 14
0
 private static void RemoveObjectHighlight(MyHudSelectedObject selection)
 {
     RemoveObjectHighlightInternal(ref selection.CurrentObject, false);
 
     selection.Visible = false;
     if (!selection.KeepObjectReference)
         selection.CurrentObject.Reset();
 }
Exemplo n.º 15
0
 private static void DrawSelectedObjectHighlight2(MyHudSelectedObject selection)
 {
     Color color = MyDefinitionManager.Static.EnvironmentDefinition.ContourHighlightColor;
     float thickness = MyDefinitionManager.Static.EnvironmentDefinition.ContourHighlightThickness;
     MyRenderProxy.UpdateModelHighlight((uint)selection.InteractiveObject.RenderObjectID, 0, null, selection.SectionIndices, null, color, thickness);
 }
Exemplo n.º 16
0
 private static void DrawSelectedObjectHighlightOutline(MyHudSelectedObject selection)
 {
     Color color = MySector.EnvironmentDefinition.ContourHighlightColor;
     float thickness = MySector.EnvironmentDefinition.ContourHighlightThickness;
     ulong pulseTimeInFrames = (ulong)Math.Round(MySector.EnvironmentDefinition.HighlightPulseInSeconds * MyEngineConstants.UPDATE_STEPS_PER_SECOND);
     var data = new MyHighlightSystem.MyHighlightData(
         entityId: selection.InteractiveObject.Owner.EntityId, 
         outlineColor: color, 
         thickness: (int)thickness, 
         pulseTimeInFrames: pulseTimeInFrames
         );
     MySession.Static.GetComponent<MyHighlightSystem>().RequestHighlightChange(data);
 }
Exemplo n.º 17
0
        public static void DrawSelectionCorner(string atlasTexture, MyHudSelectedObject selection, MyAtlasTextureCoordinate textureCoord, Vector2 scale, Vector2 pos, Vector2 rightVector, float textureScale)
        {
            if (MyVideoSettingsManager.IsTripleHead())
                pos.X = pos.X * 3;

            VRageRender.MyRenderProxy.DrawSpriteAtlas(
                atlasTexture,
                pos,
                textureCoord.Offset,
                textureCoord.Size,
                rightVector,
                scale,
                selection.Color,
                selection.HalfSize / MyGuiManager.GetHudSize() * textureScale);
        }
Exemplo n.º 18
0
        public static void DrawSelectedObjectHighlight(string atlasTexture, MyAtlasTextureCoordinate textureCoord, MyHudSelectedObject selection)
        {
            var rect = MyGuiManager.GetSafeFullscreenRectangle();

            Vector2 hudSize = new Vector2(rect.Width, rect.Height);

            var worldViewProj = selection.InteractiveObject.ActivationMatrix * MySector.MainCamera.ViewMatrix * (MatrixD)MySector.MainCamera.ProjectionMatrix;
            BoundingBoxD screenSpaceAabb = new BoundingBoxD(-Vector3D.One / 2, Vector3D.One / 2).Transform(worldViewProj);
            var min = new Vector2((float)screenSpaceAabb.Min.X, (float)screenSpaceAabb.Min.Y);
            var max = new Vector2((float)screenSpaceAabb.Max.X, (float)screenSpaceAabb.Max.Y);

            var minToMax = min - max;

            min = min * 0.5f + 0.5f * Vector2.One;
            max = max * 0.5f + 0.5f * Vector2.One;

            min.Y = 1 - min.Y;
            max.Y = 1 - max.Y;

            float textureScale = (float)Math.Pow(Math.Abs(minToMax.X), 0.35f) * 2.5f;

            if (selection.InteractiveObject.ShowOverlay)
            {
                BoundingBoxD one = new BoundingBoxD(new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, 0.5f, 0.5f));
                Color color = Color.Gold;
                color *= 0.4f;
                var m = selection.InteractiveObject.ActivationMatrix;
                var localToWorld = MatrixD.Invert(selection.InteractiveObject.WorldMatrix);
                //MySimpleObjectDraw.DrawTransparentBox(ref m, ref one, ref color, MySimpleObjectRasterizer.Solid, 0, 0.05f, "Square", null, true);

                MySimpleObjectDraw.DrawAttachedTransparentBox(ref m, ref one, ref color, selection.InteractiveObject.RenderObjectID,
                    ref localToWorld, MySimpleObjectRasterizer.Solid, 0, 0.05f, "Square", null, true);
            }

            if (MyFakes.ENABLE_USE_OBJECT_CORNERS)
            {
                DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, min, -Vector2.UnitY, textureScale);
                DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, new Vector2(min.X, max.Y), Vector2.UnitX, textureScale);
                DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, new Vector2(max.X, min.Y), -Vector2.UnitX, textureScale);
                DrawSelectionCorner(atlasTexture, selection, textureCoord, hudSize, max, Vector2.UnitY, textureScale);
            }
        }
Exemplo n.º 19
0
        public static void HandleSelectedObjectHighlight(MyHudSelectedObject selection, MyHudObjectHighlightStyleData? data)
        {
            if (selection.PreviousObject.Instance != null)
                RemoveObjectHighlightInternal(ref selection.PreviousObject, true);

            switch (selection.State)
            {
                case MyHudSelectedObjectState.VisibleStateSet:
                {
                    if (selection.Visible && (selection.CurrentObject.Style == MyHudObjectHighlightStyle.DummyHighlight
                            || selection.VisibleRenderID != selection.CurrentObject.Instance.RenderObjectID))
                        MyGuiScreenHudBase.DrawSelectedObjectHighlight(selection, data);

                    break;
                }
                case MyHudSelectedObjectState.MarkedForVisible:
                {
                    MyGuiScreenHudBase.DrawSelectedObjectHighlight(selection, data);
                    break;
                }
                case MyHudSelectedObjectState.MarkedForNotVisible:
                {
                    MyGuiScreenHudBase.RemoveObjectHighlight(selection);
                    break;
                }
            }
        }
Exemplo n.º 20
0
        private static void RemoveObjectHighlight(MyHudSelectedObject selection)
        {
            RemoveObjectHighlightInternal(ref selection.CurrentObject, false);

            selection.Visible = false;
        }
Exemplo n.º 21
0
        private static void DrawSelectedObjectHighlight(MyHudSelectedObject selection, MyHudObjectHighlightStyleData? data)
        {
            if (selection.InteractiveObject.RenderObjectID == -1)
            {
                // Invalid render object ID
                return;
            }

            switch (selection.HighlightStyle)
            {
                case MyHudObjectHighlightStyle.DummyHighlight:
                {
                    DrawSelectedObjectHighlightDummy(selection, data.Value.AtlasTexture, data.Value.TextureCoord);
                    break;
                }
                case MyHudObjectHighlightStyle.OutlineHighlight:
                {
                    int[] sectionIndices = selection.SectionIndices;
                    if (sectionIndices != null && selection.SectionIndices.Length == 0
                        && selection.SubpartIndices == null)
                    {
                        // There was a problem with sections look-up, fallback to previous highlight style
                        DrawSelectedObjectHighlightDummy(selection, data.Value.AtlasTexture, data.Value.TextureCoord);
                    }
                    else
                    {
                        DrawSelectedObjectHighlightOutline(selection);
                    }
                    break;
                }
                case MyHudObjectHighlightStyle.None:
                {
                    return;
                }
                default:
                    throw new Exception("Unknown highlight style");
            }

            selection.Visible = true;
        }
Exemplo n.º 22
0
 private static void DrawSelectedObjectHighlightOutline(MyHudSelectedObject selection)
 {
     Color color = MySector.EnvironmentDefinition.ContourHighlightColor;
     float thickness = MySector.EnvironmentDefinition.ContourHighlightThickness;
     ulong pulseTimeInFrames = (ulong)Math.Round(MySector.EnvironmentDefinition.HighlightPulseInSeconds * MyEngineConstants.UPDATE_STEPS_PER_SECOND);
     if (!MySession.Static.GetComponent<MyHighlightSystem>().IsReserved(selection.InteractiveObject.Owner.EntityId))
         MyRenderProxy.UpdateModelHighlight((uint)selection.InteractiveObject.RenderObjectID, selection.SectionIndices, selection.SubpartIndices, color, thickness, pulseTimeInFrames, selection.InteractiveObject.InstanceID);
 }
Exemplo n.º 23
0
 private static void RemoveObjectHighlight(MyHudSelectedObject selection)
 {
     RemoveObjectHighlightInternal(ref selection.CurrentObject, false);
 
     selection.Visible = false;
 }