コード例 #1
0
        /// <summary>
        /// Add textured quad with specified UP direction and width/height.
        /// </summary>
        protected void AddTexturedQuad(MyHudTexturesEnum texture, Vector2 position, Vector2 upVector, Color color, float halfWidth, float halfHeight)
        {
            Vector2 rightVector = new Vector2(-upVector.Y, upVector.X);

            MyAtlasTextureCoordinate textureCoord = m_hudScreen.GetTextureCoord(texture);

            float hudSizeX = MyGuiManager.GetSafeFullscreenRectangle().Width / MyGuiManager.GetHudSize().X;
            float hudSizeY = MyGuiManager.GetSafeFullscreenRectangle().Height / MyGuiManager.GetHudSize().Y;
            var   pos      = position;

            if (MyVideoSettingsManager.IsTripleHead())
            {
                pos.X += 1.0f;
            }

            VRageRender.MyRenderProxy.DrawSpriteAtlas(
                m_hudScreen.TextureAtlas,
                pos,
                textureCoord.Offset,
                textureCoord.Size,
                rightVector,
                new Vector2(hudSizeX, hudSizeY),
                color,
                new Vector2(halfWidth, halfHeight));
        }
コード例 #2
0
        public static void LoadTextureAtlas(string[] enumsToStrings, string textureDir, string atlasFile, out MyTexture2D texture, out MyAtlasTextureCoordinate[] textureCoords)
        {
            //MyTextureAtlas atlas = contentManager.Load<MyTextureAtlas>(atlasFile);

            MyTextureAtlas atlas = LoadTextureAtlas(textureDir, atlasFile);

            //  Here we define particle texture coordinates inside of texture atlas
            textureCoords = new MyAtlasTextureCoordinate[enumsToStrings.Length];

            texture = null;

            for (int i = 0; i < enumsToStrings.Length; i++)
            {
                MyTextureAtlasItem textureAtlasItem = atlas[enumsToStrings[i]];

                textureCoords[i] = new MyAtlasTextureCoordinate(new Vector2(textureAtlasItem.UVOffsets.X, textureAtlasItem.UVOffsets.Y), new Vector2(textureAtlasItem.UVOffsets.Z, textureAtlasItem.UVOffsets.W));

                //  Texture atlas content processor support having more DDS files for one atlas, but we don't want it (because we want to have all particles in one texture, so we can draw fast).
                //  So here we just take first and only texture.
                if (texture == null)
                {
                    texture = textureAtlasItem.AtlasTexture;
                }
            }
        }
コード例 #3
0
        public static void LoadTextureAtlas(string[] enumsToStrings, string textureDir, string atlasFile, out string texture, out MyAtlasTextureCoordinate[] textureCoords)
        {
            MyTextureAtlas atlas = LoadTextureAtlas(textureDir, atlasFile);

            textureCoords = new MyAtlasTextureCoordinate[enumsToStrings.Length];
            texture       = null;
            for (int i = 0; i < enumsToStrings.Length; i++)
            {
                MyTextureAtlasItem item = atlas[enumsToStrings[i]];
                textureCoords[i] = new MyAtlasTextureCoordinate(new Vector2(item.UVOffsets.X, item.UVOffsets.Y), new Vector2(item.UVOffsets.Z, item.UVOffsets.W));
                if (texture == null)
                {
                    texture = item.AtlasTexture;
                }
            }
        }
コード例 #4
0
        public void Draw(string atlas, MyAtlasTextureCoordinate[] atlasCoords)
        {
            float hudSizeX = MyGuiManager.GetSafeFullscreenRectangle().Width / MyGuiManager.GetHudSize().X;
            float hudSizeY = MyGuiManager.GetSafeFullscreenRectangle().Height / MyGuiManager.GetHudSize().Y;
            var   pos      = m_position;

            if (MyVideoSettingsManager.IsTripleHead())
            {
                pos.X += 1.0f;
            }

            foreach (var sprite in m_sprites)
            {
                if (!sprite.Visible)
                {
                    continue;
                }

                int spriteCoord = (int)sprite.SpriteEnum;
                if (spriteCoord >= atlasCoords.Length)
                {
                    Debug.Assert(false, "Out of bounds of the crosshair array!");
                    continue;
                }

                MyAtlasTextureCoordinate textureCoord = atlasCoords[spriteCoord];

                Color spriteColor = sprite.Color;
                if (sprite.TimeRemaining < sprite.FadeoutTime)
                {
                    spriteColor.A = (byte)(spriteColor.A * sprite.TimeRemaining / sprite.FadeoutTime);
                }

                VRageRender.MyRenderProxy.DrawSpriteAtlas(
                    atlas,
                    pos,
                    textureCoord.Offset,
                    textureCoord.Size,
                    m_rightVector,
                    new Vector2(hudSizeX, hudSizeY),
                    spriteColor,
                    sprite.HalfSize);
            }
        }
コード例 #5
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);
            }
        }
コード例 #6
0
        public static void DrawCrosshair(string atlas, MyAtlasTextureCoordinate textureCoord, MyHudCrosshair crosshair)
        {
            Vector2 rightVector = new Vector2(crosshair.UpVector.Y, crosshair.UpVector.X);

            float hudSizeX = MyGuiManager.GetSafeFullscreenRectangle().Width / MyGuiManager.GetHudSize().X;
            float hudSizeY = MyGuiManager.GetSafeFullscreenRectangle().Height / MyGuiManager.GetHudSize().Y;
            var   pos      = crosshair.Position;

            if (MyVideoSettingsManager.IsTripleHead())
            {
                pos.X += 1.0f;
            }

            VRageRender.MyRenderProxy.DrawSpriteAtlas(
                atlas,
                pos,
                textureCoord.Offset,
                textureCoord.Size,
                rightVector,
                new Vector2(hudSizeX, hudSizeY),
                crosshair.Color,
                crosshair.HalfSize);
        }
コード例 #7
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);
        }