diff --git a/TREnvironmentEditor/Model/BaseEMFunction.cs b/TREnvironmentEditor/Model/BaseEMFunction.cs index 3fabe0b8d..99a9cc453 100644 --- a/TREnvironmentEditor/Model/BaseEMFunction.cs +++ b/TREnvironmentEditor/Model/BaseEMFunction.cs @@ -49,29 +49,29 @@ public static List GetTileVertices(short x, short y, short z, bool asC public static int CreateRoomVertex(TR1Room room, TRVertex vert, short lighting = 6574) { - room.RoomData.Vertices.Add(new() + room.Mesh.Vertices.Add(new() { Lighting = lighting, Vertex = vert }); - return room.RoomData.Vertices.Count - 1; + return room.Mesh.Vertices.Count - 1; } public static int CreateRoomVertex(TR2Room room, TRVertex vert, short lighting = 6574, short lighting2 = 6574) { - room.RoomData.Vertices.Add(new() + room.Mesh.Vertices.Add(new() { Attributes = 32784, // This stops it shimmering if viewed from underwater, should be configurable Lighting = lighting, Lighting2 = lighting2, Vertex = vert }); - return room.RoomData.Vertices.Count - 1; + return room.Mesh.Vertices.Count - 1; } public static int CreateRoomVertex(TR3Room room, TRVertex vert, short lighting = 6574, ushort colour = 6574, bool useCaustics = false, bool useWaveMovement = false) { - room.RoomData.Vertices.Add(new() + room.Mesh.Vertices.Add(new() { Attributes = 32784, Lighting = lighting, @@ -80,7 +80,7 @@ public static int CreateRoomVertex(TR3Room room, TRVertex vert, short lighting = UseWaveMovement = useWaveMovement, Vertex = vert }); - return room.RoomData.Vertices.Count - 1; + return room.Mesh.Vertices.Count - 1; } /// diff --git a/TREnvironmentEditor/Model/Types/Mirroring/EMMirrorFunction.cs b/TREnvironmentEditor/Model/Types/Mirroring/EMMirrorFunction.cs index 9c8c1356d..511048153 100644 --- a/TREnvironmentEditor/Model/Types/Mirroring/EMMirrorFunction.cs +++ b/TREnvironmentEditor/Model/Types/Mirroring/EMMirrorFunction.cs @@ -300,9 +300,9 @@ private void MirrorRooms(TR1Level level) Debug.Assert(room.Info.X >= 0); // Flip room sprites separately as they don't sit on tile edges List processedVerts = new(); - foreach (TRRoomSprite sprite in room.RoomData.Sprites) + foreach (TRRoomSprite sprite in room.Mesh.Sprites) { - TR1RoomVertex roomVertex = room.RoomData.Vertices[sprite.Vertex]; + TR1RoomVertex roomVertex = room.Mesh.Vertices[sprite.Vertex]; // Flip the old world coordinate, then subtract the new room position int x = oldRoomX + roomVertex.Vertex.X; @@ -315,7 +315,7 @@ private void MirrorRooms(TR1Level level) } // Flip the face vertices - foreach (TR1RoomVertex vert in room.RoomData.Vertices) + foreach (TR1RoomVertex vert in room.Mesh.Vertices) { if (processedVerts.Contains(vert)) { @@ -374,9 +374,9 @@ private void MirrorRooms(TR2Level level) Debug.Assert(room.Info.X >= 0); // Flip room sprites separately as they don't sit on tile edges List processedVerts = new(); - foreach (TRRoomSprite sprite in room.RoomData.Sprites) + foreach (TRRoomSprite sprite in room.Mesh.Sprites) { - TR2RoomVertex roomVertex = room.RoomData.Vertices[sprite.Vertex]; + TR2RoomVertex roomVertex = room.Mesh.Vertices[sprite.Vertex]; // Flip the old world coordinate, then subtract the new room position int x = oldRoomX + roomVertex.Vertex.X; @@ -389,7 +389,7 @@ private void MirrorRooms(TR2Level level) } // Flip the face vertices - foreach (TR2RoomVertex vert in room.RoomData.Vertices) + foreach (TR2RoomVertex vert in room.Mesh.Vertices) { if (processedVerts.Contains(vert)) { @@ -448,9 +448,9 @@ private void MirrorRooms(TR3Level level) Debug.Assert(room.Info.X >= 0); // Flip room sprites separately as they don't sit on tile edges List processedVerts = new(); - foreach (TRRoomSprite sprite in room.RoomData.Sprites) + foreach (TRRoomSprite sprite in room.Mesh.Sprites) { - TR3RoomVertex roomVertex = room.RoomData.Vertices[sprite.Vertex]; + TR3RoomVertex roomVertex = room.Mesh.Vertices[sprite.Vertex]; // Flip the old world coordinate, then subtract the new room position int x = oldRoomX + roomVertex.Vertex.X; @@ -463,7 +463,7 @@ private void MirrorRooms(TR3Level level) } // Flip the face vertices - foreach (TR3RoomVertex vert in room.RoomData.Vertices) + foreach (TR3RoomVertex vert in room.Mesh.Vertices) { if (processedVerts.Contains(vert)) { @@ -1009,14 +1009,14 @@ private static void MirrorTextures(TR1Level level) foreach (TR1Room room in level.Rooms) { // Invert the faces, otherwise they are inside out - foreach (TRFace4 f in room.RoomData.Rectangles) + foreach (TRFace4 f in room.Mesh.Rectangles) { Swap(f.Vertices, 0, 3); Swap(f.Vertices, 1, 2); textureReferences.Add(f.Texture); } - foreach (TRFace3 f in room.RoomData.Triangles) + foreach (TRFace3 f in room.Mesh.Triangles) { Swap(f.Vertices, 0, 2); textureReferences.Add(f.Texture); @@ -1087,14 +1087,14 @@ private static void MirrorTextures(TR2Level level) foreach (TR2Room room in level.Rooms) { // Invert the faces, otherwise they are inside out - foreach (TRFace4 f in room.RoomData.Rectangles) + foreach (TRFace4 f in room.Mesh.Rectangles) { Swap(f.Vertices, 0, 3); Swap(f.Vertices, 1, 2); textureReferences.Add(f.Texture); } - foreach (TRFace3 f in room.RoomData.Triangles) + foreach (TRFace3 f in room.Mesh.Triangles) { Swap(f.Vertices, 0, 2); textureReferences.Add(f.Texture); @@ -1157,14 +1157,14 @@ private static void MirrorTextures(TR3Level level) foreach (TR3Room room in level.Rooms) { // Invert the faces, otherwise they are inside out - foreach (TRFace4 f in room.RoomData.Rectangles) + foreach (TRFace4 f in room.Mesh.Rectangles) { Swap(f.Vertices, 0, 3); Swap(f.Vertices, 1, 2); textureReferences.Add((ushort)(f.Texture & 0x0fff)); } - foreach (TRFace3 f in room.RoomData.Triangles) + foreach (TRFace3 f in room.Mesh.Triangles) { Swap(f.Vertices, 0, 2); textureReferences.Add((ushort)(f.Texture & 0x0fff)); diff --git a/TREnvironmentEditor/Model/Types/Rooms/EMCopyRoomFunction.cs b/TREnvironmentEditor/Model/Types/Rooms/EMCopyRoomFunction.cs index eb4861f7f..44a48b026 100644 --- a/TREnvironmentEditor/Model/Types/Rooms/EMCopyRoomFunction.cs +++ b/TREnvironmentEditor/Model/Types/Rooms/EMCopyRoomFunction.cs @@ -41,7 +41,7 @@ public override void ApplyToLevel(TR1Level level) NumXSectors = baseRoom.NumXSectors, NumZSectors = baseRoom.NumZSectors, Portals = new(), - RoomData = new() + Mesh = new() { Rectangles = new(), Sprites = new(), @@ -66,54 +66,54 @@ public override void ApplyToLevel(TR1Level level) } // Faces - for (int i = 0; i < baseRoom.RoomData.Rectangles.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Rectangles.Count; i++) { - newRoom.RoomData.Rectangles.Add(new() + newRoom.Mesh.Rectangles.Add(new() { - Texture = baseRoom.RoomData.Rectangles[i].Texture, - Vertices = new ushort[baseRoom.RoomData.Rectangles[i].Vertices.Length] + Texture = baseRoom.Mesh.Rectangles[i].Texture, + Vertices = new ushort[baseRoom.Mesh.Rectangles[i].Vertices.Length] }); - for (int j = 0; j < newRoom.RoomData.Rectangles[i].Vertices.Length; j++) + for (int j = 0; j < newRoom.Mesh.Rectangles[i].Vertices.Length; j++) { - newRoom.RoomData.Rectangles[i].Vertices[j] = baseRoom.RoomData.Rectangles[i].Vertices[j]; + newRoom.Mesh.Rectangles[i].Vertices[j] = baseRoom.Mesh.Rectangles[i].Vertices[j]; } } - for (int i = 0; i < baseRoom.RoomData.Triangles.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Triangles.Count; i++) { - newRoom.RoomData.Triangles.Add(new() + newRoom.Mesh.Triangles.Add(new() { - Texture = baseRoom.RoomData.Triangles[i].Texture, - Vertices = new ushort[baseRoom.RoomData.Triangles[i].Vertices.Length] + Texture = baseRoom.Mesh.Triangles[i].Texture, + Vertices = new ushort[baseRoom.Mesh.Triangles[i].Vertices.Length] }); - for (int j = 0; j < newRoom.RoomData.Triangles[i].Vertices.Length; j++) + for (int j = 0; j < newRoom.Mesh.Triangles[i].Vertices.Length; j++) { - newRoom.RoomData.Triangles[i].Vertices[j] = baseRoom.RoomData.Triangles[i].Vertices[j]; + newRoom.Mesh.Triangles[i].Vertices[j] = baseRoom.Mesh.Triangles[i].Vertices[j]; } } // Vertices - for (int i = 0; i < baseRoom.RoomData.Vertices.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Vertices.Count; i++) { - newRoom.RoomData.Vertices.Add(new() + newRoom.Mesh.Vertices.Add(new() { - Lighting = baseRoom.RoomData.Vertices[i].Lighting, + Lighting = baseRoom.Mesh.Vertices[i].Lighting, Vertex = new() { - X = baseRoom.RoomData.Vertices[i].Vertex.X, // Room coords for X and Z - Y = (short)(baseRoom.RoomData.Vertices[i].Vertex.Y + ydiff), - Z = baseRoom.RoomData.Vertices[i].Vertex.Z + X = baseRoom.Mesh.Vertices[i].Vertex.X, // Room coords for X and Z + Y = (short)(baseRoom.Mesh.Vertices[i].Vertex.Y + ydiff), + Z = baseRoom.Mesh.Vertices[i].Vertex.Z } }); } // Sprites - for (int i = 0; i < baseRoom.RoomData.Sprites.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Sprites.Count; i++) { - newRoom.RoomData.Sprites.Add(new() + newRoom.Mesh.Sprites.Add(new() { - Texture = baseRoom.RoomData.Sprites[i].Texture, - Vertex = baseRoom.RoomData.Sprites[i].Vertex + Texture = baseRoom.Mesh.Sprites[i].Texture, + Vertex = baseRoom.Mesh.Sprites[i].Vertex }); } @@ -179,7 +179,7 @@ public override void ApplyToLevel(TR2Level level) NumXSectors = baseRoom.NumXSectors, NumZSectors = baseRoom.NumZSectors, Portals = new(), - RoomData = new() + Mesh = new() { Rectangles = new(), Sprites = new(), @@ -206,56 +206,56 @@ public override void ApplyToLevel(TR2Level level) } // Faces - for (int i = 0; i < baseRoom.RoomData.Rectangles.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Rectangles.Count; i++) { - newRoom.RoomData.Rectangles.Add(new() + newRoom.Mesh.Rectangles.Add(new() { - Texture = baseRoom.RoomData.Rectangles[i].Texture, - Vertices = new ushort[baseRoom.RoomData.Rectangles[i].Vertices.Length] + Texture = baseRoom.Mesh.Rectangles[i].Texture, + Vertices = new ushort[baseRoom.Mesh.Rectangles[i].Vertices.Length] }); - for (int j = 0; j < newRoom.RoomData.Rectangles[i].Vertices.Length; j++) + for (int j = 0; j < newRoom.Mesh.Rectangles[i].Vertices.Length; j++) { - newRoom.RoomData.Rectangles[i].Vertices[j] = baseRoom.RoomData.Rectangles[i].Vertices[j]; + newRoom.Mesh.Rectangles[i].Vertices[j] = baseRoom.Mesh.Rectangles[i].Vertices[j]; } } - for (int i = 0; i < baseRoom.RoomData.Triangles.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Triangles.Count; i++) { - newRoom.RoomData.Triangles.Add(new() + newRoom.Mesh.Triangles.Add(new() { - Texture = baseRoom.RoomData.Triangles[i].Texture, - Vertices = new ushort[baseRoom.RoomData.Triangles[i].Vertices.Length] + Texture = baseRoom.Mesh.Triangles[i].Texture, + Vertices = new ushort[baseRoom.Mesh.Triangles[i].Vertices.Length] }); - for (int j = 0; j < newRoom.RoomData.Triangles[i].Vertices.Length; j++) + for (int j = 0; j < newRoom.Mesh.Triangles[i].Vertices.Length; j++) { - newRoom.RoomData.Triangles[i].Vertices[j] = baseRoom.RoomData.Triangles[i].Vertices[j]; + newRoom.Mesh.Triangles[i].Vertices[j] = baseRoom.Mesh.Triangles[i].Vertices[j]; } } // Vertices - for (int i = 0; i < baseRoom.RoomData.Vertices.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Vertices.Count; i++) { - newRoom.RoomData.Vertices.Add(new() + newRoom.Mesh.Vertices.Add(new() { - Attributes = baseRoom.RoomData.Vertices[i].Attributes, - Lighting = baseRoom.RoomData.Vertices[i].Lighting, - Lighting2 = baseRoom.RoomData.Vertices[i].Lighting2, + Attributes = baseRoom.Mesh.Vertices[i].Attributes, + Lighting = baseRoom.Mesh.Vertices[i].Lighting, + Lighting2 = baseRoom.Mesh.Vertices[i].Lighting2, Vertex = new TRVertex { - X = baseRoom.RoomData.Vertices[i].Vertex.X, // Room coords for X and Z - Y = (short)(baseRoom.RoomData.Vertices[i].Vertex.Y + ydiff), - Z = baseRoom.RoomData.Vertices[i].Vertex.Z + X = baseRoom.Mesh.Vertices[i].Vertex.X, // Room coords for X and Z + Y = (short)(baseRoom.Mesh.Vertices[i].Vertex.Y + ydiff), + Z = baseRoom.Mesh.Vertices[i].Vertex.Z } }); } // Sprites - for (int i = 0; i < baseRoom.RoomData.Sprites.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Sprites.Count; i++) { - newRoom.RoomData.Sprites.Add(new() + newRoom.Mesh.Sprites.Add(new() { - Texture = baseRoom.RoomData.Sprites[i].Texture, - Vertex = baseRoom.RoomData.Sprites[i].Vertex + Texture = baseRoom.Mesh.Sprites[i].Texture, + Vertex = baseRoom.Mesh.Sprites[i].Vertex }); } @@ -323,7 +323,7 @@ public override void ApplyToLevel(TR3Level level) NumZSectors = baseRoom.NumZSectors, Portals = new(), ReverbInfo = baseRoom.ReverbInfo, - RoomData = new() + Mesh = new() { Rectangles = new(), Sprites = new(), @@ -350,56 +350,56 @@ public override void ApplyToLevel(TR3Level level) } // Faces - for (int i = 0; i < baseRoom.RoomData.Rectangles.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Rectangles.Count; i++) { - newRoom.RoomData.Rectangles.Add(new() + newRoom.Mesh.Rectangles.Add(new() { - Texture = baseRoom.RoomData.Rectangles[i].Texture, - Vertices = new ushort[baseRoom.RoomData.Rectangles[i].Vertices.Length] + Texture = baseRoom.Mesh.Rectangles[i].Texture, + Vertices = new ushort[baseRoom.Mesh.Rectangles[i].Vertices.Length] }); - for (int j = 0; j < newRoom.RoomData.Rectangles[i].Vertices.Length; j++) + for (int j = 0; j < newRoom.Mesh.Rectangles[i].Vertices.Length; j++) { - newRoom.RoomData.Rectangles[i].Vertices[j] = baseRoom.RoomData.Rectangles[i].Vertices[j]; + newRoom.Mesh.Rectangles[i].Vertices[j] = baseRoom.Mesh.Rectangles[i].Vertices[j]; } } - for (int i = 0; i < baseRoom.RoomData.Triangles.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Triangles.Count; i++) { - newRoom.RoomData.Triangles.Add(new() + newRoom.Mesh.Triangles.Add(new() { - Texture = baseRoom.RoomData.Triangles[i].Texture, - Vertices = new ushort[baseRoom.RoomData.Triangles[i].Vertices.Length] + Texture = baseRoom.Mesh.Triangles[i].Texture, + Vertices = new ushort[baseRoom.Mesh.Triangles[i].Vertices.Length] }); - for (int j = 0; j < newRoom.RoomData.Triangles[i].Vertices.Length; j++) + for (int j = 0; j < newRoom.Mesh.Triangles[i].Vertices.Length; j++) { - newRoom.RoomData.Triangles[i].Vertices[j] = baseRoom.RoomData.Triangles[i].Vertices[j]; + newRoom.Mesh.Triangles[i].Vertices[j] = baseRoom.Mesh.Triangles[i].Vertices[j]; } } // Vertices - for (int i = 0; i < baseRoom.RoomData.Vertices.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Vertices.Count; i++) { - newRoom.RoomData.Vertices.Add(new() + newRoom.Mesh.Vertices.Add(new() { - Attributes = baseRoom.RoomData.Vertices[i].Attributes, - Colour = baseRoom.RoomData.Vertices[i].Colour, - Lighting = baseRoom.RoomData.Vertices[i].Lighting, + Attributes = baseRoom.Mesh.Vertices[i].Attributes, + Colour = baseRoom.Mesh.Vertices[i].Colour, + Lighting = baseRoom.Mesh.Vertices[i].Lighting, Vertex = new TRVertex { - X = baseRoom.RoomData.Vertices[i].Vertex.X, // Room coords for X and Z - Y = (short)(baseRoom.RoomData.Vertices[i].Vertex.Y + ydiff), - Z = baseRoom.RoomData.Vertices[i].Vertex.Z + X = baseRoom.Mesh.Vertices[i].Vertex.X, // Room coords for X and Z + Y = (short)(baseRoom.Mesh.Vertices[i].Vertex.Y + ydiff), + Z = baseRoom.Mesh.Vertices[i].Vertex.Z } }); } // Sprites - for (int i = 0; i < baseRoom.RoomData.Sprites.Count; i++) + for (int i = 0; i < baseRoom.Mesh.Sprites.Count; i++) { - newRoom.RoomData.Sprites.Add(new() + newRoom.Mesh.Sprites.Add(new() { - Texture = baseRoom.RoomData.Sprites[i].Texture, - Vertex = baseRoom.RoomData.Sprites[i].Vertex + Texture = baseRoom.Mesh.Sprites[i].Texture, + Vertex = baseRoom.Mesh.Sprites[i].Vertex }); } diff --git a/TREnvironmentEditor/Model/Types/Rooms/EMCopyVertexAttributesFunction.cs b/TREnvironmentEditor/Model/Types/Rooms/EMCopyVertexAttributesFunction.cs index a7da23a14..87d10d1a1 100644 --- a/TREnvironmentEditor/Model/Types/Rooms/EMCopyVertexAttributesFunction.cs +++ b/TREnvironmentEditor/Model/Types/Rooms/EMCopyVertexAttributesFunction.cs @@ -26,12 +26,12 @@ public override void ApplyToLevel(TR1Level level) switch (faceType) { case EMTextureFaceType.Rectangles: - baseVertices = room.RoomData.Rectangles[baseFaceIndex].Vertices; - copyVertices = room.RoomData.Rectangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; + baseVertices = room.Mesh.Rectangles[baseFaceIndex].Vertices; + copyVertices = room.Mesh.Rectangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; break; case EMTextureFaceType.Triangles: - baseVertices = room.RoomData.Triangles[baseFaceIndex].Vertices; - copyVertices = room.RoomData.Triangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; + baseVertices = room.Mesh.Triangles[baseFaceIndex].Vertices; + copyVertices = room.Mesh.Triangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; break; default: throw new ArgumentException($"Unknown face type {faceType}"); @@ -39,8 +39,8 @@ public override void ApplyToLevel(TR1Level level) for (int i = 0; i < baseVertices.Length; i++) { - TR1RoomVertex baseVertex = room.RoomData.Vertices[baseVertices[i]]; - TR1RoomVertex copyVertex = room.RoomData.Vertices[copyVertices[i]]; + TR1RoomVertex baseVertex = room.Mesh.Vertices[baseVertices[i]]; + TR1RoomVertex copyVertex = room.Mesh.Vertices[copyVertices[i]]; CopyAttributes(baseVertex, copyVertex); } } @@ -54,7 +54,7 @@ public override void ApplyToLevel(TR1Level level) foreach (short roomNumber in RoomMap.Keys) { TR1Room room = level.Rooms[data.ConvertRoom(roomNumber)]; - foreach (TR1RoomVertex copyVertex in room.RoomData.Vertices) + foreach (TR1RoomVertex copyVertex in room.Mesh.Vertices) { CopyAttributes(RoomMap[roomNumber], copyVertex); } @@ -80,12 +80,12 @@ public override void ApplyToLevel(TR2Level level) switch (faceType) { case EMTextureFaceType.Rectangles: - baseVertices = room.RoomData.Rectangles[baseFaceIndex].Vertices; - copyVertices = room.RoomData.Rectangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; + baseVertices = room.Mesh.Rectangles[baseFaceIndex].Vertices; + copyVertices = room.Mesh.Rectangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; break; case EMTextureFaceType.Triangles: - baseVertices = room.RoomData.Triangles[baseFaceIndex].Vertices; - copyVertices = room.RoomData.Triangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; + baseVertices = room.Mesh.Triangles[baseFaceIndex].Vertices; + copyVertices = room.Mesh.Triangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; break; default: throw new ArgumentException($"Unknown face type {faceType}"); @@ -93,8 +93,8 @@ public override void ApplyToLevel(TR2Level level) for (int i = 0; i < baseVertices.Length; i++) { - TR2RoomVertex baseVertex = room.RoomData.Vertices[baseVertices[i]]; - TR2RoomVertex copyVertex = room.RoomData.Vertices[copyVertices[i]]; + TR2RoomVertex baseVertex = room.Mesh.Vertices[baseVertices[i]]; + TR2RoomVertex copyVertex = room.Mesh.Vertices[copyVertices[i]]; CopyAttributes(baseVertex, copyVertex); } } @@ -108,7 +108,7 @@ public override void ApplyToLevel(TR2Level level) foreach (short roomNumber in RoomMap.Keys) { TR2Room room = level.Rooms[data.ConvertRoom(roomNumber)]; - foreach (TR2RoomVertex copyVertex in room.RoomData.Vertices) + foreach (TR2RoomVertex copyVertex in room.Mesh.Vertices) { CopyAttributes(RoomMap[roomNumber], copyVertex); } @@ -134,12 +134,12 @@ public override void ApplyToLevel(TR3Level level) switch (faceType) { case EMTextureFaceType.Rectangles: - baseVertices = room.RoomData.Rectangles[baseFaceIndex].Vertices; - copyVertices = room.RoomData.Rectangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; + baseVertices = room.Mesh.Rectangles[baseFaceIndex].Vertices; + copyVertices = room.Mesh.Rectangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; break; case EMTextureFaceType.Triangles: - baseVertices = room.RoomData.Triangles[baseFaceIndex].Vertices; - copyVertices = room.RoomData.Triangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; + baseVertices = room.Mesh.Triangles[baseFaceIndex].Vertices; + copyVertices = room.Mesh.Triangles[FaceMap[roomNumber][faceType][baseFaceIndex]].Vertices; break; default: throw new ArgumentException($"Unknown face type {faceType}"); @@ -147,8 +147,8 @@ public override void ApplyToLevel(TR3Level level) for (int i = 0; i < baseVertices.Length; i++) { - TR3RoomVertex baseVertex = room.RoomData.Vertices[baseVertices[i]]; - TR3RoomVertex copyVertex = room.RoomData.Vertices[copyVertices[i]]; + TR3RoomVertex baseVertex = room.Mesh.Vertices[baseVertices[i]]; + TR3RoomVertex copyVertex = room.Mesh.Vertices[copyVertices[i]]; CopyAttributes(baseVertex, copyVertex); } } @@ -162,7 +162,7 @@ public override void ApplyToLevel(TR3Level level) foreach (short roomNumber in RoomMap.Keys) { TR3Room room = level.Rooms[data.ConvertRoom(roomNumber)]; - foreach (TR3RoomVertex copyVertex in room.RoomData.Vertices) + foreach (TR3RoomVertex copyVertex in room.Mesh.Vertices) { CopyAttributes(RoomMap[roomNumber], copyVertex); } diff --git a/TREnvironmentEditor/Model/Types/Rooms/EMCreateRoomFunction.cs b/TREnvironmentEditor/Model/Types/Rooms/EMCreateRoomFunction.cs index 267ab2e5d..078b74605 100644 --- a/TREnvironmentEditor/Model/Types/Rooms/EMCreateRoomFunction.cs +++ b/TREnvironmentEditor/Model/Types/Rooms/EMCreateRoomFunction.cs @@ -38,7 +38,7 @@ public override void ApplyToLevel(TR1Level level) YTop = Location.Y - Height * TRConsts.Step1, Z = Location.Z }, - RoomData = new() + Mesh = new() { Rectangles = new(), Triangles = new(), @@ -77,9 +77,9 @@ public override void ApplyToLevel(TR1Level level) // Stride the sectors again and make faces List vertices = new(); - GenerateFaces(room.Sectors, room.RoomData.Rectangles, vertices); + GenerateFaces(room.Sectors, room.Mesh.Rectangles, vertices); - room.RoomData.Vertices.AddRange(vertices.Select(v => new TR1RoomVertex + room.Mesh.Vertices.AddRange(vertices.Select(v => new TR1RoomVertex { Lighting = DefaultVertex.Lighting, Vertex = v @@ -105,7 +105,7 @@ public override void ApplyToLevel(TR2Level level) YTop = Location.Y - Height * TRConsts.Step1, Z = Location.Z }, - RoomData = new() + Mesh = new() { Rectangles = new(), Triangles = new(), @@ -146,9 +146,9 @@ public override void ApplyToLevel(TR2Level level) // Stride the sectors again and make faces List vertices = new(); - GenerateFaces(room.Sectors, room.RoomData.Rectangles, vertices); + GenerateFaces(room.Sectors, room.Mesh.Rectangles, vertices); - room.RoomData.Vertices.AddRange(vertices.Select(v => new TR2RoomVertex + room.Mesh.Vertices.AddRange(vertices.Select(v => new TR2RoomVertex { Lighting = DefaultVertex.Lighting, Lighting2 = DefaultVertex.Lighting2, @@ -176,7 +176,7 @@ public override void ApplyToLevel(TR3Level level) YTop = Location.Y - Height * TRConsts.Step1, Z = Location.Z }, - RoomData = new() + Mesh = new() { Rectangles = new(), Triangles = new(), @@ -216,9 +216,9 @@ public override void ApplyToLevel(TR3Level level) // Stride the sectors again and make faces List vertices = new(); - GenerateFaces(room.Sectors, room.RoomData.Rectangles, vertices); + GenerateFaces(room.Sectors, room.Mesh.Rectangles, vertices); - room.RoomData.Vertices.AddRange(vertices.Select(v => new TR3RoomVertex + room.Mesh.Vertices.AddRange(vertices.Select(v => new TR3RoomVertex { Lighting = DefaultVertex.Lighting, Attributes = DefaultVertex.Attributes, diff --git a/TREnvironmentEditor/Model/Types/Rooms/EMGenerateLightFunction.cs b/TREnvironmentEditor/Model/Types/Rooms/EMGenerateLightFunction.cs index 7e597cdab..4509ba624 100644 --- a/TREnvironmentEditor/Model/Types/Rooms/EMGenerateLightFunction.cs +++ b/TREnvironmentEditor/Model/Types/Rooms/EMGenerateLightFunction.cs @@ -20,7 +20,7 @@ public override void ApplyToLevel(TR1Level level) } Dictionary lightPositions = new(); - foreach (TR1RoomVertex vertex in room.RoomData.Vertices) + foreach (TR1RoomVertex vertex in room.Mesh.Vertices) { // Several lights per room - for now just use whichever is nearest this point Vector3 vertexPosition = new(vertex.Vertex.X, vertex.Vertex.Y, vertex.Vertex.Z); @@ -60,7 +60,7 @@ public override void ApplyToLevel(TR2Level level) } Dictionary lightPositions = new(); - foreach (TR2RoomVertex vertex in room.RoomData.Vertices) + foreach (TR2RoomVertex vertex in room.Mesh.Vertices) { // Several lights per room - for now just use whichever is nearest this point Vector3 vertexPosition = new(vertex.Vertex.X, vertex.Vertex.Y, vertex.Vertex.Z); @@ -101,7 +101,7 @@ public override void ApplyToLevel(TR3Level level) } Dictionary lightPositions = new(); - foreach (TR3RoomVertex vertex in room.RoomData.Vertices) + foreach (TR3RoomVertex vertex in room.Mesh.Vertices) { // Several lights per room - for now just use whichever is nearest this point Vector3 vertexPosition = new(vertex.Vertex.X, vertex.Vertex.Y, vertex.Vertex.Z); diff --git a/TREnvironmentEditor/Model/Types/Rooms/EMImportRoomFunction.cs b/TREnvironmentEditor/Model/Types/Rooms/EMImportRoomFunction.cs index ef1a76a47..0baff4c21 100644 --- a/TREnvironmentEditor/Model/Types/Rooms/EMImportRoomFunction.cs +++ b/TREnvironmentEditor/Model/Types/Rooms/EMImportRoomFunction.cs @@ -62,7 +62,7 @@ public override void ApplyToLevel(TR2Level level) NumXSectors = roomDef.Room.NumXSectors, NumZSectors = roomDef.Room.NumZSectors, Portals = new(), - RoomData = new() + Mesh = new() { Rectangles = new(), Triangles = new(), @@ -102,56 +102,56 @@ public override void ApplyToLevel(TR2Level level) } // Faces - for (int i = 0; i < roomDef.Room.RoomData.Rectangles.Count; i++) + for (int i = 0; i < roomDef.Room.Mesh.Rectangles.Count; i++) { - newRoom.RoomData.Rectangles.Add(new() + newRoom.Mesh.Rectangles.Add(new() { - Texture = RectangleTexture == ushort.MaxValue ? roomDef.Room.RoomData.Rectangles[i].Texture : RectangleTexture, - Vertices = new ushort[roomDef.Room.RoomData.Rectangles[i].Vertices.Length] + Texture = RectangleTexture == ushort.MaxValue ? roomDef.Room.Mesh.Rectangles[i].Texture : RectangleTexture, + Vertices = new ushort[roomDef.Room.Mesh.Rectangles[i].Vertices.Length] }); - for (int j = 0; j < newRoom.RoomData.Rectangles[i].Vertices.Length; j++) + for (int j = 0; j < newRoom.Mesh.Rectangles[i].Vertices.Length; j++) { - newRoom.RoomData.Rectangles[i].Vertices[j] = roomDef.Room.RoomData.Rectangles[i].Vertices[j]; + newRoom.Mesh.Rectangles[i].Vertices[j] = roomDef.Room.Mesh.Rectangles[i].Vertices[j]; } } - for (int i = 0; i < roomDef.Room.RoomData.Triangles.Count; i++) + for (int i = 0; i < roomDef.Room.Mesh.Triangles.Count; i++) { - newRoom.RoomData.Triangles.Add(new() + newRoom.Mesh.Triangles.Add(new() { - Texture = TriangleTexture == ushort.MaxValue ? roomDef.Room.RoomData.Triangles[i].Texture : TriangleTexture, - Vertices = new ushort[roomDef.Room.RoomData.Triangles[i].Vertices.Length] + Texture = TriangleTexture == ushort.MaxValue ? roomDef.Room.Mesh.Triangles[i].Texture : TriangleTexture, + Vertices = new ushort[roomDef.Room.Mesh.Triangles[i].Vertices.Length] }); - for (int j = 0; j < newRoom.RoomData.Triangles[i].Vertices.Length; j++) + for (int j = 0; j < newRoom.Mesh.Triangles[i].Vertices.Length; j++) { - newRoom.RoomData.Triangles[i].Vertices[j] = roomDef.Room.RoomData.Triangles[i].Vertices[j]; + newRoom.Mesh.Triangles[i].Vertices[j] = roomDef.Room.Mesh.Triangles[i].Vertices[j]; } } // Vertices - for (int i = 0; i < roomDef.Room.RoomData.Vertices.Count; i++) + for (int i = 0; i < roomDef.Room.Mesh.Vertices.Count; i++) { - newRoom.RoomData.Vertices.Add(new() + newRoom.Mesh.Vertices.Add(new() { - Attributes = roomDef.Room.RoomData.Vertices[i].Attributes, - Lighting = roomDef.Room.RoomData.Vertices[i].Lighting, - Lighting2 = roomDef.Room.RoomData.Vertices[i].Lighting2, + Attributes = roomDef.Room.Mesh.Vertices[i].Attributes, + Lighting = roomDef.Room.Mesh.Vertices[i].Lighting, + Lighting2 = roomDef.Room.Mesh.Vertices[i].Lighting2, Vertex = new() { - X = roomDef.Room.RoomData.Vertices[i].Vertex.X, // Room coords for X and Z - Y = (short)(roomDef.Room.RoomData.Vertices[i].Vertex.Y + ydiff), - Z = roomDef.Room.RoomData.Vertices[i].Vertex.Z + X = roomDef.Room.Mesh.Vertices[i].Vertex.X, // Room coords for X and Z + Y = (short)(roomDef.Room.Mesh.Vertices[i].Vertex.Y + ydiff), + Z = roomDef.Room.Mesh.Vertices[i].Vertex.Z } }); } // Sprites - for (int i = 0; i < roomDef.Room.RoomData.Sprites.Count; i++) + for (int i = 0; i < roomDef.Room.Mesh.Sprites.Count; i++) { - newRoom.RoomData.Sprites.Add(new() + newRoom.Mesh.Sprites.Add(new() { - Texture = roomDef.Room.RoomData.Sprites[i].Texture, - Vertex = roomDef.Room.RoomData.Sprites[i].Vertex + Texture = roomDef.Room.Mesh.Sprites[i].Texture, + Vertex = roomDef.Room.Mesh.Sprites[i].Vertex }); } @@ -327,7 +327,7 @@ public override void ApplyToLevel(TR3Level level) NumZSectors = roomDef.Room.NumZSectors, Portals = new(), ReverbInfo = roomDef.Room.ReverbInfo, - RoomData = new() + Mesh = new() { Rectangles = new(), Triangles = new(), @@ -354,56 +354,56 @@ public override void ApplyToLevel(TR3Level level) } // Faces - for (int i = 0; i < roomDef.Room.RoomData.Rectangles.Count; i++) + for (int i = 0; i < roomDef.Room.Mesh.Rectangles.Count; i++) { - newRoom.RoomData.Rectangles.Add(new() + newRoom.Mesh.Rectangles.Add(new() { - Texture = RectangleTexture == ushort.MaxValue ? roomDef.Room.RoomData.Rectangles[i].Texture : RectangleTexture, - Vertices = new ushort[roomDef.Room.RoomData.Rectangles[i].Vertices.Length] + Texture = RectangleTexture == ushort.MaxValue ? roomDef.Room.Mesh.Rectangles[i].Texture : RectangleTexture, + Vertices = new ushort[roomDef.Room.Mesh.Rectangles[i].Vertices.Length] }); - for (int j = 0; j < newRoom.RoomData.Rectangles[i].Vertices.Length; j++) + for (int j = 0; j < newRoom.Mesh.Rectangles[i].Vertices.Length; j++) { - newRoom.RoomData.Rectangles[i].Vertices[j] = roomDef.Room.RoomData.Rectangles[i].Vertices[j]; + newRoom.Mesh.Rectangles[i].Vertices[j] = roomDef.Room.Mesh.Rectangles[i].Vertices[j]; } } - for (int i = 0; i < roomDef.Room.RoomData.Triangles.Count; i++) + for (int i = 0; i < roomDef.Room.Mesh.Triangles.Count; i++) { - newRoom.RoomData.Triangles.Add(new() + newRoom.Mesh.Triangles.Add(new() { - Texture = TriangleTexture == ushort.MaxValue ? roomDef.Room.RoomData.Triangles[i].Texture : TriangleTexture, - Vertices = new ushort[roomDef.Room.RoomData.Triangles[i].Vertices.Length] + Texture = TriangleTexture == ushort.MaxValue ? roomDef.Room.Mesh.Triangles[i].Texture : TriangleTexture, + Vertices = new ushort[roomDef.Room.Mesh.Triangles[i].Vertices.Length] }); - for (int j = 0; j < newRoom.RoomData.Triangles[i].Vertices.Length; j++) + for (int j = 0; j < newRoom.Mesh.Triangles[i].Vertices.Length; j++) { - newRoom.RoomData.Triangles[i].Vertices[j] = roomDef.Room.RoomData.Triangles[i].Vertices[j]; + newRoom.Mesh.Triangles[i].Vertices[j] = roomDef.Room.Mesh.Triangles[i].Vertices[j]; } } // Vertices - for (int i = 0; i < roomDef.Room.RoomData.Vertices.Count; i++) + for (int i = 0; i < roomDef.Room.Mesh.Vertices.Count; i++) { - newRoom.RoomData.Vertices.Add(new() + newRoom.Mesh.Vertices.Add(new() { - Attributes = roomDef.Room.RoomData.Vertices[i].Attributes, - Colour = roomDef.Room.RoomData.Vertices[i].Colour, - Lighting = roomDef.Room.RoomData.Vertices[i].Lighting, + Attributes = roomDef.Room.Mesh.Vertices[i].Attributes, + Colour = roomDef.Room.Mesh.Vertices[i].Colour, + Lighting = roomDef.Room.Mesh.Vertices[i].Lighting, Vertex = new TRVertex { - X = roomDef.Room.RoomData.Vertices[i].Vertex.X, // Room coords for X and Z - Y = (short)(roomDef.Room.RoomData.Vertices[i].Vertex.Y + ydiff), - Z = roomDef.Room.RoomData.Vertices[i].Vertex.Z + X = roomDef.Room.Mesh.Vertices[i].Vertex.X, // Room coords for X and Z + Y = (short)(roomDef.Room.Mesh.Vertices[i].Vertex.Y + ydiff), + Z = roomDef.Room.Mesh.Vertices[i].Vertex.Z } }); } // Sprites - for (int i = 0; i < roomDef.Room.RoomData.Sprites.Count; i++) + for (int i = 0; i < roomDef.Room.Mesh.Sprites.Count; i++) { - newRoom.RoomData.Sprites.Add(new() + newRoom.Mesh.Sprites.Add(new() { - Texture = roomDef.Room.RoomData.Sprites[i].Texture, - Vertex = roomDef.Room.RoomData.Sprites[i].Vertex + Texture = roomDef.Room.Mesh.Sprites[i].Texture, + Vertex = roomDef.Room.Mesh.Sprites[i].Vertex }); } diff --git a/TREnvironmentEditor/Model/Types/Surfaces/BaseWaterFunction.cs b/TREnvironmentEditor/Model/Types/Surfaces/BaseWaterFunction.cs index 2d36a2b92..36d3b07ae 100644 --- a/TREnvironmentEditor/Model/Types/Surfaces/BaseWaterFunction.cs +++ b/TREnvironmentEditor/Model/Types/Surfaces/BaseWaterFunction.cs @@ -38,19 +38,19 @@ public void AddWaterSurface(TR1Room room, bool asCeiling, IEnumerable adjac for (int k = 0; k < defaultVerts.Count; k++) { TRVertex vert = defaultVerts[k]; - int vi = room.RoomData.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); + int vi = room.Mesh.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); if (vi == -1) { vi = CreateRoomVertex(room, vert); } else { - TR1RoomVertex exVert = room.RoomData.Vertices[vi]; + TR1RoomVertex exVert = room.Mesh.Vertices[vi]; } vertIndices.Add((ushort)vi); } - room.RoomData.Rectangles.Add(new() + room.Mesh.Rectangles.Add(new() { Texture = WaterTextures[0], Vertices = vertIndices.ToArray() @@ -87,20 +87,20 @@ public void AddWaterSurface(TR2Room room, bool asCeiling, IEnumerable adjac for (int k = 0; k < defaultVerts.Count; k++) { TRVertex vert = defaultVerts[k]; - int vi = room.RoomData.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); + int vi = room.Mesh.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); if (vi == -1) { vi = CreateRoomVertex(room, vert); } else { - TR2RoomVertex exVert = room.RoomData.Vertices[vi]; + TR2RoomVertex exVert = room.Mesh.Vertices[vi]; exVert.Attributes = 32784; // Stop the shimmering } vertIndices.Add((ushort)vi); } - room.RoomData.Rectangles.Add(new() + room.Mesh.Rectangles.Add(new() { Texture = WaterTextures[0], Vertices = vertIndices.ToArray() @@ -140,7 +140,7 @@ public void AddWaterSurface(TR3Room room, bool asCeiling, IEnumerable adjac for (int k = 0; k < defaultVerts.Count; k++) { TRVertex vert = defaultVerts[k]; - int vi = room.RoomData.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); + int vi = room.Mesh.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); if (vi == -1) { vi = CreateRoomVertex(room, vert, useCaustics:true, useWaveMovement:true); @@ -148,7 +148,7 @@ public void AddWaterSurface(TR3Room room, bool asCeiling, IEnumerable adjac vertIndices.Add((ushort)vi); } - room.RoomData.Rectangles.Add(new() + room.Mesh.Rectangles.Add(new() { Texture = (ushort)(WaterTextures[count++ % WaterTextures.Length] | 0x8000), // Cycle through the textures and make them double-sided Vertices = vertIndices.ToArray() @@ -159,17 +159,17 @@ public void AddWaterSurface(TR3Room room, bool asCeiling, IEnumerable adjac public void RemoveWaterSurface(TR1Room room) { - RemoveWaterSurfaces(room.RoomData.Rectangles); + RemoveWaterSurfaces(room.Mesh.Rectangles); } public void RemoveWaterSurface(TR2Room room) { - RemoveWaterSurfaces(room.RoomData.Rectangles); + RemoveWaterSurfaces(room.Mesh.Rectangles); } public void RemoveWaterSurface(TR3Room room) { - RemoveWaterSurfaces(room.RoomData.Rectangles); + RemoveWaterSurfaces(room.Mesh.Rectangles); } public void RemoveWaterSurfaces(List faces) diff --git a/TREnvironmentEditor/Model/Types/Surfaces/EMCeilingFunction.cs b/TREnvironmentEditor/Model/Types/Surfaces/EMCeilingFunction.cs index c90c790e3..7e3f9372e 100644 --- a/TREnvironmentEditor/Model/Types/Surfaces/EMCeilingFunction.cs +++ b/TREnvironmentEditor/Model/Types/Surfaces/EMCeilingFunction.cs @@ -29,7 +29,7 @@ public override void ApplyToLevel(TR1Level level) if (AmendVertices) { - foreach (TR1RoomVertex vertex in room.RoomData.Vertices) + foreach (TR1RoomVertex vertex in room.Mesh.Vertices) { if (vertex.Vertex.Y == oldYTop) { @@ -60,7 +60,7 @@ public override void ApplyToLevel(TR2Level level) if (AmendVertices) { - foreach (TR2RoomVertex vertex in room.RoomData.Vertices) + foreach (TR2RoomVertex vertex in room.Mesh.Vertices) { if (vertex.Vertex.Y == oldYTop) { @@ -91,7 +91,7 @@ public override void ApplyToLevel(TR3Level level) if (AmendVertices) { - foreach (TR3RoomVertex vertex in room.RoomData.Vertices) + foreach (TR3RoomVertex vertex in room.Mesh.Vertices) { if (vertex.Vertex.Y == oldYTop) { diff --git a/TREnvironmentEditor/Model/Types/Surfaces/EMDrainFunction.cs b/TREnvironmentEditor/Model/Types/Surfaces/EMDrainFunction.cs index da67fea7b..73b687da5 100644 --- a/TREnvironmentEditor/Model/Types/Surfaces/EMDrainFunction.cs +++ b/TREnvironmentEditor/Model/Types/Surfaces/EMDrainFunction.cs @@ -107,7 +107,7 @@ public override void ApplyToLevel(TR3Level level) room.ContainsWater = false; // Remove all wave movements and caustics by default - foreach (TR3RoomVertex vertex in room.RoomData.Vertices) + foreach (TR3RoomVertex vertex in room.Mesh.Vertices) { vertex.UseWaveMovement = vertex.UseCaustics = false; } diff --git a/TREnvironmentEditor/Model/Types/Surfaces/EMFloodFunction.cs b/TREnvironmentEditor/Model/Types/Surfaces/EMFloodFunction.cs index b104556d8..2d2922afd 100644 --- a/TREnvironmentEditor/Model/Types/Surfaces/EMFloodFunction.cs +++ b/TREnvironmentEditor/Model/Types/Surfaces/EMFloodFunction.cs @@ -98,7 +98,7 @@ public override void ApplyToLevel(TR3Level level) { TR3Room room = level.Rooms[data.ConvertRoom(roomNumber)]; room.ContainsWater = true; - foreach (TR3RoomVertex vertex in room.RoomData.Vertices) + foreach (TR3RoomVertex vertex in room.Mesh.Vertices) { vertex.UseCaustics = true; } diff --git a/TREnvironmentEditor/Model/Types/Surfaces/EMFloorFunction.cs b/TREnvironmentEditor/Model/Types/Surfaces/EMFloorFunction.cs index 19f7ba98f..bea3d9c35 100644 --- a/TREnvironmentEditor/Model/Types/Surfaces/EMFloorFunction.cs +++ b/TREnvironmentEditor/Model/Types/Surfaces/EMFloorFunction.cs @@ -74,7 +74,7 @@ private void MoveFloor(TR1Level level) for (int i = 0; i < defVerts.Count; i++) { TRVertex vert = defVerts[i]; - int vi = room.RoomData.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); + int vi = room.Mesh.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); if (vi != -1) { oldVertIndices.Add((ushort)vi); @@ -90,8 +90,8 @@ private void MoveFloor(TR1Level level) List newVertIndices = new(); foreach (ushort vert in oldVertIndices) { - TR1RoomVertex oldRoomVertex = room.RoomData.Vertices[vert]; - TRVertex oldVert = room.RoomData.Vertices[vert].Vertex; + TR1RoomVertex oldRoomVertex = room.Mesh.Vertices[vert]; + TRVertex oldVert = room.Mesh.Vertices[vert].Vertex; TRVertex newVertex = new() { X = oldVert.X, @@ -102,15 +102,15 @@ private void MoveFloor(TR1Level level) } // Get the tile face that matches the vertex list - TRFace4 floorFace = room.RoomData.Rectangles.Find(r => r.Vertices.ToList().All(oldVertIndices.Contains)); + TRFace4 floorFace = room.Mesh.Rectangles.Find(r => r.Vertices.ToList().All(oldVertIndices.Contains)); // If the floor has been lowered (remember +Clicks = move down, -Clicks = move up) // then the sides will also need lowering. if (Clicks > 0) { // Find faces that share 2 of the old vertices - int floorY = room.RoomData.Vertices[floorFace.Vertices[0]].Vertex.Y; - foreach (TRFace4 face in room.RoomData.Rectangles) + int floorY = room.Mesh.Vertices[floorFace.Vertices[0]].Vertex.Y; + foreach (TRFace4 face in room.Mesh.Rectangles) { if (face == floorFace) { @@ -125,10 +125,10 @@ private void MoveFloor(TR1Level level) foreach (ushort sharedVert in sharedVerts) { int i = faceVerts.IndexOf(sharedVert); - TRVertex oldVert = room.RoomData.Vertices[sharedVert].Vertex; + TRVertex oldVert = room.Mesh.Vertices[sharedVert].Vertex; foreach (ushort newVert in newVertIndices) { - TRVertex newVertex = room.RoomData.Vertices[newVert].Vertex; + TRVertex newVertex = room.Mesh.Vertices[newVert].Vertex; if (newVertex.X == oldVert.X && newVertex.Z == oldVert.Z) { faceVerts[i] = newVert; @@ -159,7 +159,7 @@ private void MoveFloor(TR1Level level) if (((1 << i) & Flags) > 0) { int j = i == 3 ? 0 : (i + 1); - room.RoomData.Rectangles.Add(new() + room.Mesh.Rectangles.Add(new() { Texture = SideTexture, Vertices = new ushort[] @@ -296,7 +296,7 @@ private void MoveFloor(TR2Level level) for (int i = 0; i < defVerts.Count; i++) { TRVertex vert = defVerts[i]; - int vi = room.RoomData.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); + int vi = room.Mesh.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); if (vi != -1) { oldVertIndices.Add((ushort)vi); @@ -312,8 +312,8 @@ private void MoveFloor(TR2Level level) List newVertIndices = new(); foreach (ushort vert in oldVertIndices) { - TR2RoomVertex oldRoomVertex = room.RoomData.Vertices[vert]; - TRVertex oldVert = room.RoomData.Vertices[vert].Vertex; + TR2RoomVertex oldRoomVertex = room.Mesh.Vertices[vert]; + TRVertex oldVert = room.Mesh.Vertices[vert].Vertex; TRVertex newVertex = new() { X = oldVert.X, @@ -324,15 +324,15 @@ private void MoveFloor(TR2Level level) } // Get the tile face that matches the vertex list - TRFace4 floorFace = room.RoomData.Rectangles.Find(r => r.Vertices.ToList().All(oldVertIndices.Contains)); + TRFace4 floorFace = room.Mesh.Rectangles.Find(r => r.Vertices.ToList().All(oldVertIndices.Contains)); // If the floor has been lowered (remember +Clicks = move down, -Clicks = move up) // then the sides will also need lowering. if (Clicks > 0) { // Find faces that share 2 of the old vertices - int floorY = room.RoomData.Vertices[floorFace.Vertices[0]].Vertex.Y; - foreach (TRFace4 face in room.RoomData.Rectangles) + int floorY = room.Mesh.Vertices[floorFace.Vertices[0]].Vertex.Y; + foreach (TRFace4 face in room.Mesh.Rectangles) { if (face == floorFace) { @@ -347,10 +347,10 @@ private void MoveFloor(TR2Level level) foreach (ushort sharedVert in sharedVerts) { int i = faceVerts.IndexOf(sharedVert); - TRVertex oldVert = room.RoomData.Vertices[sharedVert].Vertex; + TRVertex oldVert = room.Mesh.Vertices[sharedVert].Vertex; foreach (ushort newVert in newVertIndices) { - TRVertex newVertex = room.RoomData.Vertices[newVert].Vertex; + TRVertex newVertex = room.Mesh.Vertices[newVert].Vertex; if (newVertex.X == oldVert.X && newVertex.Z == oldVert.Z) { faceVerts[i] = newVert; @@ -381,7 +381,7 @@ private void MoveFloor(TR2Level level) if (((1 << i) & Flags) > 0) { int j = i == 3 ? 0 : (i + 1); - room.RoomData.Rectangles.Add(new() + room.Mesh.Rectangles.Add(new() { Texture = SideTexture, Vertices = new ushort[] @@ -537,7 +537,7 @@ private void MoveFloor(TR3Level level) for (int i = 0; i < defVerts.Count; i++) { TRVertex vert = defVerts[i]; - int vi = room.RoomData.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); + int vi = room.Mesh.Vertices.FindIndex(v => v.Vertex.X == vert.X && v.Vertex.Z == vert.Z && v.Vertex.Y == vert.Y); if (vi != -1) { oldVertIndices.Add((ushort)vi); @@ -549,8 +549,8 @@ private void MoveFloor(TR3Level level) List newVertIndices = new(); foreach (ushort vert in oldVertIndices) { - TR3RoomVertex oldRoomVertex = room.RoomData.Vertices[vert]; - TRVertex oldVert = room.RoomData.Vertices[vert].Vertex; + TR3RoomVertex oldRoomVertex = room.Mesh.Vertices[vert]; + TRVertex oldVert = room.Mesh.Vertices[vert].Vertex; TRVertex newVertex = new() { X = oldVert.X, @@ -561,15 +561,15 @@ private void MoveFloor(TR3Level level) } // Get the tile face that matches the vertex list - TRFace4 floorFace = room.RoomData.Rectangles.Find(r => r.Vertices.ToList().All(oldVertIndices.Contains)); + TRFace4 floorFace = room.Mesh.Rectangles.Find(r => r.Vertices.ToList().All(oldVertIndices.Contains)); // If the floor has been lowered (remember +Clicks = move down, -Clicks = move up) // then the sides will also need lowering. if (Clicks > 0) { // Find faces that share 2 of the old vertices - int floorY = room.RoomData.Vertices[floorFace.Vertices[0]].Vertex.Y; - foreach (TRFace4 face in room.RoomData.Rectangles) + int floorY = room.Mesh.Vertices[floorFace.Vertices[0]].Vertex.Y; + foreach (TRFace4 face in room.Mesh.Rectangles) { if (face == floorFace) { @@ -584,10 +584,10 @@ private void MoveFloor(TR3Level level) foreach (ushort sharedVert in sharedVerts) { int i = faceVerts.IndexOf(sharedVert); - TRVertex oldVert = room.RoomData.Vertices[sharedVert].Vertex; + TRVertex oldVert = room.Mesh.Vertices[sharedVert].Vertex; foreach (ushort newVert in newVertIndices) { - TRVertex newVertex = room.RoomData.Vertices[newVert].Vertex; + TRVertex newVertex = room.Mesh.Vertices[newVert].Vertex; if (newVertex.X == oldVert.X && newVertex.Z == oldVert.Z) { faceVerts[i] = newVert; @@ -618,7 +618,7 @@ private void MoveFloor(TR3Level level) if (((1 << i) & Flags) > 0) { int j = i == 3 ? 0 : (i + 1); - room.RoomData.Rectangles.Add(new() + room.Mesh.Rectangles.Add(new() { Texture = SideTexture, Vertices = new ushort[] diff --git a/TREnvironmentEditor/Model/Types/Textures/EMAddFaceFunction.cs b/TREnvironmentEditor/Model/Types/Textures/EMAddFaceFunction.cs index 6656c206e..ab342632f 100644 --- a/TREnvironmentEditor/Model/Types/Textures/EMAddFaceFunction.cs +++ b/TREnvironmentEditor/Model/Types/Textures/EMAddFaceFunction.cs @@ -17,7 +17,7 @@ public override void ApplyToLevel(TR1Level level) foreach (short roomIndex in Quads.Keys) { TR1Room room = level.Rooms[data.ConvertRoom(roomIndex)]; - room.RoomData.Rectangles.AddRange(Quads[roomIndex]); + room.Mesh.Rectangles.AddRange(Quads[roomIndex]); } } @@ -26,7 +26,7 @@ public override void ApplyToLevel(TR1Level level) foreach (short roomIndex in Triangles.Keys) { TR1Room room = level.Rooms[data.ConvertRoom(roomIndex)]; - room.RoomData.Triangles.AddRange(Triangles[roomIndex]); + room.Mesh.Triangles.AddRange(Triangles[roomIndex]); } } } @@ -40,7 +40,7 @@ public override void ApplyToLevel(TR2Level level) foreach (short roomIndex in Quads.Keys) { TR2Room room = level.Rooms[data.ConvertRoom(roomIndex)]; - room.RoomData.Rectangles.AddRange(Quads[roomIndex]); + room.Mesh.Rectangles.AddRange(Quads[roomIndex]); } } @@ -49,7 +49,7 @@ public override void ApplyToLevel(TR2Level level) foreach (short roomIndex in Triangles.Keys) { TR2Room room = level.Rooms[data.ConvertRoom(roomIndex)]; - room.RoomData.Triangles.AddRange(Triangles[roomIndex]); + room.Mesh.Triangles.AddRange(Triangles[roomIndex]); } } } @@ -63,7 +63,7 @@ public override void ApplyToLevel(TR3Level level) foreach (short roomIndex in Quads.Keys) { TR3Room room = level.Rooms[data.ConvertRoom(roomIndex)]; - room.RoomData.Rectangles.AddRange(Quads[roomIndex]); + room.Mesh.Rectangles.AddRange(Quads[roomIndex]); } } @@ -72,7 +72,7 @@ public override void ApplyToLevel(TR3Level level) foreach (short roomIndex in Triangles.Keys) { TR3Room room = level.Rooms[data.ConvertRoom(roomIndex)]; - room.RoomData.Triangles.AddRange(Triangles[roomIndex]); + room.Mesh.Triangles.AddRange(Triangles[roomIndex]); } } } diff --git a/TREnvironmentEditor/Model/Types/Textures/EMAddRoomSpriteFunction.cs b/TREnvironmentEditor/Model/Types/Textures/EMAddRoomSpriteFunction.cs index d18ccb317..941cef24a 100644 --- a/TREnvironmentEditor/Model/Types/Textures/EMAddRoomSpriteFunction.cs +++ b/TREnvironmentEditor/Model/Types/Textures/EMAddRoomSpriteFunction.cs @@ -15,12 +15,12 @@ public override void ApplyToLevel(TR1Level level) foreach (EMLocation location in Locations) { TR1Room room = level.Rooms[data.ConvertRoom(location.Room)]; - room.RoomData.Sprites.Add(new() + room.Mesh.Sprites.Add(new() { Texture = Texture, - Vertex = (short)room.RoomData.Vertices.Count + Vertex = (short)room.Mesh.Vertices.Count }); - room.RoomData.Vertices.Add(new() + room.Mesh.Vertices.Add(new() { Lighting = Vertex.Lighting, Vertex = new() @@ -39,12 +39,12 @@ public override void ApplyToLevel(TR2Level level) foreach (EMLocation location in Locations) { TR2Room room = level.Rooms[data.ConvertRoom(location.Room)]; - room.RoomData.Sprites.Add(new() + room.Mesh.Sprites.Add(new() { Texture = Texture, - Vertex = (short)room.RoomData.Vertices.Count + Vertex = (short)room.Mesh.Vertices.Count }); - room.RoomData.Vertices.Add(new() + room.Mesh.Vertices.Add(new() { Lighting = Vertex.Lighting, Lighting2 = Vertex.Lighting2, @@ -65,12 +65,12 @@ public override void ApplyToLevel(TR3Level level) foreach (EMLocation location in Locations) { TR3Room room = level.Rooms[data.ConvertRoom(location.Room)]; - room.RoomData.Sprites.Add(new() + room.Mesh.Sprites.Add(new() { Texture = Texture, - Vertex = (short)room.RoomData.Vertices.Count + Vertex = (short)room.Mesh.Vertices.Count }); - room.RoomData.Vertices.Add(new() + room.Mesh.Vertices.Add(new() { Lighting = Vertex.Lighting, Attributes = Vertex.Attributes, diff --git a/TREnvironmentEditor/Model/Types/Textures/EMModifyFaceFunction.cs b/TREnvironmentEditor/Model/Types/Textures/EMModifyFaceFunction.cs index 318882c24..71fa6c2b1 100644 --- a/TREnvironmentEditor/Model/Types/Textures/EMModifyFaceFunction.cs +++ b/TREnvironmentEditor/Model/Types/Textures/EMModifyFaceFunction.cs @@ -37,10 +37,10 @@ public override void ApplyToLevel(TR1Level level) switch (rot.FaceType) { case EMTextureFaceType.Rectangles: - RotateRectangles(room.RoomData.Rectangles, rot); + RotateRectangles(room.Mesh.Rectangles, rot); break; case EMTextureFaceType.Triangles: - RotateTriangles(room.RoomData.Triangles, rot); + RotateTriangles(room.Mesh.Triangles, rot); break; } } @@ -76,10 +76,10 @@ public override void ApplyToLevel(TR2Level level) switch (rot.FaceType) { case EMTextureFaceType.Rectangles: - RotateRectangles(room.RoomData.Rectangles, rot); + RotateRectangles(room.Mesh.Rectangles, rot); break; case EMTextureFaceType.Triangles: - RotateTriangles(room.RoomData.Triangles, rot); + RotateTriangles(room.Mesh.Triangles, rot); break; } } @@ -115,10 +115,10 @@ public override void ApplyToLevel(TR3Level level) switch (rot.FaceType) { case EMTextureFaceType.Rectangles: - RotateRectangles(room.RoomData.Rectangles, rot); + RotateRectangles(room.Mesh.Rectangles, rot); break; case EMTextureFaceType.Triangles: - RotateTriangles(room.RoomData.Triangles, rot); + RotateTriangles(room.Mesh.Triangles, rot); break; } } @@ -129,16 +129,16 @@ private static void ModifyRectangles(TR1Room room, EMFaceModification mod) { foreach (int faceIndex in mod.GetIndices()) { - TRFace4 rect = room.RoomData.Rectangles[faceIndex]; + TRFace4 rect = room.Mesh.Rectangles[faceIndex]; foreach (int vertIndex in mod.VertexChanges.Keys) { - TR1RoomVertex currentRoomVertex = room.RoomData.Vertices[rect.Vertices[vertIndex]]; + TR1RoomVertex currentRoomVertex = room.Mesh.Vertices[rect.Vertices[vertIndex]]; TRVertex newVertex = mod.VertexChanges[vertIndex]; TR1RoomVertex newRoomVertex = GenerateRoomVertex(currentRoomVertex, newVertex); // Remap the face to use this vertex - rect.Vertices[vertIndex] = (ushort)room.RoomData.Vertices.Count; - room.RoomData.Vertices.Add(newRoomVertex); + rect.Vertices[vertIndex] = (ushort)room.Mesh.Vertices.Count; + room.Mesh.Vertices.Add(newRoomVertex); } } } @@ -147,16 +147,16 @@ private static void ModifyRectangles(TR2Room room, EMFaceModification mod) { foreach (int faceIndex in mod.GetIndices()) { - TRFace4 rect = room.RoomData.Rectangles[faceIndex]; + TRFace4 rect = room.Mesh.Rectangles[faceIndex]; foreach (int vertIndex in mod.VertexChanges.Keys) { - TR2RoomVertex currentRoomVertex = room.RoomData.Vertices[rect.Vertices[vertIndex]]; + TR2RoomVertex currentRoomVertex = room.Mesh.Vertices[rect.Vertices[vertIndex]]; TRVertex newVertex = mod.VertexChanges[vertIndex]; TR2RoomVertex newRoomVertex = GenerateRoomVertex(currentRoomVertex, newVertex); // Remap the face to use this vertex - rect.Vertices[vertIndex] = (ushort)room.RoomData.Vertices.Count; - room.RoomData.Vertices.Add(newRoomVertex); + rect.Vertices[vertIndex] = (ushort)room.Mesh.Vertices.Count; + room.Mesh.Vertices.Add(newRoomVertex); } } } @@ -165,16 +165,16 @@ private static void ModifyRectangles(TR3Room room, EMFaceModification mod) { foreach (int faceIndex in mod.GetIndices()) { - TRFace4 rect = room.RoomData.Rectangles[faceIndex]; + TRFace4 rect = room.Mesh.Rectangles[faceIndex]; foreach (int vertIndex in mod.VertexChanges.Keys) { - TR3RoomVertex currentRoomVertex = room.RoomData.Vertices[rect.Vertices[vertIndex]]; + TR3RoomVertex currentRoomVertex = room.Mesh.Vertices[rect.Vertices[vertIndex]]; TRVertex newVertex = mod.VertexChanges[vertIndex]; TR3RoomVertex newRoomVertex = GenerateRoomVertex(currentRoomVertex, newVertex); // Remap the face to use this vertex - rect.Vertices[vertIndex] = (ushort)room.RoomData.Vertices.Count; - room.RoomData.Vertices.Add(newRoomVertex); + rect.Vertices[vertIndex] = (ushort)room.Mesh.Vertices.Count; + room.Mesh.Vertices.Add(newRoomVertex); } } } @@ -183,16 +183,16 @@ private static void ModifyTriangles(TR1Room room, EMFaceModification mod) { foreach (int faceIndex in mod.GetIndices()) { - TRFace3 tri = room.RoomData.Triangles[faceIndex]; + TRFace3 tri = room.Mesh.Triangles[faceIndex]; foreach (int vertIndex in mod.VertexChanges.Keys) { - TR1RoomVertex currentRoomVertex = room.RoomData.Vertices[tri.Vertices[vertIndex]]; + TR1RoomVertex currentRoomVertex = room.Mesh.Vertices[tri.Vertices[vertIndex]]; TRVertex newVertex = mod.VertexChanges[vertIndex]; TR1RoomVertex newRoomVertex = GenerateRoomVertex(currentRoomVertex, newVertex); // Remap the face to use this vertex - tri.Vertices[vertIndex] = (ushort)room.RoomData.Vertices.Count; - room.RoomData.Vertices.Add(newRoomVertex); + tri.Vertices[vertIndex] = (ushort)room.Mesh.Vertices.Count; + room.Mesh.Vertices.Add(newRoomVertex); } } } @@ -201,16 +201,16 @@ private static void ModifyTriangles(TR2Room room, EMFaceModification mod) { foreach (int faceIndex in mod.GetIndices()) { - TRFace3 tri = room.RoomData.Triangles[faceIndex]; + TRFace3 tri = room.Mesh.Triangles[faceIndex]; foreach (int vertIndex in mod.VertexChanges.Keys) { - TR2RoomVertex currentRoomVertex = room.RoomData.Vertices[tri.Vertices[vertIndex]]; + TR2RoomVertex currentRoomVertex = room.Mesh.Vertices[tri.Vertices[vertIndex]]; TRVertex newVertex = mod.VertexChanges[vertIndex]; TR2RoomVertex newRoomVertex = GenerateRoomVertex(currentRoomVertex, newVertex); // Remap the face to use this vertex - tri.Vertices[vertIndex] = (ushort)room.RoomData.Vertices.Count; - room.RoomData.Vertices.Add(newRoomVertex); + tri.Vertices[vertIndex] = (ushort)room.Mesh.Vertices.Count; + room.Mesh.Vertices.Add(newRoomVertex); } } } @@ -219,16 +219,16 @@ private static void ModifyTriangles(TR3Room room, EMFaceModification mod) { foreach (int faceIndex in mod.GetIndices()) { - TRFace3 tri = room.RoomData.Triangles[faceIndex]; + TRFace3 tri = room.Mesh.Triangles[faceIndex]; foreach (int vertIndex in mod.VertexChanges.Keys) { - TR3RoomVertex currentRoomVertex = room.RoomData.Vertices[tri.Vertices[vertIndex]]; + TR3RoomVertex currentRoomVertex = room.Mesh.Vertices[tri.Vertices[vertIndex]]; TRVertex newVertex = mod.VertexChanges[vertIndex]; TR3RoomVertex newRoomVertex = GenerateRoomVertex(currentRoomVertex, newVertex); // Remap the face to use this vertex - tri.Vertices[vertIndex] = (ushort)room.RoomData.Vertices.Count; - room.RoomData.Vertices.Add(newRoomVertex); + tri.Vertices[vertIndex] = (ushort)room.Mesh.Vertices.Count; + room.Mesh.Vertices.Add(newRoomVertex); } } } diff --git a/TREnvironmentEditor/Model/Types/Textures/EMRefaceFunction.cs b/TREnvironmentEditor/Model/Types/Textures/EMRefaceFunction.cs index 1aab80775..3eb6d4d75 100644 --- a/TREnvironmentEditor/Model/Types/Textures/EMRefaceFunction.cs +++ b/TREnvironmentEditor/Model/Types/Textures/EMRefaceFunction.cs @@ -31,7 +31,7 @@ public void ApplyTextures(TR1Level level) foreach (int roomIndex in TextureMap[texture].Keys) { TR1Room room = level.Rooms[data.ConvertRoom(roomIndex)]; - ApplyTextures(texture, TextureMap[texture][roomIndex], room.RoomData.Rectangles, room.RoomData.Triangles); + ApplyTextures(texture, TextureMap[texture][roomIndex], room.Mesh.Rectangles, room.Mesh.Triangles); } } } @@ -45,7 +45,7 @@ public void ApplyTextures(TR2Level level) foreach (int roomIndex in TextureMap[texture].Keys) { TR2Room room = level.Rooms[data.ConvertRoom(roomIndex)]; - ApplyTextures(texture, TextureMap[texture][roomIndex], room.RoomData.Rectangles, room.RoomData.Triangles); + ApplyTextures(texture, TextureMap[texture][roomIndex], room.Mesh.Rectangles, room.Mesh.Triangles); } } } @@ -59,7 +59,7 @@ public void ApplyTextures(TR3Level level) foreach (int roomIndex in TextureMap[texture].Keys) { TR3Room room = level.Rooms[data.ConvertRoom(roomIndex)]; - ApplyTextures(texture, TextureMap[texture][roomIndex], room.RoomData.Rectangles, room.RoomData.Triangles); + ApplyTextures(texture, TextureMap[texture][roomIndex], room.Mesh.Rectangles, room.Mesh.Triangles); } } } diff --git a/TREnvironmentEditor/Model/Types/Textures/EMRemoveFaceFunction.cs b/TREnvironmentEditor/Model/Types/Textures/EMRemoveFaceFunction.cs index 08f8a024f..6706e16e5 100644 --- a/TREnvironmentEditor/Model/Types/Textures/EMRemoveFaceFunction.cs +++ b/TREnvironmentEditor/Model/Types/Textures/EMRemoveFaceFunction.cs @@ -33,8 +33,8 @@ public override void ApplyToLevel(TR1Level level) } } - RemoveEntries(room.RoomData.Rectangles, rectangleRemovals); - RemoveEntries(room.RoomData.Triangles, triangleRemovals); + RemoveEntries(room.Mesh.Rectangles, rectangleRemovals); + RemoveEntries(room.Mesh.Triangles, triangleRemovals); } } @@ -64,8 +64,8 @@ public override void ApplyToLevel(TR2Level level) } } - RemoveEntries(room.RoomData.Rectangles, rectangleRemovals); - RemoveEntries(room.RoomData.Triangles, triangleRemovals); + RemoveEntries(room.Mesh.Rectangles, rectangleRemovals); + RemoveEntries(room.Mesh.Triangles, triangleRemovals); } } @@ -95,8 +95,8 @@ public override void ApplyToLevel(TR3Level level) } } - RemoveEntries(room.RoomData.Rectangles, rectangleRemovals); - RemoveEntries(room.RoomData.Triangles, triangleRemovals); + RemoveEntries(room.Mesh.Rectangles, rectangleRemovals); + RemoveEntries(room.Mesh.Triangles, triangleRemovals); } } diff --git a/TREnvironmentEditor/Model/Types/Textures/EMSwapFaceFunction.cs b/TREnvironmentEditor/Model/Types/Textures/EMSwapFaceFunction.cs index 8d2b15075..cdd48b1ff 100644 --- a/TREnvironmentEditor/Model/Types/Textures/EMSwapFaceFunction.cs +++ b/TREnvironmentEditor/Model/Types/Textures/EMSwapFaceFunction.cs @@ -19,8 +19,8 @@ public override void ApplyToLevel(TR1Level level) { int targetIndex = Swaps[originalIndex]; // Swap their positions in the list - (room.RoomData.Rectangles[targetIndex], room.RoomData.Rectangles[originalIndex]) - = (room.RoomData.Rectangles[originalIndex], room.RoomData.Rectangles[targetIndex]); + (room.Mesh.Rectangles[targetIndex], room.Mesh.Rectangles[originalIndex]) + = (room.Mesh.Rectangles[originalIndex], room.Mesh.Rectangles[targetIndex]); } } else @@ -29,8 +29,8 @@ public override void ApplyToLevel(TR1Level level) { int targetIndex = Swaps[originalIndex]; // Swap their positions in the list - (room.RoomData.Triangles[targetIndex], room.RoomData.Triangles[originalIndex]) - = (room.RoomData.Triangles[originalIndex], room.RoomData.Triangles[targetIndex]); + (room.Mesh.Triangles[targetIndex], room.Mesh.Triangles[originalIndex]) + = (room.Mesh.Triangles[originalIndex], room.Mesh.Triangles[targetIndex]); } } } @@ -45,8 +45,8 @@ public override void ApplyToLevel(TR2Level level) { int targetIndex = Swaps[originalIndex]; // Swap their positions in the list - (room.RoomData.Rectangles[targetIndex], room.RoomData.Rectangles[originalIndex]) - = (room.RoomData.Rectangles[originalIndex], room.RoomData.Rectangles[targetIndex]); + (room.Mesh.Rectangles[targetIndex], room.Mesh.Rectangles[originalIndex]) + = (room.Mesh.Rectangles[originalIndex], room.Mesh.Rectangles[targetIndex]); } } else @@ -55,8 +55,8 @@ public override void ApplyToLevel(TR2Level level) { int targetIndex = Swaps[originalIndex]; // Swap their positions in the list - (room.RoomData.Triangles[targetIndex], room.RoomData.Triangles[originalIndex]) - = (room.RoomData.Triangles[originalIndex], room.RoomData.Triangles[targetIndex]); + (room.Mesh.Triangles[targetIndex], room.Mesh.Triangles[originalIndex]) + = (room.Mesh.Triangles[originalIndex], room.Mesh.Triangles[targetIndex]); } } } @@ -71,8 +71,8 @@ public override void ApplyToLevel(TR3Level level) { int targetIndex = Swaps[originalIndex]; // Swap their positions in the list - (room.RoomData.Rectangles[targetIndex], room.RoomData.Rectangles[originalIndex]) - = (room.RoomData.Rectangles[originalIndex], room.RoomData.Rectangles[targetIndex]); + (room.Mesh.Rectangles[targetIndex], room.Mesh.Rectangles[originalIndex]) + = (room.Mesh.Rectangles[originalIndex], room.Mesh.Rectangles[targetIndex]); } } else @@ -81,8 +81,8 @@ public override void ApplyToLevel(TR3Level level) { int targetIndex = Swaps[originalIndex]; // Swap their positions in the list - (room.RoomData.Triangles[targetIndex], room.RoomData.Triangles[originalIndex]) - = (room.RoomData.Triangles[originalIndex], room.RoomData.Triangles[targetIndex]); + (room.Mesh.Triangles[targetIndex], room.Mesh.Triangles[originalIndex]) + = (room.Mesh.Triangles[originalIndex], room.Mesh.Triangles[targetIndex]); } } } diff --git a/TRLevelControl/Control/TR1LevelControl.cs b/TRLevelControl/Control/TR1LevelControl.cs index 4dd32f255..2ea7ae956 100644 --- a/TRLevelControl/Control/TR1LevelControl.cs +++ b/TRLevelControl/Control/TR1LevelControl.cs @@ -58,7 +58,7 @@ protected override void Read(TRLevelReader reader) _level.Rooms.Add(room); uint numWords = reader.ReadUInt32(); - room.RoomData = ConvertToRoomData(reader.ReadUInt16s(numWords)); + room.Mesh = ConvertToRoomData(reader.ReadUInt16s(numWords)); //Portals ushort numPortals = reader.ReadUInt16(); @@ -273,11 +273,11 @@ private void WriteSprites(TRLevelWriter writer) _spriteBuilder.WriteSprites(writer, _level.Sprites); } - private static TR1RoomData ConvertToRoomData(ushort[] rawData) + private static TR1RoomMesh ConvertToRoomData(ushort[] rawData) { // This approach is temporarily retained - TR1RoomData roomData = new() + TR1RoomMesh roomData = new() { Vertices = new() }; diff --git a/TRLevelControl/Control/TR2LevelControl.cs b/TRLevelControl/Control/TR2LevelControl.cs index bfee5a725..a933d3492 100644 --- a/TRLevelControl/Control/TR2LevelControl.cs +++ b/TRLevelControl/Control/TR2LevelControl.cs @@ -64,7 +64,7 @@ protected override void Read(TRLevelReader reader) _level.Rooms.Add(room); uint numWords = reader.ReadUInt32(); - room.RoomData = ConvertToRoomData(reader.ReadUInt16s(numWords)); + room.Mesh = ConvertToRoomData(reader.ReadUInt16s(numWords)); //Portals ushort numPortals = reader.ReadUInt16(); @@ -284,11 +284,11 @@ private void WriteSprites(TRLevelWriter writer) _spriteBuilder.WriteSprites(writer, _level.Sprites); } - private static TR2RoomData ConvertToRoomData(ushort[] rawData) + private static TR2RoomMesh ConvertToRoomData(ushort[] rawData) { // This approach is temporarily retained - TR2RoomData roomData = new() + TR2RoomMesh roomData = new() { Vertices = new() }; diff --git a/TRLevelControl/Control/TR3LevelControl.cs b/TRLevelControl/Control/TR3LevelControl.cs index fbe0350b0..f314fa938 100644 --- a/TRLevelControl/Control/TR3LevelControl.cs +++ b/TRLevelControl/Control/TR3LevelControl.cs @@ -64,7 +64,7 @@ protected override void Read(TRLevelReader reader) _level.Rooms.Add(room); uint numWords = reader.ReadUInt32(); - room.RoomData = TR3FileReadUtilities.ConvertToRoomData(reader.ReadUInt16s(numWords)); + room.Mesh = TR3FileReadUtilities.ConvertToRoomData(reader.ReadUInt16s(numWords)); //Portals ushort numPortals = reader.ReadUInt16(); diff --git a/TRLevelControl/Model/TR1/TR1Room.cs b/TRLevelControl/Model/TR1/TR1Room.cs index 0e69b2fba..069a71df2 100644 --- a/TRLevelControl/Model/TR1/TR1Room.cs +++ b/TRLevelControl/Model/TR1/TR1Room.cs @@ -5,7 +5,7 @@ namespace TRLevelControl.Model; public class TR1Room : ISerializableCompact { public TRRoomInfo Info { get; set; } - public TR1RoomData RoomData { get; set; } + public TR1RoomMesh Mesh { get; set; } public List Portals { get; set; } public ushort NumZSectors { get; set; } public ushort NumXSectors { get; set; } @@ -39,7 +39,7 @@ public byte[] Serialize() { writer.Write(Info.Serialize()); - byte[] meshData = RoomData.Serialize(); + byte[] meshData = Mesh.Serialize(); writer.Write((uint)meshData.Length / sizeof(short)); writer.Write(meshData); diff --git a/TRLevelControl/Model/TR1/TR1RoomData.cs b/TRLevelControl/Model/TR1/TR1RoomMesh.cs similarity index 96% rename from TRLevelControl/Model/TR1/TR1RoomData.cs rename to TRLevelControl/Model/TR1/TR1RoomMesh.cs index c0274f836..bc33bd668 100644 --- a/TRLevelControl/Model/TR1/TR1RoomData.cs +++ b/TRLevelControl/Model/TR1/TR1RoomMesh.cs @@ -2,7 +2,7 @@ namespace TRLevelControl.Model; -public class TR1RoomData : ISerializableCompact +public class TR1RoomMesh : ISerializableCompact { public List Vertices { get; set; } public List Rectangles { get; set; } diff --git a/TRLevelControl/Model/TR2/TR2Room.cs b/TRLevelControl/Model/TR2/TR2Room.cs index 9acce52a6..f77d9e00e 100644 --- a/TRLevelControl/Model/TR2/TR2Room.cs +++ b/TRLevelControl/Model/TR2/TR2Room.cs @@ -5,7 +5,7 @@ namespace TRLevelControl.Model; public class TR2Room : ISerializableCompact { public TRRoomInfo Info { get; set; } - public TR2RoomData RoomData { get; set; } + public TR2RoomMesh Mesh { get; set; } public List Portals { get; set; } public ushort NumZSectors { get; set; } public ushort NumXSectors { get; set; } @@ -73,7 +73,7 @@ public byte[] Serialize() { writer.Write(Info.Serialize()); - byte[] meshData = RoomData.Serialize(); + byte[] meshData = Mesh.Serialize(); writer.Write((uint)meshData.Length / sizeof(short)); writer.Write(meshData); diff --git a/TRLevelControl/Model/TR2/TR2RoomData.cs b/TRLevelControl/Model/TR2/TR2RoomMesh.cs similarity index 96% rename from TRLevelControl/Model/TR2/TR2RoomData.cs rename to TRLevelControl/Model/TR2/TR2RoomMesh.cs index 7acd5a51e..2fd2eae81 100644 --- a/TRLevelControl/Model/TR2/TR2RoomData.cs +++ b/TRLevelControl/Model/TR2/TR2RoomMesh.cs @@ -2,7 +2,7 @@ namespace TRLevelControl.Model; -public class TR2RoomData : ISerializableCompact +public class TR2RoomMesh : ISerializableCompact { public List Vertices { get; set; } public List Rectangles { get; set; } diff --git a/TRLevelControl/Model/TR3/TR3Room.cs b/TRLevelControl/Model/TR3/TR3Room.cs index 9589efdfe..6146a624c 100644 --- a/TRLevelControl/Model/TR3/TR3Room.cs +++ b/TRLevelControl/Model/TR3/TR3Room.cs @@ -5,7 +5,7 @@ namespace TRLevelControl.Model; public class TR3Room : ISerializableCompact { public TRRoomInfo Info { get; set; } - public TR3RoomData RoomData { get; set; } + public TR3RoomMesh Mesh { get; set; } public List Portals { get; set; } public ushort NumZSectors { get; set; } public ushort NumXSectors { get; set; } @@ -94,7 +94,7 @@ public byte[] Serialize() { writer.Write(Info.Serialize()); - byte[] meshData = RoomData.Serialize(); + byte[] meshData = Mesh.Serialize(); writer.Write((uint)meshData.Length / sizeof(short)); writer.Write(meshData); diff --git a/TRLevelControl/Model/TR3/TR3RoomData.cs b/TRLevelControl/Model/TR3/TR3RoomMesh.cs similarity index 96% rename from TRLevelControl/Model/TR3/TR3RoomData.cs rename to TRLevelControl/Model/TR3/TR3RoomMesh.cs index 4053ee6ee..a20e18fd4 100644 --- a/TRLevelControl/Model/TR3/TR3RoomData.cs +++ b/TRLevelControl/Model/TR3/TR3RoomMesh.cs @@ -2,7 +2,7 @@ namespace TRLevelControl.Model; -public class TR3RoomData : ISerializableCompact +public class TR3RoomMesh : ISerializableCompact { public List Vertices { get; set; } public List Rectangles { get; set; } diff --git a/TRLevelControl/Model/TR4/TR4Room.cs b/TRLevelControl/Model/TR4/TR4Room.cs index 337d794da..860eec6dd 100644 --- a/TRLevelControl/Model/TR4/TR4Room.cs +++ b/TRLevelControl/Model/TR4/TR4Room.cs @@ -5,7 +5,7 @@ namespace TRLevelControl.Model; public class TR4Room : ISerializableCompact { public TRRoomInfo Info { get; set; } - public TR3RoomData RoomData { get; set; } + public TR4RoomMesh Mesh { get; set; } public List Portals { get; set; } public ushort NumZSectors { get; set; } public ushort NumXSectors { get; set; } @@ -27,7 +27,7 @@ public byte[] Serialize() { writer.Write(Info.Serialize()); - byte[] meshData = RoomData.Serialize(); + byte[] meshData = Mesh.Serialize(); writer.Write((uint)meshData.Length / sizeof(short)); writer.Write(meshData); diff --git a/TRLevelControl/Model/TR4/TR4RoomMesh.cs b/TRLevelControl/Model/TR4/TR4RoomMesh.cs new file mode 100644 index 000000000..c5e1542cc --- /dev/null +++ b/TRLevelControl/Model/TR4/TR4RoomMesh.cs @@ -0,0 +1,45 @@ +using TRLevelControl.Serialization; + +namespace TRLevelControl.Model; + +public class TR4RoomMesh : ISerializableCompact +{ + public List Vertices { get; set; } + public List Rectangles { get; set; } + public List Triangles { get; set; } + public List Sprites { get; set; } + + public byte[] Serialize() + { + using MemoryStream stream = new(); + using (BinaryWriter writer = new(stream)) + { + writer.Write((short)Vertices.Count); + foreach (TR3RoomVertex vert in Vertices) + { + writer.Write(vert.Serialize()); + } + + writer.Write((short)Rectangles.Count); + foreach (TRFace4 face in Rectangles) + { + writer.Write(face.Serialize()); + } + + writer.Write((short)Triangles.Count); + foreach (TRFace3 face in Triangles) + { + writer.Write(face.Serialize()); + } + + writer.Write((short)Sprites.Count); + foreach (TRRoomSprite sprite in Sprites) + { + writer.Write(sprite.Serialize()); + } + } + + return stream.ToArray(); + } +} + diff --git a/TRLevelControl/TR3FileReadUtilities.cs b/TRLevelControl/TR3FileReadUtilities.cs index d9bd15e46..f5347fde5 100644 --- a/TRLevelControl/TR3FileReadUtilities.cs +++ b/TRLevelControl/TR3FileReadUtilities.cs @@ -5,11 +5,11 @@ namespace TRLevelControl; internal static class TR3FileReadUtilities { - public static TR3RoomData ConvertToRoomData(ushort[] rawData) + public static TR3RoomMesh ConvertToRoomData(ushort[] rawData) { // This approach is temporarily retained - TR3RoomData roomData = new() + TR3RoomMesh roomData = new() { Vertices = new() }; diff --git a/TRLevelControl/TR4FileReadUtilities.cs b/TRLevelControl/TR4FileReadUtilities.cs index 32e00f566..f96cedf06 100644 --- a/TRLevelControl/TR4FileReadUtilities.cs +++ b/TRLevelControl/TR4FileReadUtilities.cs @@ -29,7 +29,7 @@ public static void PopulateRooms(TRLevelReader reader, TR4Level lvl) lvl.Rooms.Add(room); uint numWords = reader.ReadUInt32(); - room.RoomData = TR3FileReadUtilities.ConvertToRoomData(reader.ReadUInt16s(numWords)); + room.Mesh = ConvertToRoomData(reader.ReadUInt16s(numWords)); //Portals ushort numPortals = reader.ReadUInt16(); @@ -74,6 +74,82 @@ public static void PopulateRooms(TRLevelReader reader, TR4Level lvl) } } + public static TR4RoomMesh ConvertToRoomData(ushort[] rawData) + { + // This approach is temporarily retained + + TR4RoomMesh roomData = new() + { + Vertices = new() + }; + + int offset = 0; + ushort count = rawData[offset++]; + for (int j = 0; j < count; j++) + { + roomData.Vertices.Add(new() + { + Vertex = new() + { + X = UnsafeConversions.UShortToShort(rawData[offset++]), + Y = UnsafeConversions.UShortToShort(rawData[offset++]), + Z = UnsafeConversions.UShortToShort(rawData[offset++]), + }, + Lighting = UnsafeConversions.UShortToShort(rawData[offset++]), + Attributes = rawData[offset++], + Colour = rawData[offset++], + }); + } + + count = rawData[offset++]; + roomData.Rectangles = new(); + for (int j = 0; j < count; j++) + { + roomData.Rectangles.Add(new() + { + Vertices = new ushort[] + { + rawData[offset++], + rawData[offset++], + rawData[offset++], + rawData[offset++], + }, + Texture = rawData[offset++], + }); + } + + count = rawData[offset++]; + roomData.Triangles = new(); + for (int j = 0; j < count; j++) + { + roomData.Triangles.Add(new() + { + Vertices = new ushort[] + { + rawData[offset++], + rawData[offset++], + rawData[offset++], + }, + Texture = rawData[offset++], + }); + } + + count = rawData[offset++]; + roomData.Sprites = new(); + for (int j = 0; j < count; j++) + { + roomData.Sprites.Add(new() + { + Vertex = UnsafeConversions.UShortToShort(rawData[offset++]), + Texture = UnsafeConversions.UShortToShort(rawData[offset++]), + }); + } + + Debug.Assert(offset == rawData.Length); + + return roomData; + } + public static void PopulateFloordata(BinaryReader reader, TR4Level lvl) { uint numFloorData = reader.ReadUInt32(); diff --git a/TRModelTransporter/Helpers/TRModelExtensions.cs b/TRModelTransporter/Helpers/TRModelExtensions.cs index 575ce13f7..5ecbede12 100644 --- a/TRModelTransporter/Helpers/TRModelExtensions.cs +++ b/TRModelTransporter/Helpers/TRModelExtensions.cs @@ -142,11 +142,11 @@ public static void ReindexTextures(this TR2Level level, Dictionary ind foreach (TR2Room room in level.Rooms) { - foreach (TRFace4 rect in room.RoomData.Rectangles) + foreach (TRFace4 rect in room.Mesh.Rectangles) { rect.Texture = ConvertTextureReference(rect.Texture, indexMap, defaultToOriginal); } - foreach (TRFace3 tri in room.RoomData.Triangles) + foreach (TRFace3 tri in room.Mesh.Triangles) { tri.Texture = ConvertTextureReference(tri.Texture, indexMap, defaultToOriginal); } @@ -200,11 +200,11 @@ public static void ReindexTextures(this TR3Level level, Dictionary ind foreach (TR3Room room in level.Rooms) { - foreach (TRFace4 rect in room.RoomData.Rectangles) + foreach (TRFace4 rect in room.Mesh.Rectangles) { rect.Texture = ConvertTextureReference(rect.Texture, indexMap, defaultToOriginal); } - foreach (TRFace3 tri in room.RoomData.Triangles) + foreach (TRFace3 tri in room.Mesh.Triangles) { tri.Texture = ConvertTextureReference(tri.Texture, indexMap, defaultToOriginal); } diff --git a/TRRandomizerCore/Randomizers/TR1/TR1NightModeRandomizer.cs b/TRRandomizerCore/Randomizers/TR1/TR1NightModeRandomizer.cs index 3e1390b55..654985d1f 100644 --- a/TRRandomizerCore/Randomizers/TR1/TR1NightModeRandomizer.cs +++ b/TRRandomizerCore/Randomizers/TR1/TR1NightModeRandomizer.cs @@ -89,7 +89,7 @@ private void DarkenRooms(TR1CombinedLevel level) room.AmbientIntensity = intensity1; room.Lights.ForEach(l => l.Intensity = intensity2); room.StaticMeshes.ForEach(s => s.Intensity = (ushort)intensity1); - room.RoomData.Vertices.ForEach(v => v.Lighting = intensity1); + room.Mesh.Vertices.ForEach(v => v.Lighting = intensity1); } } } diff --git a/TRRandomizerCore/Randomizers/TR2/TR2NightModeRandomizer.cs b/TRRandomizerCore/Randomizers/TR2/TR2NightModeRandomizer.cs index ba58ccdaa..6c8a46911 100644 --- a/TRRandomizerCore/Randomizers/TR2/TR2NightModeRandomizer.cs +++ b/TRRandomizerCore/Randomizers/TR2/TR2NightModeRandomizer.cs @@ -112,7 +112,7 @@ private static void SetStaticMeshLights(TR2Room room, ushort val) private static void SetVertexLight(TR2Room room, short val) { - foreach (TR2RoomVertex vert in room.RoomData.Vertices) + foreach (TR2RoomVertex vert in room.Mesh.Vertices) { vert.Lighting = val; vert.Lighting2 = val; diff --git a/TRRandomizerCore/Randomizers/TR3/TR3NightModeRandomizer.cs b/TRRandomizerCore/Randomizers/TR3/TR3NightModeRandomizer.cs index 348bfd6aa..3a027b887 100644 --- a/TRRandomizerCore/Randomizers/TR3/TR3NightModeRandomizer.cs +++ b/TRRandomizerCore/Randomizers/TR3/TR3NightModeRandomizer.cs @@ -76,7 +76,7 @@ private void DarkenRooms(TR3Level level) private static void SetVertexLight(TR3Room room, short val) { - foreach (TR3RoomVertex vert in room.RoomData.Vertices) + foreach (TR3RoomVertex vert in room.Mesh.Vertices) { vert.Lighting = val; diff --git a/TRRandomizerCore/Randomizers/TR3/TR3VfxRandomizer.cs b/TRRandomizerCore/Randomizers/TR3/TR3VfxRandomizer.cs index a386cdf0a..79b0805c6 100644 --- a/TRRandomizerCore/Randomizers/TR3/TR3VfxRandomizer.cs +++ b/TRRandomizerCore/Randomizers/TR3/TR3VfxRandomizer.cs @@ -103,7 +103,7 @@ private void FilterVerticesRandomRoom(TR3Level level) private static void SetColourFilter(TR3Room room, Color col, bool replace, bool enableCaustics, bool enableWave) { - foreach (TR3RoomVertex vert in room.RoomData.Vertices) + foreach (TR3RoomVertex vert in room.Mesh.Vertices) { byte curRed = (byte)((vert.Colour & 0x7C00) >> 10); byte curGreen = (byte)((vert.Colour & 0x03E0) >> 5); diff --git a/TRRandomizerCore/Resources/TR2/Rooms/XIAN.TR2-Rooms.json b/TRRandomizerCore/Resources/TR2/Rooms/XIAN.TR2-Rooms.json index 0d0a30257..ade05a11d 100644 --- a/TRRandomizerCore/Resources/TR2/Rooms/XIAN.TR2-Rooms.json +++ b/TRRandomizerCore/Resources/TR2/Rooms/XIAN.TR2-Rooms.json @@ -8,7 +8,7 @@ "YTop": -512 }, "NumDataWords": 11186, - "RoomData": { + "Mesh": { "NumVertices": 1022, "Vertices": [ { diff --git a/TRRandomizerCore/Textures/DynamicTextureBuilder.cs b/TRRandomizerCore/Textures/DynamicTextureBuilder.cs index 18d39d0d8..5e690c212 100644 --- a/TRRandomizerCore/Textures/DynamicTextureBuilder.cs +++ b/TRRandomizerCore/Textures/DynamicTextureBuilder.cs @@ -73,11 +73,11 @@ public DynamicTextureTarget Build(TR1CombinedLevel level) // Collect unique room and room sprite textures foreach (TR1Room room in level.Data.Rooms) { - foreach (TRFace3 f in room.RoomData.Triangles) + foreach (TRFace3 f in room.Mesh.Triangles) defaultObjectTextures.Add(f.Texture); - foreach (TRFace4 f in room.RoomData.Rectangles) + foreach (TRFace4 f in room.Mesh.Rectangles) defaultObjectTextures.Add(f.Texture); - foreach (TRRoomSprite sprite in room.RoomData.Sprites) + foreach (TRRoomSprite sprite in room.Mesh.Sprites) { // Temporary until room sprites store type IDs and not offsets TR1Type spriteID = default; diff --git a/TRRandomizerCore/Textures/Landmarks/TR1LandmarkImporter.cs b/TRRandomizerCore/Textures/Landmarks/TR1LandmarkImporter.cs index fd4e0232e..ba28eb51c 100644 --- a/TRRandomizerCore/Textures/Landmarks/TR1LandmarkImporter.cs +++ b/TRRandomizerCore/Textures/Landmarks/TR1LandmarkImporter.cs @@ -21,7 +21,7 @@ protected override List GetObjectTextures(TR1Level level) protected override void SetRoomTexture(TR1Level level, int roomIndex, int rectangleIndex, ushort textureIndex) { - level.Rooms[roomIndex].RoomData.Rectangles[rectangleIndex].Texture = textureIndex; + level.Rooms[roomIndex].Mesh.Rectangles[rectangleIndex].Texture = textureIndex; } protected override short? GetRoomFromPortal(TR1Level level, PortalSector portalSector, bool isLevelMirrored) diff --git a/TRRandomizerCore/Textures/Landmarks/TR2LandmarkImporter.cs b/TRRandomizerCore/Textures/Landmarks/TR2LandmarkImporter.cs index c28066a84..b7d4928bf 100644 --- a/TRRandomizerCore/Textures/Landmarks/TR2LandmarkImporter.cs +++ b/TRRandomizerCore/Textures/Landmarks/TR2LandmarkImporter.cs @@ -21,7 +21,7 @@ protected override List GetObjectTextures(TR2Level level) protected override void SetRoomTexture(TR2Level level, int roomIndex, int rectangleIndex, ushort textureIndex) { - level.Rooms[roomIndex].RoomData.Rectangles[rectangleIndex].Texture = textureIndex; + level.Rooms[roomIndex].Mesh.Rectangles[rectangleIndex].Texture = textureIndex; } protected override short? GetRoomFromPortal(TR2Level level, PortalSector portalSector, bool isLevelMirrored) diff --git a/TRRandomizerCore/Textures/Landmarks/TR3LandmarkImporter.cs b/TRRandomizerCore/Textures/Landmarks/TR3LandmarkImporter.cs index b62fc588e..4339670b2 100644 --- a/TRRandomizerCore/Textures/Landmarks/TR3LandmarkImporter.cs +++ b/TRRandomizerCore/Textures/Landmarks/TR3LandmarkImporter.cs @@ -21,7 +21,7 @@ protected override List GetObjectTextures(TR3Level level) protected override void SetRoomTexture(TR3Level level, int roomIndex, int rectangleIndex, ushort textureIndex) { - level.Rooms[roomIndex].RoomData.Rectangles[rectangleIndex].Texture = textureIndex; + level.Rooms[roomIndex].Mesh.Rectangles[rectangleIndex].Texture = textureIndex; } protected override short? GetRoomFromPortal(TR3Level level, PortalSector portalSector, bool isLevelMirrored) diff --git a/TRRandomizerCore/Textures/Wireframing/TR1Wireframer.cs b/TRRandomizerCore/Textures/Wireframing/TR1Wireframer.cs index 99abd4c49..9d59d3496 100644 --- a/TRRandomizerCore/Textures/Wireframing/TR1Wireframer.cs +++ b/TRRandomizerCore/Textures/Wireframing/TR1Wireframer.cs @@ -100,7 +100,7 @@ protected override IEnumerable> GetRoomFace3s(TR1Level leve List> faces = new(); foreach (TR1Room room in level.Rooms) { - faces.Add(room.RoomData.Triangles.ToList()); + faces.Add(room.Mesh.Triangles.ToList()); } return faces; } @@ -110,7 +110,7 @@ protected override IEnumerable> GetRoomFace4s(TR1Level leve List> faces = new(); foreach (TR1Room room in level.Rooms) { - faces.Add(room.RoomData.Rectangles.ToList()); + faces.Add(room.Mesh.Rectangles.ToList()); } return faces; } diff --git a/TRRandomizerCore/Textures/Wireframing/TR2Wireframer.cs b/TRRandomizerCore/Textures/Wireframing/TR2Wireframer.cs index 379402669..20596cc06 100644 --- a/TRRandomizerCore/Textures/Wireframing/TR2Wireframer.cs +++ b/TRRandomizerCore/Textures/Wireframing/TR2Wireframer.cs @@ -72,7 +72,7 @@ protected override IEnumerable> GetRoomFace3s(TR2Level leve List> faces = new(); foreach (TR2Room room in level.Rooms) { - faces.Add(room.RoomData.Triangles.ToList()); + faces.Add(room.Mesh.Triangles.ToList()); } return faces; } @@ -82,7 +82,7 @@ protected override IEnumerable> GetRoomFace4s(TR2Level leve List> faces = new(); foreach (TR2Room room in level.Rooms) { - faces.Add(room.RoomData.Rectangles.ToList()); + faces.Add(room.Mesh.Rectangles.ToList()); } return faces; } diff --git a/TRRandomizerCore/Textures/Wireframing/TR3Wireframer.cs b/TRRandomizerCore/Textures/Wireframing/TR3Wireframer.cs index 5f5614bbc..bb43d5d11 100644 --- a/TRRandomizerCore/Textures/Wireframing/TR3Wireframer.cs +++ b/TRRandomizerCore/Textures/Wireframing/TR3Wireframer.cs @@ -67,7 +67,7 @@ protected override IEnumerable> GetRoomFace3s(TR3Level leve List> faces = new(); foreach (TR3Room room in level.Rooms) { - faces.Add(room.RoomData.Triangles.ToList()); + faces.Add(room.Mesh.Triangles.ToList()); } return faces; } @@ -77,7 +77,7 @@ protected override IEnumerable> GetRoomFace4s(TR3Level leve List> faces = new(); foreach (TR3Room room in level.Rooms) { - faces.Add(room.RoomData.Rectangles.ToList()); + faces.Add(room.Mesh.Rectangles.ToList()); } return faces; } diff --git a/TRRandomizerCore/Utilities/FaceUtilities.cs b/TRRandomizerCore/Utilities/FaceUtilities.cs index 6844902f4..737ffd580 100644 --- a/TRRandomizerCore/Utilities/FaceUtilities.cs +++ b/TRRandomizerCore/Utilities/FaceUtilities.cs @@ -16,9 +16,9 @@ public static List GetTriggerFaces(TR1Level level, List tri List faces = new(); foreach (TR1Room room in level.Rooms) { - faces.AddRange(ScanTriggerFaces(floorData, triggerTypes, includeDeathTiles, room.Sectors, room.NumZSectors, room.RoomData.Rectangles, v => + faces.AddRange(ScanTriggerFaces(floorData, triggerTypes, includeDeathTiles, room.Sectors, room.NumZSectors, room.Mesh.Rectangles, v => { - return room.RoomData.Vertices[v].Vertex; + return room.Mesh.Vertices[v].Vertex; })); } @@ -33,9 +33,9 @@ public static List GetTriggerFaces(TR2Level level, List tri List faces = new(); foreach (TR2Room room in level.Rooms) { - faces.AddRange(ScanTriggerFaces(floorData, triggerTypes, includeDeathTiles, room.Sectors, room.NumZSectors, room.RoomData.Rectangles, v => + faces.AddRange(ScanTriggerFaces(floorData, triggerTypes, includeDeathTiles, room.Sectors, room.NumZSectors, room.Mesh.Rectangles, v => { - return room.RoomData.Vertices[v].Vertex; + return room.Mesh.Vertices[v].Vertex; })); } @@ -50,9 +50,9 @@ public static List GetTriggerFaces(TR3Level level, List tri List faces = new(); foreach (TR3Room room in level.Rooms) { - faces.AddRange(ScanTriggerFaces(floorData, triggerTypes, includeDeathTiles, room.Sectors, room.NumZSectors, room.RoomData.Rectangles, v => + faces.AddRange(ScanTriggerFaces(floorData, triggerTypes, includeDeathTiles, room.Sectors, room.NumZSectors, room.Mesh.Rectangles, v => { - return room.RoomData.Vertices[v].Vertex; + return room.Mesh.Vertices[v].Vertex; })); } @@ -152,7 +152,7 @@ private static void ScanTR2SectorLadderFaces(Dictionary> List vertMatches = GetVerticesToMatch(climbEntry, x, z); - foreach (TRFace4 face in room.RoomData.Rectangles) + foreach (TRFace4 face in room.Mesh.Rectangles) { if (faces.ContainsKey(face)) { @@ -162,7 +162,7 @@ private static void ScanTR2SectorLadderFaces(Dictionary> List faceVertices = new(); foreach (ushort v in face.Vertices) { - faceVertices.Add(room.RoomData.Vertices[v].Vertex); + faceVertices.Add(room.Mesh.Vertices[v].Vertex); } if (IsWallMatch(vertMatches, faceVertices)) @@ -203,7 +203,7 @@ private static void ScanTR3SectorLadderFaces(Dictionary> List vertMatches = GetVerticesToMatch(climbEntry, x, z); - foreach (TRFace4 face in room.RoomData.Rectangles) + foreach (TRFace4 face in room.Mesh.Rectangles) { if (faces.ContainsKey(face)) { @@ -213,7 +213,7 @@ private static void ScanTR3SectorLadderFaces(Dictionary> List faceVertices = new(); foreach (ushort v in face.Vertices) { - faceVertices.Add(room.RoomData.Vertices[v].Vertex); + faceVertices.Add(room.Mesh.Vertices[v].Vertex); } if (IsWallMatch(vertMatches, faceVertices)) @@ -255,7 +255,7 @@ private static void ScanTR3SectorMonkeyFaces(Dictionary> List vertMatches = GetFloorOrCeilingVerticesToMatch(x, z); - foreach (TRFace4 face in room.RoomData.Rectangles) + foreach (TRFace4 face in room.Mesh.Rectangles) { if (faces.ContainsKey(face)) { @@ -265,7 +265,7 @@ private static void ScanTR3SectorMonkeyFaces(Dictionary> List faceVertices = new(); foreach (ushort v in face.Vertices) { - faceVertices.Add(room.RoomData.Vertices[v].Vertex); + faceVertices.Add(room.Mesh.Vertices[v].Vertex); } if (IsCeilingMatch(vertMatches, faceVertices, y)) diff --git a/TextureExport/Types/FaceMapper.cs b/TextureExport/Types/FaceMapper.cs index e9fcd7366..5e77aa87e 100644 --- a/TextureExport/Types/FaceMapper.cs +++ b/TextureExport/Types/FaceMapper.cs @@ -31,13 +31,13 @@ public static void DrawFaces(TR1Level level, string lvl, int[] roomNumbers) newRectFaces[roomNumber] = new Dictionary(); newTriFaces[roomNumber] = new Dictionary(); - for (int i = 0; i < level.Rooms[roomNumber].RoomData.Rectangles.Count; i++) + for (int i = 0; i < level.Rooms[roomNumber].Mesh.Rectangles.Count; i++) { - rectFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].RoomData.Rectangles[i].Texture, packer.Tiles); + rectFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].Mesh.Rectangles[i].Texture, packer.Tiles); } - for (int i = 0; i < level.Rooms[roomNumber].RoomData.Triangles.Count; i++) + for (int i = 0; i < level.Rooms[roomNumber].Mesh.Triangles.Count; i++) { - triFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].RoomData.Triangles[i].Texture, packer.Tiles); + triFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].Mesh.Triangles[i].Texture, packer.Tiles); } foreach (int rectIndex in rectFaces[roomNumber].Keys) @@ -73,11 +73,11 @@ public static void DrawFaces(TR1Level level, string lvl, int[] roomNumbers) { foreach (int rectIndex in newRectFaces[roomNumber].Keys) { - level.Rooms[roomNumber].RoomData.Rectangles[rectIndex].Texture = (ushort)newRectFaces[roomNumber][rectIndex]; + level.Rooms[roomNumber].Mesh.Rectangles[rectIndex].Texture = (ushort)newRectFaces[roomNumber][rectIndex]; } foreach (int triIndex in newTriFaces[roomNumber].Keys) { - level.Rooms[roomNumber].RoomData.Triangles[triIndex].Texture = (ushort)newTriFaces[roomNumber][triIndex]; + level.Rooms[roomNumber].Mesh.Triangles[triIndex].Texture = (ushort)newTriFaces[roomNumber][triIndex]; } } @@ -103,13 +103,13 @@ public static void DrawFaces(TR2Level level, string lvl, int[] roomNumbers) newRectFaces[roomNumber] = new Dictionary(); newTriFaces[roomNumber] = new Dictionary(); - for (int i = 0; i < level.Rooms[roomNumber].RoomData.Rectangles.Count; i++) + for (int i = 0; i < level.Rooms[roomNumber].Mesh.Rectangles.Count; i++) { - rectFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].RoomData.Rectangles[i].Texture, packer.Tiles); + rectFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].Mesh.Rectangles[i].Texture, packer.Tiles); } - for (int i = 0; i < level.Rooms[roomNumber].RoomData.Triangles.Count; i++) + for (int i = 0; i < level.Rooms[roomNumber].Mesh.Triangles.Count; i++) { - triFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].RoomData.Triangles[i].Texture, packer.Tiles); + triFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].Mesh.Triangles[i].Texture, packer.Tiles); } foreach (int rectIndex in rectFaces[roomNumber].Keys) @@ -145,11 +145,11 @@ public static void DrawFaces(TR2Level level, string lvl, int[] roomNumbers) { foreach (int rectIndex in newRectFaces[roomNumber].Keys) { - level.Rooms[roomNumber].RoomData.Rectangles[rectIndex].Texture = (ushort)newRectFaces[roomNumber][rectIndex]; + level.Rooms[roomNumber].Mesh.Rectangles[rectIndex].Texture = (ushort)newRectFaces[roomNumber][rectIndex]; } foreach (int triIndex in newTriFaces[roomNumber].Keys) { - level.Rooms[roomNumber].RoomData.Triangles[triIndex].Texture = (ushort)newTriFaces[roomNumber][triIndex]; + level.Rooms[roomNumber].Mesh.Triangles[triIndex].Texture = (ushort)newTriFaces[roomNumber][triIndex]; } } @@ -175,13 +175,13 @@ public static void DrawFaces(TR3Level level, string lvl, int[] roomNumbers) newRectFaces[roomNumber] = new Dictionary(); newTriFaces[roomNumber] = new Dictionary(); - for (int i = 0; i < level.Rooms[roomNumber].RoomData.Rectangles.Count; i++) + for (int i = 0; i < level.Rooms[roomNumber].Mesh.Rectangles.Count; i++) { - rectFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].RoomData.Rectangles[i].Texture, packer.Tiles); + rectFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].Mesh.Rectangles[i].Texture, packer.Tiles); } - for (int i = 0; i < level.Rooms[roomNumber].RoomData.Triangles.Count; i++) + for (int i = 0; i < level.Rooms[roomNumber].Mesh.Triangles.Count; i++) { - triFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].RoomData.Triangles[i].Texture, packer.Tiles); + triFaces[roomNumber][i] = GetFaceSegment(level.Rooms[roomNumber].Mesh.Triangles[i].Texture, packer.Tiles); } foreach (int rectIndex in rectFaces[roomNumber].Keys) @@ -217,11 +217,11 @@ public static void DrawFaces(TR3Level level, string lvl, int[] roomNumbers) { foreach (int rectIndex in newRectFaces[roomNumber].Keys) { - level.Rooms[roomNumber].RoomData.Rectangles[rectIndex].Texture = (ushort)newRectFaces[roomNumber][rectIndex]; + level.Rooms[roomNumber].Mesh.Rectangles[rectIndex].Texture = (ushort)newRectFaces[roomNumber][rectIndex]; } foreach (int triIndex in newTriFaces[roomNumber].Keys) { - level.Rooms[roomNumber].RoomData.Triangles[triIndex].Texture = (ushort)newTriFaces[roomNumber][triIndex]; + level.Rooms[roomNumber].Mesh.Triangles[triIndex].Texture = (ushort)newTriFaces[roomNumber][triIndex]; } } @@ -245,7 +245,7 @@ public static void DrawBoxes(TR2Level level, string lvl, int[] roomNumbers) rectFaces[roomNumber] = new Dictionary(); newRectFaces[roomNumber] = new Dictionary(); - for (int i = 0; i < level.Rooms[roomNumber].RoomData.Rectangles.Count; i++) + for (int i = 0; i < level.Rooms[roomNumber].Mesh.Rectangles.Count; i++) { TexturedTileSegment seg = GetBoxFaceSegment(level.Rooms[roomNumber], i, packer.Tiles); if (seg != null) @@ -271,7 +271,7 @@ public static void DrawBoxes(TR2Level level, string lvl, int[] roomNumbers) { foreach (int rectIndex in newRectFaces[roomNumber].Keys) { - level.Rooms[roomNumber].RoomData.Rectangles[rectIndex].Texture = (ushort)newRectFaces[roomNumber][rectIndex]; + level.Rooms[roomNumber].Mesh.Rectangles[rectIndex].Texture = (ushort)newRectFaces[roomNumber][rectIndex]; } } @@ -356,14 +356,14 @@ private static TRObjectTextureVert CreatePoint(int x, int y) private static TexturedTileSegment GetBoxFaceSegment(TR2Room room, int rectIndex, IReadOnlyList tiles) { - TRFace4 face = room.RoomData.Rectangles[rectIndex]; + TRFace4 face = room.Mesh.Rectangles[rectIndex]; List verts = new() { - room.RoomData.Vertices[face.Vertices[0]].Vertex, - room.RoomData.Vertices[face.Vertices[1]].Vertex, - room.RoomData.Vertices[face.Vertices[2]].Vertex, - room.RoomData.Vertices[face.Vertices[3]].Vertex + room.Mesh.Vertices[face.Vertices[0]].Vertex, + room.Mesh.Vertices[face.Vertices[1]].Vertex, + room.Mesh.Vertices[face.Vertices[2]].Vertex, + room.Mesh.Vertices[face.Vertices[3]].Vertex }; // Ignore walls @@ -387,13 +387,13 @@ private static TexturedTileSegment GetBoxFaceSegment(TR2Room room, int rectIndex private static string GetBoxDescription(TR2Level level, FDControl control, int roomNumber, int rectIndex) { TR2Room room = level.Rooms[roomNumber]; - TRFace4 face = room.RoomData.Rectangles[rectIndex]; + TRFace4 face = room.Mesh.Rectangles[rectIndex]; List verts = new() { - room.RoomData.Vertices[face.Vertices[0]].Vertex, - room.RoomData.Vertices[face.Vertices[1]].Vertex, - room.RoomData.Vertices[face.Vertices[2]].Vertex, - room.RoomData.Vertices[face.Vertices[3]].Vertex + room.Mesh.Vertices[face.Vertices[0]].Vertex, + room.Mesh.Vertices[face.Vertices[1]].Vertex, + room.Mesh.Vertices[face.Vertices[2]].Vertex, + room.Mesh.Vertices[face.Vertices[3]].Vertex }; int xmin = verts.Min(v => v.X) + room.Info.X;