Skip to content

Commit

Permalink
Fix textures in new wld zones
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgal committed Sep 17, 2023
1 parent dafe8b2 commit e8e8c7a
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions LanternExtractor/EQ/Wld/Fragments/Mesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Mesh : WldFragment
/// The vertices of the mesh
/// </summary>
public List<vec3> Vertices { get; set; }

/// <summary>
/// The normals of the mesh
/// </summary>
Expand All @@ -55,7 +55,7 @@ public class Mesh : WldFragment
/// The polygon indices of the mesh
/// </summary>
public List<Polygon> Indices { get; private set; }

public List<Color> Colors { get; set; }

/// <summary>
Expand Down Expand Up @@ -123,9 +123,9 @@ public override void Initialize(int index, int size, byte[] data,
// Seems to be related to lighting models? (torches, etc.)
if (unknownDword1 != 0 || unknownDword2 != 0 || unknownDword3 != 0)
{

}

MaxDistance = Reader.ReadSingle();
MinPosition = new vec3(Reader.ReadSingle(), Reader.ReadSingle(), Reader.ReadSingle());
MaxPosition = new vec3(Reader.ReadSingle(), Reader.ReadSingle(), Reader.ReadSingle());
Expand All @@ -145,7 +145,7 @@ public override void Initialize(int index, int size, byte[] data,
short vertexTextureCount = Reader.ReadInt16();
short size9 = Reader.ReadInt16();
float scale = 1.0f / (1 << Reader.ReadInt16());

for (int i = 0; i < vertexCount; ++i)
{
Vertices.Add(new vec3(Reader.ReadInt16() * scale, Reader.ReadInt16() * scale,
Expand All @@ -156,7 +156,7 @@ public override void Initialize(int index, int size, byte[] data,
{
if (isNewWldFormat)
{
TextureUvCoordinates.Add(new vec2(Reader.ReadInt32() / 256.0f, Reader.ReadInt32() / 256.0f));
TextureUvCoordinates.Add(new vec2(Reader.ReadSingle(), Reader.ReadSingle()));
}
else
{
Expand All @@ -179,7 +179,7 @@ public override void Initialize(int index, int size, byte[] data,
int g = colorBytes[1];
int r = colorBytes[2];
int a = colorBytes[3];

Colors.Add(new Color( r, g, b, a));
}

Expand All @@ -202,7 +202,7 @@ public override void Initialize(int index, int size, byte[] data,
Vertex3 = Reader.ReadInt16(),
});
}

MobPieces = new Dictionary<int, MobVertexPiece>();
int mobStart = 0;

Expand All @@ -224,7 +224,7 @@ public override void Initialize(int index, int size, byte[] data,
MaterialGroups = new List<RenderGroup>();

StartTextureIndex = Int32.MaxValue;

for (int i = 0; i < polygonTextureCount; ++i)
{
var group = new RenderGroup();
Expand All @@ -247,7 +247,7 @@ public override void Initialize(int index, int size, byte[] data,
{
Reader.BaseStream.Position += 12;
}

// In some rare cases, the number of uvs does not match the number of vertices
if (Vertices.Count != TextureUvCoordinates.Count)
{
Expand Down Expand Up @@ -291,4 +291,4 @@ public void ClearCollision()
ExportSeparateCollision = true;
}
}
}
}

0 comments on commit e8e8c7a

Please sign in to comment.