Automatically open ctex files for narc if a bfres is opened. Fix aces texture mapping
This commit is contained in:
parent
33ae4c5635
commit
134b8e295c
@ -135,7 +135,7 @@ namespace FirstPlugin
|
|||||||
|
|
||||||
public bool AddFile(ArchiveFileInfo archiveFileInfo)
|
public bool AddFile(ArchiveFileInfo archiveFileInfo)
|
||||||
{
|
{
|
||||||
FileEntry file = new FileEntry();
|
FileEntry file = new FileEntry(this);
|
||||||
file.FileName = archiveFileInfo.FileName;
|
file.FileName = archiveFileInfo.FileName;
|
||||||
file.CreateEntry(archiveFileInfo.FileData, true);
|
file.CreateEntry(archiveFileInfo.FileData, true);
|
||||||
files.Add(file);
|
files.Add(file);
|
||||||
@ -203,9 +203,31 @@ namespace FirstPlugin
|
|||||||
}
|
}
|
||||||
public class FileEntry : ArchiveFileInfo
|
public class FileEntry : ArchiveFileInfo
|
||||||
{
|
{
|
||||||
public FileEntry()
|
BEA ArchiveFile;
|
||||||
|
public FileEntry(BEA bea)
|
||||||
{
|
{
|
||||||
|
ArchiveFile = bea;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsTexturesLoaded = false;
|
||||||
|
public override IFileFormat OpenFile()
|
||||||
|
{
|
||||||
|
var FileFormat = base.OpenFile();
|
||||||
|
bool IsModel = FileFormat is BFRES;
|
||||||
|
|
||||||
|
if (IsModel && !IsTexturesLoaded)
|
||||||
|
{
|
||||||
|
IsTexturesLoaded = true;
|
||||||
|
foreach (var file in ArchiveFile.Files)
|
||||||
|
{
|
||||||
|
if (Utils.GetExtension(file.FileName) == ".ftxb")
|
||||||
|
{
|
||||||
|
file.FileFormat = file.OpenFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OpenFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ushort unk1;
|
public ushort unk1;
|
||||||
@ -281,7 +303,7 @@ namespace FirstPlugin
|
|||||||
|
|
||||||
public FileEntry SetupFileEntry(ASST asset)
|
public FileEntry SetupFileEntry(ASST asset)
|
||||||
{
|
{
|
||||||
FileEntry fileEntry = new FileEntry();
|
FileEntry fileEntry = new FileEntry(this);
|
||||||
fileEntry.FileName = asset.FileName;
|
fileEntry.FileName = asset.FileName;
|
||||||
fileEntry.unk1 = asset.unk;
|
fileEntry.unk1 = asset.unk;
|
||||||
fileEntry.unk2 = asset.unk2;
|
fileEntry.unk2 = asset.unk2;
|
||||||
|
@ -77,23 +77,45 @@ namespace FirstPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileEntry(string Name)
|
public NARC ArchiveFile;
|
||||||
|
|
||||||
|
public FileEntry(NARC narc, string Name)
|
||||||
{
|
{
|
||||||
|
ArchiveFile = narc;
|
||||||
FileName = Name.Replace(" ", string.Empty).RemoveIllegaleFolderNameCharacters();
|
FileName = Name.Replace(" ", string.Empty).RemoveIllegaleFolderNameCharacters();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override byte[] FileData
|
public override byte[] FileData
|
||||||
{
|
{
|
||||||
get
|
get { return DecompressBlock(); }
|
||||||
{
|
|
||||||
return DecompressBlock();
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsTexturesLoaded = false;
|
||||||
|
public override IFileFormat OpenFile()
|
||||||
|
{
|
||||||
|
var FileFormat = base.OpenFile();
|
||||||
|
bool IsModel = FileFormat is BFRES;
|
||||||
|
|
||||||
|
if (IsModel && !IsTexturesLoaded)
|
||||||
|
{
|
||||||
|
IsTexturesLoaded = true;
|
||||||
|
foreach (var file in ArchiveFile.Files)
|
||||||
|
{
|
||||||
|
if (Utils.GetExtension(file.FileName) == ".cbntx")
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Opening cbntx {file.FileName}");
|
||||||
|
file.FileFormat = file.OpenFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.OpenFile();
|
||||||
|
}
|
||||||
|
|
||||||
private byte[] DecompressBlock()
|
private byte[] DecompressBlock()
|
||||||
{
|
{
|
||||||
byte[] data = GetBlock();
|
byte[] data = GetBlock();
|
||||||
@ -153,7 +175,7 @@ namespace FirstPlugin
|
|||||||
List<byte> Data = new List<byte>();
|
List<byte> Data = new List<byte>();
|
||||||
for (ushort i = 0; i < header.FATB.FileCount; i++)
|
for (ushort i = 0; i < header.FATB.FileCount; i++)
|
||||||
{
|
{
|
||||||
FileEntries.Add(new FileEntry(names[i])
|
FileEntries.Add(new FileEntry(this, names[i])
|
||||||
{
|
{
|
||||||
entry = header.FATB.FileEntries[i],
|
entry = header.FATB.FileEntries[i],
|
||||||
fileImage = header.FIMG,
|
fileImage = header.FIMG,
|
||||||
@ -183,7 +205,6 @@ namespace FirstPlugin
|
|||||||
|
|
||||||
//EFE for REing format https://github.com/Gericom/EveryFileExplorer/blob/f9f00d193c9608d71c9a23d9f3ab7e752f4ada2a/NDS/NitroSystem/FND/NARC.cs
|
//EFE for REing format https://github.com/Gericom/EveryFileExplorer/blob/f9f00d193c9608d71c9a23d9f3ab7e752f4ada2a/NDS/NitroSystem/FND/NARC.cs
|
||||||
|
|
||||||
|
|
||||||
public class Header
|
public class Header
|
||||||
{
|
{
|
||||||
public string Signature;
|
public string Signature;
|
||||||
|
@ -792,6 +792,29 @@ namespace FirstPlugin
|
|||||||
texture.Type = MatTexture.TextureType.Shadow;
|
texture.Type = MatTexture.TextureType.Shadow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (mat.ShaderAssign.ShaderArchiveName == "ssg")
|
||||||
|
{
|
||||||
|
bool IsAlbedo0 = texture.SamplerName == "_a0";
|
||||||
|
bool IsNormal = texture.SamplerName == "_n0";
|
||||||
|
bool IsEmissive = texture.SamplerName == "_e0";
|
||||||
|
bool IsSpecular = texture.SamplerName == "_s0";
|
||||||
|
|
||||||
|
if (IsAlbedo0)
|
||||||
|
{
|
||||||
|
m.HasDiffuseMap = true;
|
||||||
|
texture.Type = MatTexture.TextureType.Diffuse;
|
||||||
|
}
|
||||||
|
if (IsNormal)
|
||||||
|
{
|
||||||
|
m.HasNormalMap = true;
|
||||||
|
texture.Type = MatTexture.TextureType.Normal;
|
||||||
|
}
|
||||||
|
if (IsSpecular)
|
||||||
|
{
|
||||||
|
m.HasSpecularMap = true;
|
||||||
|
texture.Type = MatTexture.TextureType.Specular;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (Runtime.activeGame == Runtime.ActiveGame.Bezel)
|
else if (Runtime.activeGame == Runtime.ActiveGame.Bezel)
|
||||||
{
|
{
|
||||||
bool IsAlbedo0 = useSampler == "_a0";
|
bool IsAlbedo0 = useSampler == "_a0";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user