コード例 #1
0
        public TMDDocument CreateDocument(TMD tmd)
        {
            List <IRenderable> objectMeshes =
                LibLSDUtil.CreateMeshesFromTMD(tmd, null, null, headless: true);

            return(new TMDDocument(tmd, objectMeshes));
        }
コード例 #2
0
        public TMDDocument CreateDocument(TMD tmd)
        {
            List <IRenderable> objectMeshes =
                LibLSDUtil.CreateMeshesFromTMD(tmd, _shader, _vramController.VRAM, headless: false);

            return(new TMDDocument(tmd, objectMeshes));
        }
コード例 #3
0
ファイル: VRAMController.cs プロジェクト: Sievaxx/LSDView
        public void LoadTIXIntoVRAM(string tixPath)
        {
            Logger.Log()(LogLevel.INFO, $"Loading TIX from {tixPath} into virtual VRAM");

            TIX tix;

            using (BinaryReader br = new BinaryReader(File.Open(tixPath, FileMode.Open)))
            {
                tix = new TIX(br);
            }

            Logger.Log()(LogLevel.INFO, $"Successfully loaded TIX");

            foreach (var chunk in tix.Chunks)
            {
                foreach (var tim in chunk.TIMs)
                {
                    var image = LibLSDUtil.GetImageDataFromTIM(tim);

                    int actualXPos = (tim.PixelData.XPosition - 320) * 2;
                    int actualYPos = 512 - tim.PixelData.YPosition - image.height;

                    VRAMTexture.SubImage(image.data, actualXPos, actualYPos, image.width, image.height);
                }
            }

            VRAMLoaded = true;
        }
コード例 #4
0
ファイル: LBDController.cs プロジェクト: Sievaxx/LSDView
        public LBDDocument CreateDocument(LBD lbd)
        {
            TMDDocument        tileTmd    = _tmdController.CreateDocument(lbd.Tiles);
            List <IRenderable> tileLayout = new List <IRenderable>();

            int tileNo = 0;

            foreach (LBDTile tile in lbd.TileLayout)
            {
                int x = tileNo / lbd.Header.TileWidth;
                int y = tileNo % lbd.Header.TileWidth;

                if (tile.DrawTile)
                {
                    tileLayout.AddRange(LibLSDUtil.CreateLBDTileMesh(tile, lbd.ExtraTiles, x, y, lbd.Tiles, _shader,
                                                                     _vramController.VRAMTexture));
                }

                tileNo++;
            }

            List <MOMDocument> entities = null;

            if (lbd.Header.HasMML)
            {
                entities = new List <MOMDocument>();
                foreach (MOM mom in lbd.MML?.MOMs)
                {
                    entities.Add(_momController.CreateDocument(mom));
                }
            }

            return(new LBDDocument(lbd, tileTmd, tileLayout, entities));
        }
コード例 #5
0
        public TIMDocument CreateDocument(TIM tim)
        {
            Mesh textureMesh = Mesh.CreateQuad(_shader);
            var  img         = LibLSDUtil.GetImageDataFromTIM(tim);

            textureMesh.Textures.Add(new Texture2D(img.width, img.height, img.data));

            return(new TIMDocument(tim, textureMesh));
        }
コード例 #6
0
        /// <summary>
        /// Export a TIM file to a common image format.
        /// </summary>
        /// <param name="tim">The TIM file.</param>
        /// <param name="clutIndex">The index of the CLUT to export with.</param>
        /// <param name="filePath">The file path to export to.</param>
        /// <param name="format">The image format to export to.</param>
        public void ExportImage(TIM tim, int clutIndex, string filePath, ImageFormat format)
        {
            Log.Information($"Exporting image ({format}) to: {filePath}");

            var    image = LibLSDUtil.GetImageDataFromTIM(tim, clutIndex, flip: false);
            Bitmap bmp   = ImageUtil.ImageDataToBitmap(image.data, image.width, image.height);

            bmp.Save(filePath, format);
        }
コード例 #7
0
        /// <summary>
        /// Export a TIM file to a common image format.
        /// </summary>
        /// <param name="tim">The TIM file.</param>
        /// <param name="filePath">The file path to export to.</param>
        /// <param name="format">The image format to export to.</param>
        public void ExportImage(TIM tim, string filePath, ImageFormat format)
        {
            Logger.Log()(LogLevel.INFO, $"Exporting image ({format}) to: {filePath}");

            var    image = LibLSDUtil.GetImageDataFromTIM(tim, flip: false);
            Bitmap bmp   = ImageUtil.ImageDataToBitmap(image.data, image.width, image.height);

            bmp.Save(filePath, format);
        }
コード例 #8
0
        public TIM Load(string timPath)
        {
            var tim = LibLSDUtil.LoadTIM(timPath);

            TIMDocument document = CreateDocument(tim);

            _treeController.PopulateWithDocument(document, Path.GetFileName(timPath));

            return(tim);
        }
コード例 #9
0
        public LBD Load(string lbdPath)
        {
            var lbd = LibLSDUtil.LoadLBD(lbdPath);

            LBDDocument document = CreateDocument(lbd);

            _treeController.PopulateWithDocument(document, Path.GetFileName(lbdPath));

            return(lbd);
        }
コード例 #10
0
        public TMD Load(string tmdPath)
        {
            var tmd = LibLSDUtil.LoadTMD(tmdPath);

            TMDDocument document = CreateDocument(tmd);

            _treeController.PopulateWithDocument(document, Path.GetFileName(tmdPath));

            return(tmd);
        }
コード例 #11
0
        public MOM Load(string momPath)
        {
            var mom = LibLSDUtil.LoadMOM(momPath);

            MOMDocument document = CreateDocument(mom);

            _treeController.PopulateWithDocument(document, Path.GetFileName(momPath));

            return(mom);
        }
コード例 #12
0
        public TIMDocument CreateDocument(TIM tim)
        {
            // 1 if not using CLUT, otherwise number of CLUTs
            int numMeshes = tim.ColorLookup?.NumberOfCLUTs ?? 1;

            Mesh[] timMeshes = new Mesh[numMeshes];

            for (int i = 0; i < numMeshes; i++)
            {
                var        img         = LibLSDUtil.GetImageDataFromTIM(tim, clutIndex: i);
                Mesh       textureMesh = Mesh.CreateQuad(_shader);
                ITexture2D tex         = new Texture2D(img.width, img.height, img.data);
                textureMesh.Textures.Add(tex);
                timMeshes[i] = textureMesh;
            }

            return(new TIMDocument(tim, timMeshes));
        }
コード例 #13
0
        public void LoadTIXIntoVRAM(string tixPath)
        {
            Log.Information($"Loading TIX from {tixPath} into virtual VRAM");

            using (BinaryReader br = new BinaryReader(File.Open(tixPath, FileMode.Open)))
            {
                Tix = new TIX(br);
            }

            Log.Information("Successfully loaded TIX");

            if (VRAM != null)
            {
                disposeOldVRAM();
            }

            VRAM = LibLSDUtil.TIXToTexture2D(Tix, headless: true, flip: false);

            VRAMLoaded = true;
        }
コード例 #14
0
        /// <summary>
        /// Export the TIM files in a TIX to common image formats.
        /// </summary>
        /// <param name="tix">The TIX file.</param>
        /// <param name="filePath">The file path to export to.</param>
        /// <param name="separate">Whether or not to separate images in the output.</param>
        /// <param name="format">The image format to export to.</param>
        public void ExportImages(TIX tix, string filePath, bool separate, ImageFormat format)
        {
            if (separate)
            {
                Log.Information($"Exporting images ({format}) in TIX to: {filePath}");

                var allTims = tix.AllTIMs;
                for (int i = 0; i < allTims.Count; i++)
                {
                    var fileName = Path.GetFileNameWithoutExtension(filePath);
                    var ext      = Path.GetExtension(filePath);
                    var dir      = Path.GetDirectoryName(filePath);
                    ExportImage(allTims[i], 0, Path.Combine(dir, $"{fileName}-{i}{ext}"), format);
                }
            }
            else
            {
                ITexture2D tixTex = LibLSDUtil.TIXToTexture2D(tix, headless: true, flip: false);
                ExportTexture(tixTex, filePath, format);
            }
        }
コード例 #15
0
 public TMD Load(string path)
 {
     return(LibLSDUtil.LoadTMD(path));
 }
コード例 #16
0
 public MOM Load(string path)
 {
     return(LibLSDUtil.LoadMOM(path));
 }
コード例 #17
0
 public LBD Load(string path)
 {
     return(LibLSDUtil.LoadLBD(path));
 }
コード例 #18
0
 public TIX Load(string path)
 {
     return(LibLSDUtil.LoadTIX(path));
 }