|
|
@ -4,9 +4,79 @@ using UnityEngine; |
|
|
|
|
|
|
|
|
public class TextureSet |
|
|
public class TextureSet |
|
|
{ |
|
|
{ |
|
|
public Texture2D MainTexture { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public Texture2D FullBrightTexture { get; set; } |
|
|
|
|
|
|
|
|
public List<TextureSkin> Skins { get; } = new List<TextureSkin>(); |
|
|
|
|
|
|
|
|
|
|
|
public TexturePair PrimaryTextures => Skins.Count > 0 && Skins[0].Frames.Count > 0 ? Skins[0].Frames[0] : null; |
|
|
|
|
|
|
|
|
|
|
|
public bool Import(GameAssets assets, QGLTexture[][] textures, QGLTexture[][] fullBrights) |
|
|
|
|
|
{ |
|
|
|
|
|
if (textures == null) |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
for (int skinIndex = 0; skinIndex < textures.Length; skinIndex++) |
|
|
|
|
|
{ |
|
|
|
|
|
if (textures[skinIndex] == null) |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
var skin = new TextureSkin(); |
|
|
|
|
|
if (skin.Import(assets, textures[skinIndex], |
|
|
|
|
|
fullBrights != null && skinIndex < fullBrights.Length ? fullBrights[skinIndex] : null)) |
|
|
|
|
|
{ |
|
|
|
|
|
Skins.Add(skin); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class TextureSkin |
|
|
|
|
|
{ |
|
|
|
|
|
public List<TexturePair> Frames { get; } = new List<TexturePair>(); |
|
|
|
|
|
|
|
|
|
|
|
public bool Import(GameAssets assets, QGLTexture[] textures, QGLTexture[] fullBrights) |
|
|
|
|
|
{ |
|
|
|
|
|
if (textures == null) |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
for (int frameIndex = 0; frameIndex < textures.Length; frameIndex++) |
|
|
|
|
|
{ |
|
|
|
|
|
if (textures[frameIndex] == null) |
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
var frame = new TexturePair(); |
|
|
|
|
|
if (frame.Import(assets, textures[frameIndex], |
|
|
|
|
|
fullBrights != null && frameIndex < fullBrights.Length ? fullBrights[frameIndex] : null)) |
|
|
|
|
|
{ |
|
|
|
|
|
Frames.Add(frame); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class TexturePair |
|
|
|
|
|
{ |
|
|
|
|
|
public Texture2D MainTexture { get; private set; } |
|
|
|
|
|
|
|
|
// TODO: organize into skins, frames/groups
|
|
|
|
|
|
|
|
|
public Texture2D FullBrightTexture { get; private set; } |
|
|
|
|
|
|
|
|
|
|
|
public bool Import(GameAssets assets, QGLTexture texture, QGLTexture fullBright) |
|
|
|
|
|
{ |
|
|
|
|
|
if (texture == null) |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (assets.TryGetTexture(texture.texNum, out var mainTexture)) |
|
|
|
|
|
{ |
|
|
|
|
|
MainTexture = mainTexture; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (fullBright != null && assets.TryGetTexture(fullBright.texNum, out var fullBrightTexture)) |
|
|
|
|
|
{ |
|
|
|
|
|
FullBrightTexture = fullBrightTexture; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
} |
|
|
} |