Exemple #1
0
        protected void MinimapTextureFill(clsMinimapTexture Texture)
        {
            int X = 0;
            int Y = 0;
            sXY_int Low = new sXY_int();
            sXY_int High = new sXY_int();
            sXY_int Footprint = new sXY_int();
            bool Flag = default(bool);
            bool[,] UnitMap = new bool[Texture.Size.Y, Texture.Size.X];
            float[,,] sngTexture = new float[Texture.Size.Y, Texture.Size.X, 3];
            float Alpha = 0;
            float AntiAlpha = 0;
            sRGB_sng RGB_sng = new sRGB_sng();

            if ( Program.frmMainInstance.menuMiniShowTex.Checked )
            {
                if ( Tileset != null )
                {
                    for ( Y = 0; Y <= Terrain.TileSize.Y - 1; Y++ )
                    {
                        for ( X = 0; X <= Terrain.TileSize.X - 1; X++ )
                        {
                            if ( Terrain.Tiles[X, Y].Texture.TextureNum >= 0 && Terrain.Tiles[X, Y].Texture.TextureNum < Tileset.TileCount )
                            {
                                sngTexture[Y, X, 0] = Tileset.Tiles[Terrain.Tiles[X, Y].Texture.TextureNum].AverageColour.Red;
                                sngTexture[Y, X, 1] = Tileset.Tiles[Terrain.Tiles[X, Y].Texture.TextureNum].AverageColour.Green;
                                sngTexture[Y, X, 2] = Tileset.Tiles[Terrain.Tiles[X, Y].Texture.TextureNum].AverageColour.Blue;
                            }
                        }
                    }
                }
                if ( Program.frmMainInstance.menuMiniShowHeight.Checked )
                {
                    float Height = 0;
                    for ( Y = 0; Y <= Terrain.TileSize.Y - 1; Y++ )
                    {
                        for ( X = 0; X <= Terrain.TileSize.X - 1; X++ )
                        {
                            Height =
                                Convert.ToSingle(((Terrain.Vertices[X, Y].Height) + Terrain.Vertices[X + 1, Y].Height + Terrain.Vertices[X, Y + 1].Height +
                                                         Terrain.Vertices[X + 1, Y + 1].Height) / 1020.0F);
                            sngTexture[Y, X, 0] = (sngTexture[Y, X, 0] * 2.0F + Height) / 3.0F;
                            sngTexture[Y, X, 1] = (sngTexture[Y, X, 1] * 2.0F + Height) / 3.0F;
                            sngTexture[Y, X, 2] = (sngTexture[Y, X, 2] * 2.0F + Height) / 3.0F;
                        }
                    }
                }
            }
            else if ( Program.frmMainInstance.menuMiniShowHeight.Checked )
            {
                float Height = 0;
                for ( Y = 0; Y <= Terrain.TileSize.Y - 1; Y++ )
                {
                    for ( X = 0; X <= Terrain.TileSize.X - 1; X++ )
                    {
                        Height =
                            Convert.ToSingle(((Terrain.Vertices[X, Y].Height) + Terrain.Vertices[X + 1, Y].Height + Terrain.Vertices[X, Y + 1].Height +
                                                     Terrain.Vertices[X + 1, Y + 1].Height) / 1020.0F);
                        sngTexture[Y, X, 0] = Height;
                        sngTexture[Y, X, 1] = Height;
                        sngTexture[Y, X, 2] = Height;
                    }
                }
            }
            else
            {
                for ( Y = 0; Y <= Terrain.TileSize.Y - 1; Y++ )
                {
                    for ( X = 0; X <= Terrain.TileSize.X - 1; X++ )
                    {
                        sngTexture[Y, X, 0] = 0.0F;
                        sngTexture[Y, X, 1] = 0.0F;
                        sngTexture[Y, X, 2] = 0.0F;
                    }
                }
            }
            if ( Program.frmMainInstance.menuMiniShowCliffs.Checked )
            {
                if ( Tileset != null )
                {
                    Alpha = SettingsManager.Settings.MinimapCliffColour.Alpha;
                    AntiAlpha = 1.0F - Alpha;
                    for ( Y = 0; Y <= Terrain.TileSize.Y - 1; Y++ )
                    {
                        for ( X = 0; X <= Terrain.TileSize.X - 1; X++ )
                        {
                            if ( Terrain.Tiles[X, Y].Texture.TextureNum >= 0 && Terrain.Tiles[X, Y].Texture.TextureNum < Tileset.TileCount )
                            {
                                if ( Tileset.Tiles[Terrain.Tiles[X, Y].Texture.TextureNum].Default_Type == App.TileTypeNum_Cliff )
                                {
                                    sngTexture[Y, X, 0] = sngTexture[Y, X, 0] * AntiAlpha + SettingsManager.Settings.MinimapCliffColour.Red * Alpha;
                                    sngTexture[Y, X, 1] = sngTexture[Y, X, 1] * AntiAlpha + SettingsManager.Settings.MinimapCliffColour.Green * Alpha;
                                    sngTexture[Y, X, 2] = sngTexture[Y, X, 2] * AntiAlpha + SettingsManager.Settings.MinimapCliffColour.Blue * Alpha;
                                }
                            }
                        }
                    }
                }
            }
            if ( Program.frmMainInstance.menuMiniShowGateways.Checked )
            {
                clsGateway Gateway = default(clsGateway);
                foreach ( clsGateway tempLoopVar_Gateway in Gateways )
                {
                    Gateway = tempLoopVar_Gateway;
                    MathUtil.ReorderXY(Gateway.PosA, Gateway.PosB, Low, High);
                    for ( Y = Low.Y; Y <= High.Y; Y++ )
                    {
                        for ( X = Low.X; X <= High.X; X++ )
                        {
                            sngTexture[Y, X, 0] = 1.0F;
                            sngTexture[Y, X, 1] = 1.0F;
                            sngTexture[Y, X, 2] = 0.0F;
                        }
                    }
                }
            }
            if ( Program.frmMainInstance.menuMiniShowUnits.Checked )
            {
                //units that are not selected
                clsUnit Unit = default(clsUnit);
                foreach ( clsUnit tempLoopVar_Unit in Units )
                {
                    Unit = tempLoopVar_Unit;
                    Flag = true;
                    if ( Unit.Type.UnitType_frmMainSelectedLink.IsConnected )
                    {
                        Flag = false;
                    }
                    else
                    {
                        Footprint = Unit.Type.get_GetFootprintSelected(Unit.Rotation);
                    }
                    if ( Flag )
                    {
                        GetFootprintTileRangeClamped(Unit.Pos.Horizontal, Footprint, Low, High);
                        for ( Y = Low.Y; Y <= High.Y; Y++ )
                        {
                            for ( X = Low.X; X <= High.X; X++ )
                            {
                                if ( !UnitMap[Y, X] )
                                {
                                    UnitMap[Y, X] = true;
                                    if ( SettingsManager.Settings.MinimapTeamColours )
                                    {
                                        if ( SettingsManager.Settings.MinimapTeamColoursExceptFeatures & Unit.Type.Type == clsUnitType.enumType.Feature )
                                        {
                                            sngTexture[Y, X, 0] = App.MinimapFeatureColour.Red;
                                            sngTexture[Y, X, 1] = App.MinimapFeatureColour.Green;
                                            sngTexture[Y, X, 2] = App.MinimapFeatureColour.Blue;
                                        }
                                        else
                                        {
                                            RGB_sng = GetUnitGroupMinimapColour(Unit.UnitGroup);
                                            sngTexture[Y, X, 0] = RGB_sng.Red;
                                            sngTexture[Y, X, 1] = RGB_sng.Green;
                                            sngTexture[Y, X, 2] = RGB_sng.Blue;
                                        }
                                    }
                                    else
                                    {
                                        sngTexture[Y, X, 0] = sngTexture[Y, X, 0] * 0.6666667F + 0.333333343F;
                                        sngTexture[Y, X, 1] = sngTexture[Y, X, 1] * 0.6666667F;
                                        sngTexture[Y, X, 2] = sngTexture[Y, X, 2] * 0.6666667F;
                                    }
                                }
                            }
                        }
                    }
                }
                //reset unit map
                for ( Y = 0; Y <= Texture.Size.Y - 1; Y++ )
                {
                    for ( X = 0; X <= Texture.Size.X - 1; X++ )
                    {
                        UnitMap[Y, X] = false;
                    }
                }
                //units that are selected and highlighted
                Alpha = SettingsManager.Settings.MinimapSelectedObjectsColour.Alpha;
                AntiAlpha = 1.0F - Alpha;
                foreach ( clsUnit tempLoopVar_Unit in Units )
                {
                    Unit = tempLoopVar_Unit;
                    Flag = false;
                    if ( Unit.Type.UnitType_frmMainSelectedLink.IsConnected )
                    {
                        Flag = true;
                        Footprint = Unit.Type.get_GetFootprintSelected(Unit.Rotation);
                        Footprint.X += 2;
                        Footprint.Y += 2;
                    }
                    if ( Flag )
                    {
                        GetFootprintTileRangeClamped(Unit.Pos.Horizontal, Footprint, Low, High);
                        for ( Y = Low.Y; Y <= High.Y; Y++ )
                        {
                            for ( X = Low.X; X <= High.X; X++ )
                            {
                                if ( !UnitMap[Y, X] )
                                {
                                    UnitMap[Y, X] = true;
                                    sngTexture[Y, X, 0] = sngTexture[Y, X, 0] * AntiAlpha + SettingsManager.Settings.MinimapSelectedObjectsColour.Red * Alpha;
                                    sngTexture[Y, X, 1] = sngTexture[Y, X, 1] * AntiAlpha + SettingsManager.Settings.MinimapSelectedObjectsColour.Green * Alpha;
                                    sngTexture[Y, X, 2] = sngTexture[Y, X, 2] * AntiAlpha + SettingsManager.Settings.MinimapSelectedObjectsColour.Blue * Alpha;
                                }
                            }
                        }
                    }
                }
            }
            for ( Y = 0; Y <= Terrain.TileSize.Y - 1; Y++ )
            {
                for ( X = 0; X <= Terrain.TileSize.X - 1; X++ )
                {
                    Texture.set_Pixels(X, Y, new sRGBA_sng(
                        sngTexture[Y, X, 0],
                        sngTexture[Y, X, 1],
                        sngTexture[Y, X, 2],
                        1.0F));
                }
            }
        }
Exemple #2
0
        private void MinimapMake()
        {
            int NewTextureSize =
                (int)
                    (Math.Round(
                        Convert.ToDouble(Math.Pow(2.0D, Math.Ceiling(Math.Log(Math.Max(Terrain.TileSize.X, Terrain.TileSize.Y)) / Math.Log(2.0D))))));

            if ( NewTextureSize != Minimap_Texture_Size )
            {
                Minimap_Texture_Size = NewTextureSize;
            }

            clsMinimapTexture Texture = new clsMinimapTexture(new sXY_int(Minimap_Texture_Size, Minimap_Texture_Size));

            MinimapTextureFill(Texture);

            MinimapGLDelete();

            GL.GenTextures(1, out Minimap_GLTexture);
            GL.BindTexture(TextureTarget.Texture2D, Minimap_GLTexture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.ClampToEdge);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.ClampToEdge);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
            GL.TexImage2D<sRGBA_sng>(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, Minimap_Texture_Size, Minimap_Texture_Size, 0, PixelFormat.Rgba,
                PixelType.Float, Texture.InlinePixels);

            Program.frmMainInstance.View_DrawViewLater();
        }
Exemple #3
0
        public App.sResult Write_MinimapFile(string Path, bool Overwrite)
        {
            App.sResult ReturnResult = new App.sResult();
            int X = 0;
            int Y = 0;

            Bitmap MinimapBitmap = new Bitmap(Terrain.TileSize.X, Terrain.TileSize.Y);

            clsMinimapTexture Texture = new clsMinimapTexture(new sXY_int(Terrain.TileSize.X, Terrain.TileSize.Y));
            MinimapTextureFill(Texture);

            for ( Y = 0; Y <= Terrain.TileSize.Y - 1; Y++ )
            {
                for ( X = 0; X <= Terrain.TileSize.X - 1; X++ )
                {
                    MinimapBitmap.SetPixel(X, Y,
                        ColorTranslator.FromOle(
                            ColorUtil.OSRGB((int)(MathUtil.Clamp_sng(Convert.ToSingle(Texture.get_Pixels(X, Y).Red * 255.0F), 0.0F, 255.0F)),
                                (int)(MathUtil.Clamp_sng(Convert.ToSingle(Texture.get_Pixels(X, Y).Green * 255.0F), 0.0F, 255.0F)),
                                (int)(MathUtil.Clamp_sng(Convert.ToSingle(Texture.get_Pixels(X, Y).Blue * 255.0F), 0.0F, 255.0F)))));
                }
            }

            ReturnResult = BitmapUtil.SaveBitmap(Path, Overwrite, MinimapBitmap);

            return ReturnResult;
        }