Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MiloLib/Assets/Rnd/RndCam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public RndCam Read(EndianReader reader, bool standalone, DirectoryMeta parent, D

if (revision == 8)
{
reader.ReadUInt32(); // coll version
objectsCount = reader.ReadUInt32();
for (int i = 0; i < objectsCount; i++)
{
Expand Down
27 changes: 17 additions & 10 deletions MiloLib/Assets/Rnd/RndLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public enum Type

public uint unkInt1;
public uint unkInt2;
public uint unkInt3;
public uint unkInt4;
public uint unkInt5;
public float constant_atten;
public float linear_atten;
public float quadratic_atten;

public RndLight Read(EndianReader reader, bool standalone, DirectoryMeta parent, DirectoryMeta.Entry entry)
{
Expand All @@ -75,18 +75,25 @@ public RndLight Read(EndianReader reader, bool standalone, DirectoryMeta parent,
else (altRevision, revision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)((combinedRevision >> 16) & 0xFFFF));


base.objFields.Read(reader, parent, entry);
if (revision > 3) base.objFields.Read(reader, parent, entry);

trans.Read(reader, false, parent, entry);

color = color.Read(reader);

if (revision < 3)
{
reader.ReadFloat(); // inner angle
reader.ReadFloat(); // outer angle
}

range = reader.ReadFloat();

if (revision < 3)
{
unkInt3 = reader.ReadUInt32();
unkInt4 = reader.ReadUInt32();
unkInt5 = reader.ReadUInt32();
constant_atten = reader.ReadFloat();
linear_atten = reader.ReadFloat();
quadratic_atten = reader.ReadFloat();
}

if (revision != 0)
Expand Down Expand Up @@ -179,9 +186,9 @@ public override void Write(EndianWriter writer, bool standalone, DirectoryMeta p

if (revision < 3)
{
writer.WriteUInt32(unkInt3);
writer.WriteUInt32(unkInt4);
writer.WriteUInt32(unkInt5);
writer.WriteFloat(constant_atten);
writer.WriteFloat(linear_atten);
writer.WriteFloat(quadratic_atten);
}

if (revision != 0)
Expand Down
68 changes: 66 additions & 2 deletions MiloLib/Assets/Rnd/RndMat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,41 @@ public void Write(EndianWriter writer)
Symbol.Write(writer, name);
}
}

public class TextureEntry_Amp
{
public Blend blendMode;
public int coordIndex;
public TexGen genMode;
public Matrix texXfm = new Matrix();
public bool useXfm;
public int wrapMode; // differs from TexWrap
public Symbol tex_name = new Symbol(0, "");

public TextureEntry_Amp Read(EndianReader reader)
{
blendMode = (Blend)reader.ReadInt32();
coordIndex = reader.ReadInt32();
genMode = (TexGen)reader.ReadInt32();
texXfm = new Matrix().Read(reader);
useXfm = reader.ReadBoolean();
wrapMode = reader.ReadInt32();
tex_name = Symbol.Read(reader);
return this;
}

public void Write(EndianWriter writer)
{
writer.WriteInt32((int)blendMode);
writer.WriteInt32(coordIndex);
writer.WriteInt32((int)genMode);
texXfm.Write(writer);
writer.WriteBoolean(useXfm);
writer.WriteInt32(wrapMode);
Symbol.Write(writer, tex_name);
}
}

private ushort altRevision;
private ushort revision;

Expand Down Expand Up @@ -292,6 +327,9 @@ public void Write(EndianWriter writer)
private uint textureCount;
public List<TextureEntry> textures = new();

private uint textureCountAmp;
public List<TextureEntry_Amp> textures_amp = new();

public int unkInt1;
public int unkInt2;
public int unkInt3;
Expand All @@ -314,6 +352,11 @@ public RndMat Read(EndianReader reader, bool standalone, DirectoryMeta parent, D

if (revision <= 9)
{
textureCountAmp = reader.ReadUInt32();
for (int i = 0; i < textureCountAmp; i++)
{
textures_amp.Add(new TextureEntry_Amp().Read(reader));
}
}
else if (revision <= 21)
{
Expand All @@ -324,12 +367,33 @@ public RndMat Read(EndianReader reader, bool standalone, DirectoryMeta parent, D
}
}

base.Read(reader, false, parent, entry);
if (revision > 21) {
base.Read(reader, false, parent, entry);
}

blend = (Blend)reader.ReadInt32();
color = new HmxColor4().Read(reader);

if (revision <= 21)
if (revision <= 15)
{
HmxColor4 light_color = new HmxColor4().Read(reader);
HmxColor4 edge_color = new HmxColor4().Read(reader);
reader.ReadByte(); // mat enable?
reader.ReadByte(); // unk
reader.ReadByte(); // do vert lighting
reader.ReadByte(); // do edge highlights
reader.ReadUInt32(); // cull winding dir
reader.ReadUInt32(); // do multipass processing(?)
reader.ReadByte(); // "normalize"
reader.ReadByte(); // do flat shading
reader.ReadByte(); // "base ambient"
if (standalone)
{
if ((reader.Endianness == Endian.BigEndian ? 0xADDEADDE : 0xDEADDEAD) != reader.ReadUInt32()) throw new Exception("Got to end of standalone asset but didn't find the expected end bytes, read likely did not succeed");
}
return this;
}
else if (revision <= 21)
{
reader.ReadByte();
reader.ReadUInt16();
Expand Down
74 changes: 72 additions & 2 deletions MiloLib/Assets/Rnd/RndMatAnim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,67 @@ public override string ToString()

public class RndMatAnimStage
{
public List<Vec3Key> transKeys = new List<Vec3Key>();
public List<Vec3Key> scaleKeys = new List<Vec3Key>();
public List<Vec3Key> rotKeys = new List<Vec3Key>();
public List<SymbolKey> texKeys = new List<SymbolKey>();

public RndMatAnimStage Read(EndianReader reader)
{
uint transKeysCount = reader.ReadUInt32();
for (uint i = 0; i < transKeysCount; i++)
{
Vec3Key transKey = new();
transKey.Read(reader);
transKeys.Add(transKey);
}
uint scaleKeysCount = reader.ReadUInt32();
for (uint i = 0; i < scaleKeysCount; i++)
{
Vec3Key scaleKey = new();
scaleKey.Read(reader);
scaleKeys.Add(scaleKey);
}
uint rotKeysCount = reader.ReadUInt32();
for (uint i = 0; i < rotKeysCount; i++)
{
Vec3Key rotKey = new();
rotKey.Read(reader);
rotKeys.Add(rotKey);
}
uint texKeysCount = reader.ReadUInt32();
for (uint i = 0; i < texKeysCount; i++)
{
SymbolKey texKey = new();
texKey.Read(reader);
texKeys.Add(texKey);
}
return this;
}

public void Write(EndianWriter writer)
{
writer.WriteUInt32((uint)transKeys.Count);
foreach (Vec3Key transKey in transKeys)
{
transKey.Write(writer);
}
writer.WriteUInt32((uint)scaleKeys.Count);
foreach (Vec3Key scaleKey in scaleKeys)
{
scaleKey.Write(writer);
}
writer.WriteUInt32((uint)rotKeys.Count);
foreach (Vec3Key rotKey in rotKeys)
{
rotKey.Write(writer);
}
writer.WriteUInt32((uint)texKeys.Count);
foreach (SymbolKey texKey in texKeys)
{
texKey.Write(writer);
}
}
}

private ushort altRevision;
Expand Down Expand Up @@ -175,8 +235,8 @@ public class RndMatAnimStage
private uint colorKeysCount3;
[MaxVersion(3)]
public List<ColorKey> colorKeys3 = new();


[MaxVersion(3)]
public List<RndMatAnimStage> stages = new();



Expand All @@ -195,6 +255,16 @@ public RndMatAnim Read(EndianReader reader, bool standalone, DirectoryMeta paren

material = Symbol.Read(reader);

if (revision <= 3)
{
uint stage_ct = reader.ReadUInt32();
for (uint i = 0; i < stage_ct; i++) {
RndMatAnimStage stage = new();
stage.Read(reader);
stages.Add(stage);
}
}

keysOwner = Symbol.Read(reader);

if (revision > 1)
Expand Down
26 changes: 23 additions & 3 deletions MiloLib/Assets/Rnd/RndMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,25 @@ public RndMesh Read(EndianReader reader, bool standalone, DirectoryMeta parent,
if (BitConverter.IsLittleEndian) (revision, altRevision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)((combinedRevision >> 16) & 0xFFFF));
else (altRevision, revision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)((combinedRevision >> 16) & 0xFFFF));

base.Read(reader, false, parent, entry);
if (revision > 25) base.Read(reader, false, parent, entry);


trans = trans.Read(reader, false, parent, entry);
draw = draw.Read(reader, false, parent, entry);

if (revision < 15)
{
uint collideable_rev = reader.ReadUInt32();
uint collideable_refs_siz = reader.ReadUInt32();
for (uint i = 0; i < collideable_refs_siz; i++)
{
Symbol.Read(reader);
}

uint z_mode = reader.ReadUInt32();
uint z_comparison_func = reader.ReadUInt32();
}

mat = Symbol.Read(reader);

if (revision == 27)
Expand Down Expand Up @@ -673,8 +686,6 @@ public RndMesh Read(EndianReader reader, bool standalone, DirectoryMeta parent,
unkFloat = reader.ReadFloat();
}



if (revision < 16)
{
if (revision > 11)
Expand Down Expand Up @@ -706,6 +717,15 @@ public RndMesh Read(EndianReader reader, bool standalone, DirectoryMeta parent,
faces.Add(new Face().Read(reader));
}

if (revision < 15) {
uint edgeCount = reader.ReadUInt32();
for (int i = 0; i < edgeCount; i++)
{
reader.ReadUInt16();
reader.ReadUInt16();
}
}

if (revision > 0x17)
{
groupSizesCount = reader.ReadUInt32();
Expand Down
Loading