public TMDDocument CreateDocument(TMD tmd) { List <IRenderable> objectMeshes = LibLSDUtil.CreateMeshesFromTMD(tmd, null, null, headless: true); return(new TMDDocument(tmd, objectMeshes)); }
public TMDDocument CreateDocument(TMD tmd) { List <IRenderable> objectMeshes = LibLSDUtil.CreateMeshesFromTMD(tmd, _shader, _vramController.VRAM, headless: false); return(new TMDDocument(tmd, objectMeshes)); }
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; }
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)); }
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)); }
/// <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); }
/// <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); }
public TIM Load(string timPath) { var tim = LibLSDUtil.LoadTIM(timPath); TIMDocument document = CreateDocument(tim); _treeController.PopulateWithDocument(document, Path.GetFileName(timPath)); return(tim); }
public LBD Load(string lbdPath) { var lbd = LibLSDUtil.LoadLBD(lbdPath); LBDDocument document = CreateDocument(lbd); _treeController.PopulateWithDocument(document, Path.GetFileName(lbdPath)); return(lbd); }
public TMD Load(string tmdPath) { var tmd = LibLSDUtil.LoadTMD(tmdPath); TMDDocument document = CreateDocument(tmd); _treeController.PopulateWithDocument(document, Path.GetFileName(tmdPath)); return(tmd); }
public MOM Load(string momPath) { var mom = LibLSDUtil.LoadMOM(momPath); MOMDocument document = CreateDocument(mom); _treeController.PopulateWithDocument(document, Path.GetFileName(momPath)); return(mom); }
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)); }
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; }
/// <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); } }
public TMD Load(string path) { return(LibLSDUtil.LoadTMD(path)); }
public MOM Load(string path) { return(LibLSDUtil.LoadMOM(path)); }
public LBD Load(string path) { return(LibLSDUtil.LoadLBD(path)); }
public TIX Load(string path) { return(LibLSDUtil.LoadTIX(path)); }