private static void Serialize(this SerializingContainer2 sc, LightMap_1D lmap) { sc.Serialize(ref lmap.LightGuids, Serialize); sc.Serialize(ref lmap.Owner); sc.SerializeBulkData(ref lmap.DirectionalSamples, Serialize); sc.Serialize(ref lmap.ScaleVector1); sc.Serialize(ref lmap.ScaleVector2); sc.Serialize(ref lmap.ScaleVector3); if (sc.Game != MEGame.ME3) { sc.Serialize(ref lmap.ScaleVector4); } sc.SerializeBulkData(ref lmap.SimpleSamples, Serialize); }
private static void Serialize(this SerializingContainer2 sc, LightMap_5 lmap) { sc.Serialize(ref lmap.LightGuids, Serialize); sc.Serialize(ref lmap.unkInt); sc.SerializeBulkData(ref lmap.SimpleSamples, Serialize); sc.Serialize(ref lmap.unkVector); }
private static void Serialize(this SerializingContainer2 sc, LightMap_3 lmap) { sc.Serialize(ref lmap.LightGuids, Serialize); sc.Serialize(ref lmap.unkInt); sc.SerializeBulkData(ref lmap.DirectionalSamples, Serialize); sc.Serialize(ref lmap.unkVector1); sc.Serialize(ref lmap.unkVector2); }
public static void Serialize(this SerializingContainer2 sc, ref StaticMeshRenderData data) { if (sc.IsLoading) { data = new StaticMeshRenderData(); } sc.SerializeBulkData(ref data.RawTriangles, Serialize); sc.Serialize(ref data.Elements, Serialize); sc.Serialize(ref data.PositionVertexBuffer); if (sc.IsSaving) { if (sc.Game >= MEGame.ME3 && data.ColorVertexBuffer == null) { //this was read in from ME1 or ME2, we need to seperate out the color data data.ColorVertexBuffer = new ColorVertexBuffer { VertexData = data.VertexBuffer.VertexData.Select(vertex => vertex.Color).ToArray(), NumVertices = (uint)data.VertexBuffer.VertexData.Length, Stride = 4 }; } else if (sc.Game < MEGame.ME3 && data.ColorVertexBuffer != null) { //this was read in from ME3 or UDK, we need to integrate the color data for (int i = data.VertexBuffer.VertexData.Length - 1; i >= 0; i--) { data.VertexBuffer.VertexData[i].Color = data.ColorVertexBuffer.VertexData[i]; } } } sc.Serialize(ref data.VertexBuffer); if (sc.Game >= MEGame.ME3) { sc.Serialize(ref data.ColorVertexBuffer); } if (sc.Game < MEGame.UDK) { sc.Serialize(ref data.ShadowExtrusionVertexBuffer); } else if (sc.IsLoading) { data.ShadowExtrusionVertexBuffer = new ExtrusionVertexBuffer { Stride = 4, VertexData = Array.Empty <float>() }; } sc.Serialize(ref data.NumVertices); int elementSize = 2; sc.Serialize(ref elementSize); sc.Serialize(ref data.IndexBuffer, Serialize); elementSize = 2; sc.Serialize(ref elementSize); sc.Serialize(ref data.WireframeIndexBuffer, Serialize); if (sc.Game != MEGame.UDK) { elementSize = 16; sc.Serialize(ref elementSize); sc.Serialize(ref data.Edges, Serialize); sc.Serialize(ref data.ShadowTriangleDoubleSided, Serialize); } else if (sc.IsLoading) { data.Edges = Array.Empty <MeshEdge>(); data.ShadowTriangleDoubleSided = Array.Empty <byte>(); } if (sc.Game == MEGame.UDK) { sc.BulkSerialize(ref data.unkBuffer, Serialize, 2); } if (sc.Game == MEGame.ME1) { sc.Serialize(ref data.unk1); int bulkDataFlags = 0; sc.Serialize(ref bulkDataFlags); int byteCount = data.xmlFile?.Length ?? 0; sc.Serialize(ref byteCount); sc.Serialize(ref byteCount); int xmlOffsetInFile = sc.FileOffset + 4; sc.Serialize(ref xmlOffsetInFile); sc.Serialize(ref data.xmlFile, byteCount); } else if (sc.IsLoading) { data.xmlFile = Array.Empty <byte>(); } }
public static void Serialize(this SerializingContainer2 sc, ref StaticLODModel slm) { if (sc.IsLoading) { slm = new StaticLODModel(); } sc.Serialize(ref slm.Sections, Serialize); if (sc.Game == MEGame.UDK) { sc.Serialize(ref slm.NeedsCPUAccess); sc.Serialize(ref slm.DataTypeSize); } int ushortSize = 2; sc.Serialize(ref ushortSize); sc.Serialize(ref slm.IndexBuffer, Serialize); if (sc.Game != MEGame.UDK) { sc.Serialize(ref slm.ShadowIndices, Serialize); } sc.Serialize(ref slm.ActiveBoneIndices, Serialize); if (sc.Game != MEGame.UDK) { sc.Serialize(ref slm.ShadowTriangleDoubleSided, Serialize); } sc.Serialize(ref slm.Chunks, Serialize); sc.Serialize(ref slm.Size); sc.Serialize(ref slm.NumVertices); if (sc.Game != MEGame.UDK) { sc.Serialize(ref slm.Edges, Serialize); } sc.Serialize(ref slm.RequiredBones, Serialize); if (sc.Game == MEGame.UDK) { int[] UDKRawPointIndices = sc.IsSaving ? Array.ConvertAll(slm.RawPointIndices, u => (int)u) : Array.Empty <int>(); sc.SerializeBulkData(ref UDKRawPointIndices, Serialize); slm.RawPointIndices = Array.ConvertAll(UDKRawPointIndices, i => (ushort)i); } else { sc.SerializeBulkData(ref slm.RawPointIndices, Serialize); } if (sc.Game == MEGame.UDK) { sc.Serialize(ref slm.NumTexCoords); } if (sc.Game == MEGame.ME1) { if (sc.IsSaving && slm.ME1VertexBufferGPUSkin == null) { GPUSkinVertex[] vertexData = slm.VertexBufferGPUSkin.VertexData; slm.ME1VertexBufferGPUSkin = new SoftSkinVertex[vertexData.Length]; for (int i = 0; i < vertexData.Length; i++) { GPUSkinVertex vert = vertexData[i]; slm.ME1VertexBufferGPUSkin[i] = new SoftSkinVertex { Position = vert.Position, TangentX = vert.TangentX, TangentY = new PackedNormal(0, 1, 0, 0), //¯\_(ツ)_/¯ TangentZ = vert.TangentZ, UV = new Vector2D(vert.UV.X, vert.UV.Y), InfluenceBones = vert.InfluenceBones.TypedClone(), InfluenceWeights = vert.InfluenceWeights.TypedClone() }; } } int softSkinVertexSize = 40; sc.Serialize(ref softSkinVertexSize); sc.Serialize(ref slm.ME1VertexBufferGPUSkin, Serialize); } else { if (sc.IsSaving && slm.VertexBufferGPUSkin == null) { slm.VertexBufferGPUSkin = new SkeletalMeshVertexBuffer { MeshExtension = new Vector3(1, 1, 1), NumTexCoords = 1, VertexData = new GPUSkinVertex[slm.ME1VertexBufferGPUSkin.Length] }; for (int i = 0; i < slm.ME1VertexBufferGPUSkin.Length; i++) { SoftSkinVertex vert = slm.ME1VertexBufferGPUSkin[i]; slm.VertexBufferGPUSkin.VertexData[i] = new GPUSkinVertex { Position = vert.Position, TangentX = vert.TangentX, TangentZ = vert.TangentZ, UV = new Vector2DHalf(vert.UV.X, vert.UV.Y), InfluenceBones = vert.InfluenceBones.TypedClone(), InfluenceWeights = vert.InfluenceWeights.TypedClone() }; } } sc.Serialize(ref slm.VertexBufferGPUSkin); } if (sc.Game >= MEGame.ME3) { int vertexInfluencesCount = 0; sc.Serialize(ref vertexInfluencesCount); if (vertexInfluencesCount != 0) { throw new Exception($"VertexInfluences exist on this SkeletalMesh! Mesh in: {sc.Pcc.FilePath}"); } } if (sc.Game == MEGame.UDK) { sc.Serialize(ref slm.NeedsCPUAccess); sc.Serialize(ref slm.DataTypeSize); int elementSize = 2; sc.Serialize(ref elementSize); ushort[] secondIndexBuffer = new ushort[0]; sc.Serialize(ref secondIndexBuffer, Serialize); } }