Пример #1
0
        public static Dictionary <ObjectGame.ObjcetIds, PlainBmpTexture> CreateGameObjectsTextures(Size aTextureSize,
                                                                                                   ShaderProgram aProgram)
        {
            Dictionary <ObjectGame.ObjcetIds, GameObjectType>  objTypeList    = ObjectGame.GetObjTypes();
            Dictionary <ObjectGame.ObjcetIds, PlainBmpTexture> objTextureList =
                new Dictionary <ObjectGame.ObjcetIds, PlainBmpTexture>();

            SolidBrush  tempBrush;
            Bitmap      tempBmp;
            ObjMaterial tempMaterial;

            foreach (KeyValuePair <ObjectGame.ObjcetIds, GameObjectType> keyValuePair in objTypeList)
            {
                PlainBmpTexture tempBmpTexture = new PlainBmpTexture(keyValuePair.Value.Name)
                {
                    Color = keyValuePair.Value.Color
                };
                tempBrush = new SolidBrush(tempBmpTexture.Color);
                tempBmp   = BitmapHelper.CreatBitamp(aTextureSize, tempBrush);
                tempBmpTexture.TextureBmp = tempBmp;
                tempMaterial = new ObjMaterial(aProgram)
                {
                    DiffuseMap = new Texture(tempBmp)
                };
                tempBmpTexture.Material = tempMaterial;
                objTextureList.Add(keyValuePair.Key, tempBmpTexture);
            }

            return(objTextureList);
        }
Пример #2
0
        public static Dictionary <Tile.TileIds, Bitmap> CreateTileBitmaps(Size aTextureSize)
        {
            Dictionary <Tile.TileIds, TileType> tileList        = Tile.GetTileTypes();
            Dictionary <Tile.TileIds, Bitmap>   tiletextureList = new Dictionary <Tile.TileIds, Bitmap>();

            SolidBrush tempBrush;
            Bitmap     tempBmp;

            foreach (KeyValuePair <Tile.TileIds, TileType> keyValuePair in tileList)
            {
                string tempTiletextureName = "Tile_" + keyValuePair.Key.ToString() + ".png";

                string          tempFilePath   = Path.Combine(TheResourceManager.TileDirectory, tempTiletextureName);
                PlainBmpTexture tempBmpTexture = new PlainBmpTexture(keyValuePair.Value.Name);

                if (!File.Exists(tempFilePath))
                {
                    tempBmpTexture.Color = keyValuePair.Value.Color;
                    tempBrush            = new SolidBrush(tempBmpTexture.Color);
                    tempBmp = BitmapHelper.CreatBitamp(aTextureSize, tempBrush);
                }
                else
                {
                    tempBmp = (Bitmap)Bitmap.FromFile(tempFilePath);    //Filename);
                    tempBmp.RotateFlip(RotateFlipType.RotateNoneFlipY); // bitmaps read from bottom up, so flip it
                    if (tempBmp.PixelFormat != PixelFormat.Format32bppArgb)
                    {
                        Bitmap clone = new Bitmap(tempBmp.Width, tempBmp.Height,
                                                  System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
                        using (Graphics gr = Graphics.FromImage(clone))
                        {
                            gr.DrawImage(tempBmp, new Rectangle(0, 0, clone.Width, clone.Height));
                        }
                        tempBmp = clone;
                    }
                }
                tiletextureList.Add(keyValuePair.Key, tempBmp);
            }

            return(tiletextureList);
        }
Пример #3
0
        public static Dictionary <Tile.TileIds, PlainBmpTexture> CreateTileTextures(Size aTextureSize,
                                                                                    ShaderProgram aProgram)
        {
            Dictionary <Tile.TileIds, TileType>        tileList        = Tile.GetTileTypes();
            Dictionary <Tile.TileIds, PlainBmpTexture> tiletextureList =
                new Dictionary <Tile.TileIds, PlainBmpTexture>();

            SolidBrush  tempBrush;
            Bitmap      tempBmp;
            ObjMaterial tempMaterial;

            foreach (KeyValuePair <Tile.TileIds, TileType> keyValuePair in tileList)
            {
                string tempTiletextureName = "Tile_" + keyValuePair.Key.ToString() + ".png";

                PlainBmpTexture tempBmpTexture = new PlainBmpTexture(keyValuePair.Value.Name);
                tempMaterial = TheResourceManager.GetFromFile(aProgram, tempTiletextureName, false, ResourceManager.ResourceTypes.Tile);
                if (tempMaterial == null)
                {
                    tempBmpTexture.Color = keyValuePair.Value.Color;
                    tempBrush            = new SolidBrush(tempBmpTexture.Color);
                    tempBmp = BitmapHelper.CreatBitamp(aTextureSize, tempBrush);
                    tempBmpTexture.TextureBmp = tempBmp;
                    tempMaterial = new ObjMaterial(aProgram)
                    {
                        DiffuseMap = new Texture(tempBmp)
                    };
                    tempBmpTexture.Material = tempMaterial;
                }
                else
                {
                    tempBmpTexture.Material = tempMaterial;
                }
                tiletextureList.Add(keyValuePair.Key, tempBmpTexture);
            }

            return(tiletextureList);
        }