コード例 #1
0
ファイル: MainWindow.cs プロジェクト: marwahaha/FacCom
        private void SaveMap(string fileOpened)
        {
            mapFile.Data = new float[mapFile.Width * mapFile.Height];
            for (int y = 0; y < mapFile.Height; y++)
            {
                for (int x = 0; x < mapFile.Width; x++)
                {
                    mapFile.Data[x + y * mapFile.Width] = ForegroundGame.Map.altitudeData[x, y];
                }
            }
            string fullpath = Path.GetFullPath(Application.StartupPath + @"\..\data\Maps");

            /*foreach (MapModel mapmodel in mapFile.Models) {
             *  mapmodel.file = PathHandling.RelativePath(fullpath,mapmodel.file);
             *  mapmodel.Position = mapmodel.model.Position;
             *  mapmodel.Orientation = mapmodel.model.Orientation;
             *  mapmodel.Scale = mapmodel.model.Scale;
             * }*/


            RawMap.Save(mapFile, fileOpened);

            Texture2DDescription desc = new Texture2DDescription()
            {
                ArraySize         = 1,
                BindFlags         = BindFlags.None,
                CpuAccessFlags    = CpuAccessFlags.Read,
                Format            = SharpDX.DXGI.Format.R8G8B8A8_UNorm,
                Width             = mapFile.Width,
                Height            = mapFile.Height,
                MipLevels         = 1,
                OptionFlags       = ResourceOptionFlags.None,
                SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
                Usage             = ResourceUsage.Staging,
            };

            Texture2D tex = new Texture2D(Display.device, desc);
            string    pathz;

            if (renderWindow1.modifiedTextureMap)
            {
                Display.context.CopyResource(ForegroundGame.Map.TextureMap.Tex, tex);
                pathz = Path.Combine(Resources.Main_Path, "Maps\\" + fileOpened + "\\_textureMap.png");
                Texture2D.ToFile(Display.context, tex, ImageFileFormat.Png, pathz);
                renderWindow1.modifiedTextureMap = false;
            }

            if (renderWindow1.modifiedColorMap)
            {
                Display.context.CopyResource(ForegroundGame.Map.ColorMap.Tex, tex);
                pathz = Path.Combine(Resources.Main_Path, "Maps\\" + fileOpened + "\\_colorMap.png");
                Texture2D.ToFile(Display.context, tex, ImageFileFormat.Png, pathz);
                renderWindow1.modifiedColorMap = false;
            }
            tex.Dispose();
        }