Example #1
0
        public static void Serialize(this SerializingContainer2 sc, ref PSA.PSABone b)
        {
            if (sc.IsLoading)
            {
                b = new PSA.PSABone();
            }

            sc.SerializeFixedSizeString(ref b.Name, 64);
            sc.Serialize(ref b.Flags);
            sc.Serialize(ref b.NumChildren);
            sc.Serialize(ref b.ParentIndex);
            sc.Serialize(ref b.Rotation);
            sc.Serialize(ref b.Position);
            sc.Serialize(ref b.Length);
            sc.Serialize(ref b.Size);
        }
Example #2
0
        public LightmassPrimitiveSettings[] LightmassSettings; //ME3

        protected override void Serialize(SerializingContainer2 sc)
        {
            sc.Serialize(ref Bounds);
            sc.BulkSerialize(ref Vectors, SCExt.Serialize, 12);
            sc.BulkSerialize(ref Points, SCExt.Serialize, 12);
            sc.BulkSerialize(ref Nodes, SCExt.Serialize, 64);
            sc.Serialize(ref Self);
            sc.Serialize(ref Surfs, SCExt.Serialize);
            sc.BulkSerialize(ref Verts, SCExt.Serialize, sc.Game == MEGame.ME3 ? 16 : 24);
            sc.Serialize(ref NumSharedSides);
            sc.Serialize(ref Zones, SCExt.Serialize);
            sc.Serialize(ref Polys);
            sc.BulkSerialize(ref LeafHulls, SCExt.Serialize, 4);
            sc.BulkSerialize(ref Leaves, SCExt.Serialize, 4);
            sc.Serialize(ref RootOutside);
            sc.Serialize(ref Linked);
            sc.BulkSerialize(ref PortalNodes, SCExt.Serialize, 4);
            if (sc.Game != MEGame.UDK)
            {
                sc.BulkSerialize(ref ShadowVolume, SCExt.Serialize, 16);
            }
            else if (sc.IsLoading)
            {
                ShadowVolume = Array.Empty <MeshEdge>();
            }
            sc.Serialize(ref NumVertices);
            sc.BulkSerialize(ref VertexBuffer, SCExt.Serialize, 36);
            if (sc.Game >= MEGame.ME3)
            {
                sc.Serialize(ref LightingGuid);
                sc.Serialize(ref LightmassSettings, SCExt.Serialize);
            }
            else if (sc.IsLoading)
            {
                LightmassSettings = new[]
                {
                    new LightmassPrimitiveSettings
                    {
                        FullyOccludedSamplesFraction = 1,
                        EmissiveLightFalloffExponent = 2,
                        EmissiveBoost = 1,
                        DiffuseBoost  = 1,
                        SpecularBoost = 1
                    }
                };
            }
        }
Example #3
0
 public NameReference FriendlyName; //ME1/2
 protected override void Serialize(SerializingContainer2 sc)
 {
     base.Serialize(sc);
     sc.Serialize(ref NativeIndex);
     if (sc.Game <= MEGame.ME2)
     {
         sc.Serialize(ref OperatorPrecedence);
     }
     sc.Serialize(ref FunctionFlags);
     if (sc.Game <= MEGame.ME2 && FunctionFlags.HasFlag(FunctionFlags.Net))
     {
         sc.Serialize(ref ReplicationOffset);
     }
     if (sc.Game <= MEGame.ME2)
     {
         sc.Serialize(ref FriendlyName);
     }
 }
Example #4
0
        protected void Serialize(SerializingContainer2 sc)
        {
            var mainHeader = new ChunkHeader
            {
                ChunkID = "ANIMHEAD",
                Version = version
            };

            sc.Serialize(ref mainHeader);

            var boneHeader = new ChunkHeader
            {
                ChunkID   = "BONENAMES",
                Version   = version,
                DataSize  = 0x78,
                DataCount = Bones?.Count ?? 0
            };

            sc.Serialize(ref boneHeader);
            sc.Serialize(ref Bones, boneHeader.DataCount, SCExt.Serialize);

            var infoHeader = new ChunkHeader
            {
                ChunkID   = "ANIMINFO",
                Version   = version,
                DataSize  = 0xa8,
                DataCount = Infos?.Count ?? 0
            };

            sc.Serialize(ref infoHeader);
            sc.Serialize(ref Infos, infoHeader.DataCount, SCExt.Serialize);

            var keyHeader = new ChunkHeader
            {
                ChunkID   = "ANIMKEYS",
                Version   = version,
                DataSize  = 0x20,
                DataCount = Keys?.Count ?? 0
            };

            sc.Serialize(ref keyHeader);
            sc.Serialize(ref Keys, keyHeader.DataCount, SCExt.Serialize);
        }
Example #5
0
        public static void Serialize(this SerializingContainer2 sc, ref PSA.PSAAnimInfo a)
        {
            if (sc.IsLoading)
            {
                a = new PSA.PSAAnimInfo();
            }

            sc.SerializeFixedSizeString(ref a.Name, 64);
            sc.SerializeFixedSizeString(ref a.Group, 64);
            sc.Serialize(ref a.TotalBones);
            sc.Serialize(ref a.RootInclude);
            sc.Serialize(ref a.KeyCompressionStyle);
            sc.Serialize(ref a.KeyQuotum);
            sc.Serialize(ref a.KeyReduction);
            sc.Serialize(ref a.TrackTime);
            sc.Serialize(ref a.AnimRate);
            sc.Serialize(ref a.StartBone);
            sc.Serialize(ref a.FirstRawFrame);
            sc.Serialize(ref a.NumRawFrames);
        }
Example #6
0
        public uint unk3;               //UDK


        protected override void Serialize(SerializingContainer2 sc)
        {
            sc.Serialize(ref Bounds);
            sc.Serialize(ref Materials, SCExt.Serialize);
            sc.Serialize(ref Origin);
            sc.Serialize(ref RotOrigin);
            sc.Serialize(ref RefSkeleton, SCExt.Serialize);
            sc.Serialize(ref SkeletalDepth);
            sc.Serialize(ref LODModels, SCExt.Serialize);
            sc.Serialize(ref NameIndexMap, SCExt.Serialize, SCExt.Serialize);
            sc.Serialize(ref PerPolyBoneKDOPs, SCExt.Serialize);

            if (sc.Game >= MEGame.ME3)
            {
                if (sc.IsSaving && sc.Game == MEGame.UDK)
                {
                    ClothingAssets = new UIndex[0];
                }
                sc.Serialize(ref BoneBreakNames, SCExt.Serialize);
                sc.Serialize(ref ClothingAssets, SCExt.Serialize);
            }
            else
            {
                BoneBreakNames = Array.Empty <string>();
                ClothingAssets = Array.Empty <UIndex>();
            }

            if (sc.Game == MEGame.UDK)
            {
                sc.Serialize(ref unk1);
                sc.Serialize(ref unk2);
                sc.Serialize(ref unkFloats, SCExt.Serialize);
                sc.Serialize(ref unk3);
            }
            else if (sc.IsLoading)
            {
                unk1      = 1;
                unkFloats = new [] { 1f, 0f, 0f, 0f };
            }
        }
Example #7
0
        public UIndex[] ClothingAssets; //ME3 and UDK

        protected override void Serialize(SerializingContainer2 sc)
        {
            sc.Serialize(ref Bounds);
            sc.Serialize(ref Materials, SCExt.Serialize);
            sc.Serialize(ref Origin);
            sc.Serialize(ref RotOrigin);
            sc.Serialize(ref RefSkeleton, SCExt.Serialize);
            sc.Serialize(ref SkeletalDepth);
            sc.Serialize(ref LODModels, SCExt.Serialize);
            sc.Serialize(ref NameIndexMap, SCExt.Serialize, SCExt.Serialize);
            sc.Serialize(ref PerPolyBoneKDOPs, SCExt.Serialize);

            if (sc.Game >= MEGame.ME3)
            {
                sc.Serialize(ref BoneBreakNames, SCExt.Serialize);
                sc.Serialize(ref ClothingAssets, SCExt.Serialize);
            }
            else
            {
                BoneBreakNames = Array.Empty <string>();
                ClothingAssets = Array.Empty <UIndex>();
            }
        }
Example #8
0
        protected override void Serialize(SerializingContainer2 sc)
        {
            var components = Export.GetProperty <ArrayProperty <ObjectProperty> >("LightComponents");

            if (components == null || components.Count == 0)
            {
                return;
            }

            if (sc.IsLoading)
            {
                LocalToWorldTransforms = new List <Matrix>(components.Count);
            }

            for (int i = 0; i < components.Count; i++)
            {
                Matrix m = i < LocalToWorldTransforms.Count ? LocalToWorldTransforms[i] : Matrix.Identity;
                sc.Serialize(ref m);
                if (sc.IsLoading)
                {
                    LocalToWorldTransforms.Add(m);
                }
            }
        }
Example #9
0
        private static void SerializeFixedSizeString(this SerializingContainer2 sc, ref string s, int length)
        {
            if (sc.IsLoading)
            {
                var pos = sc.ms.Position;
                s = sc.ms.ReadStringASCIINull();

                sc.ms.JumpTo(pos + length);
            }
            else
            {
                for (int i = 0; i < length; i++)
                {
                    if (i < s.Length)
                    {
                        sc.ms.Writer.WriteByte((byte)s[i]);
                    }
                    else
                    {
                        sc.ms.Writer.WriteByte(0);
                    }
                }
            }
        }
Example #10
0
 public OrderedMultiValueDictionary <NameReference, UIndex> AnimationMap;//? Speculative name
 protected override void Serialize(SerializingContainer2 sc)
 {
     sc.Serialize(ref AnimationMap, SCExt.Serialize, SCExt.Serialize);
 }
Example #11
0
 protected override void Serialize(SerializingContainer2 sc)
 {
     sc.Serialize(ref CachedPhysBrushData);
 }
Example #12
0
        public Guid LightingGuid;            //ME3/UDK

        protected override void Serialize(SerializingContainer2 sc)
        {
            sc.Serialize(ref Bounds);
            sc.Serialize(ref BodySetup);
            if (sc.IsSaving)
            {
                if (sc.Game >= MEGame.ME3 && kDOPTreeME3UDK == null)
                {
                    kDOPTreeME3UDK = KDOPTreeBuilder.ToCompact(kDOPTreeME1ME2.Triangles, LODModels[0].PositionVertexBuffer.VertexData);
                }
                else if (sc.Game < MEGame.ME3 && kDOPTreeME1ME2 == null)
                {
                    //todo: need to convert kDOPTreeCompact to kDOPTree
                    throw new NotImplementedException("Cannot convert ME3 StaticMeshes to ME1 or ME2 format :(");
                }
            }

            if (sc.Game >= MEGame.ME3)
            {
                sc.Serialize(ref kDOPTreeME3UDK);
            }
            else
            {
                sc.Serialize(ref kDOPTreeME1ME2);
            }

            if (sc.IsSaving)
            {
                //This will improve loading times by preventing the engine from rebuilding the mesh
                if (sc.Game == MEGame.ME1)
                {
                    InternalVersion = 15;
                }
                if (sc.Game == MEGame.ME2)
                {
                    InternalVersion = 16;
                }
                if (sc.Game == MEGame.ME3)
                {
                    InternalVersion = 18;
                }
                if (sc.Game == MEGame.UDK)
                {
                    InternalVersion = 18;
                }
            }
            sc.Serialize(ref InternalVersion);
            if (sc.Game == MEGame.UDK)
            {
                int dummy = 0;
                sc.Serialize(ref dummy);
                sc.Serialize(ref dummy);
                sc.Serialize(ref dummy);
                sc.Serialize(ref dummy);
            }
            sc.Serialize(ref LODModels, SCExt.Serialize);
            if (sc.Game == MEGame.ME1)
            {
                sc.Serialize(ref unk2);
                sc.Serialize(ref unk3);
                sc.Serialize(ref unk4);
                sc.Serialize(ref unk5);
                sc.Serialize(ref unk6);
            }
            else
            {
                sc.Serialize(ref unk1);
                sc.Serialize(ref ThumbnailAngle);
                sc.Serialize(ref ThumbnailDistance);
                if (sc.Game != MEGame.UDK)
                {
                    sc.Serialize(ref unk7);
                }
                if (sc.Game >= MEGame.ME3)
                {
                    sc.Serialize(ref HighResSourceMeshName);
                    sc.Serialize(ref HighResSourceMeshCRC);
                    sc.Serialize(ref LightingGuid);
                }
            }

            if (sc.IsLoading && sc.Game < MEGame.ME3)
            {
                LightingGuid = Guid.NewGuid();
            }
        }
Example #13
0
 //should never be called
 protected override void Serialize(SerializingContainer2 sc)
 {
     data = sc.ms.BaseStream.ReadFully();
 }
 protected abstract void Serialize(SerializingContainer2 sc);
Example #15
0
 protected override void Serialize(SerializingContainer2 sc)
 {
     sc.Serialize(ref SequenceNamesToUnkMap, SCExt.Serialize, SCExt.Serialize);
 }
Example #16
0
 protected override void Serialize(SerializingContainer2 sc)
 {
     sc.Serialize(ref SM3MaterialResource);
     sc.Serialize(ref SM2MaterialResource);
 }
Example #17
0
 protected override void Serialize(SerializingContainer2 sc)
 {
     base.Serialize(sc);
     sc.Serialize(ref Reference2);
 }
Example #18
0
 protected override void Serialize(SerializingContainer2 sc)
 {
     sc.Serialize(ref SuperClass);
     sc.Serialize(ref Next);
 }
 protected override void Serialize(SerializingContainer2 sc)
 {
     sc.Serialize(ref ArchetypeToInstanceMap, SCExt.Serialize, SCExt.Serialize);
     sc.Serialize(ref ObjectMap, SCExt.Serialize, SCExt.Serialize);
 }
Example #20
0
        public UIndex ArtPlaceable2; //ME1

        protected override void Serialize(SerializingContainer2 sc)
        {
            sc.Serialize(ref Self);
            sc.Serialize(ref Actors, SCExt.Serialize);
            sc.Serialize(ref URL);
            sc.Serialize(ref Model);
            sc.Serialize(ref ModelComponents, SCExt.Serialize);
            sc.Serialize(ref GameSequences, SCExt.Serialize);
            sc.Serialize(ref TextureToInstancesMap, SCExt.Serialize, SCExt.Serialize);
            if (sc.Game == MEGame.ME3)
            {
                sc.Serialize(ref ApexMesh, SCExt.Serialize);
            }
            else if (sc.IsLoading)
            {
                ApexMesh = Array.Empty <byte>();
            }

            int byteSize = 1;

            sc.Serialize(ref byteSize);
            sc.Serialize(ref CachedPhysBSPData, SCExt.Serialize);

            sc.Serialize(ref CachedPhysSMDataMap, SCExt.Serialize, SCExt.Serialize);
            sc.Serialize(ref CachedPhysSMDataStore, SCExt.Serialize);
            sc.Serialize(ref CachedPhysPerTriSMDataMap, SCExt.Serialize, SCExt.Serialize);
            sc.Serialize(ref CachedPhysPerTriSMDataStore, SCExt.Serialize);
            sc.Serialize(ref CachedPhysBSPDataVersion);
            sc.Serialize(ref CachedPhysSMDataVersion);
            sc.Serialize(ref ForceStreamTextures, SCExt.Serialize, SCExt.Serialize);
            sc.Serialize(ref NavListStart);
            sc.Serialize(ref NavListEnd);
            sc.Serialize(ref CoverListStart);
            sc.Serialize(ref CoverListEnd);
            if (sc.Game == MEGame.ME3)
            {
                sc.Serialize(ref PylonListStart);
                sc.Serialize(ref PylonListEnd);
                sc.Serialize(ref guidToIntMap, SCExt.Serialize, SCExt.Serialize);
                sc.Serialize(ref CoverLinks, SCExt.Serialize);
                sc.Serialize(ref intToByteMap, SCExt.Serialize, SCExt.Serialize);
                sc.Serialize(ref guidToIntMap2, SCExt.Serialize, SCExt.Serialize);
                sc.Serialize(ref NavPoints, SCExt.Serialize);
                sc.Serialize(ref numbers, SCExt.Serialize);
            }
            else if (sc.IsLoading)
            {
                PylonListStart = new UIndex(0);
                PylonListEnd   = new UIndex(0);
                guidToIntMap   = new OrderedMultiValueDictionary <Guid, int>();
                CoverLinks     = new UIndex[0];
                intToByteMap   = new OrderedMultiValueDictionary <int, byte>();
                guidToIntMap2  = new OrderedMultiValueDictionary <Guid, int>();
                NavPoints      = new UIndex[0];
                numbers        = new int[0];
            }
            sc.Serialize(ref CrossLevelActors, SCExt.Serialize);
            if (sc.Game == MEGame.ME3)
            {
                //PrecomputedLightVolume
                bool bIsInitialized = false;
                sc.Serialize(ref bIsInitialized);
                //should always be false, but just in case;
                if (bIsInitialized)
                {
                    throw new Exception($"PersistentLevel has a PreComputedLightVolume! Level in: {sc.Pcc.FilePath}");
                }
            }

            if (sc.Game == MEGame.ME1)
            {
                sc.Serialize(ref ArtPlaceable1);
                sc.Serialize(ref ArtPlaceable2);
            }
            else if (sc.IsLoading)
            {
                ArtPlaceable1 = new UIndex(0);
                ArtPlaceable2 = new UIndex(0);
            }
        }
Example #21
0
 protected override void Serialize(SerializingContainer2 sc)
 {
     base.Serialize(sc);
     sc.Serialize(ref Names, SCExt.Serialize);
 }
Example #22
0
 protected override void Serialize(SerializingContainer2 sc)
 {
     sc.Serialize(ref LODData, SCExt.Serialize);
 }
Example #23
0
 protected override void Serialize(SerializingContainer2 sc)
 {
     base.Serialize(sc);
     sc.Serialize(ref Value);
 }
 protected override void Serialize(SerializingContainer2 sc)
 {
     sc.Serialize(ref StaticRecievers, SCExt.Serialize);
 }
Example #25
0
        public UIndex ArtPlaceable2; //ME1

        protected override void Serialize(SerializingContainer2 sc)
        {
            sc.Serialize(ref Self);
            sc.Serialize(ref Actors, SCExt.Serialize);
            sc.Serialize(ref URL);
            sc.Serialize(ref Model);
            sc.Serialize(ref ModelComponents, SCExt.Serialize);
            sc.Serialize(ref GameSequences, SCExt.Serialize);
            sc.Serialize(ref TextureToInstancesMap, SCExt.Serialize, SCExt.Serialize);
            if (sc.Game == MEGame.UDK)
            {
                sc.Serialize(ref MeshComponentsWithDynamiclighting, SCExt.Serialize, SCExt.Serialize);
            }
            else
            {
                MeshComponentsWithDynamiclighting = new OrderedMultiValueDictionary <UIndex, uint>();
            }
            if (sc.Game >= MEGame.ME3)
            {
                sc.Serialize(ref ApexMesh, SCExt.Serialize);
            }
            else if (sc.IsLoading)
            {
                ApexMesh = Array.Empty <byte>();
            }

            int byteSize = 1;

            sc.Serialize(ref byteSize);
            sc.Serialize(ref CachedPhysBSPData, SCExt.Serialize);

            sc.Serialize(ref CachedPhysSMDataMap, SCExt.Serialize, SCExt.Serialize);
            sc.Serialize(ref CachedPhysSMDataStore, SCExt.Serialize);
            sc.Serialize(ref CachedPhysPerTriSMDataMap, SCExt.Serialize, SCExt.Serialize);
            sc.Serialize(ref CachedPhysPerTriSMDataStore, SCExt.Serialize);
            sc.Serialize(ref CachedPhysBSPDataVersion);
            sc.Serialize(ref CachedPhysSMDataVersion);
            sc.Serialize(ref ForceStreamTextures, SCExt.Serialize, SCExt.Serialize);
            if (sc.Game == MEGame.UDK)
            {
                KCachedConvexData dummy = new KCachedConvexData {
                    CachedConvexElements = Array.Empty <KCachedConvexDataElement>()
                };
                sc.Serialize(ref dummy);
                int dummyInt = 0;
                sc.Serialize(ref dummyInt);
            }
            sc.Serialize(ref NavListStart);
            sc.Serialize(ref NavListEnd);
            sc.Serialize(ref CoverListStart);
            sc.Serialize(ref CoverListEnd);
            if (sc.Game >= MEGame.ME3)
            {
                sc.Serialize(ref PylonListStart);
                sc.Serialize(ref PylonListEnd);
            }
            if (sc.Game == MEGame.ME3)
            {
                sc.Serialize(ref guidToIntMap, SCExt.Serialize, SCExt.Serialize);
                sc.Serialize(ref CoverLinks, SCExt.Serialize);
                sc.Serialize(ref intToByteMap, SCExt.Serialize, SCExt.Serialize);
                sc.Serialize(ref guidToIntMap2, SCExt.Serialize, SCExt.Serialize);
                sc.Serialize(ref NavPoints, SCExt.Serialize);
                sc.Serialize(ref numbers, SCExt.Serialize);
            }
            else if (sc.IsLoading)
            {
                PylonListStart = new UIndex(0);
                PylonListEnd   = new UIndex(0);
                guidToIntMap   = new OrderedMultiValueDictionary <Guid, int>();
                CoverLinks     = new UIndex[0];
                intToByteMap   = new OrderedMultiValueDictionary <int, byte>();
                guidToIntMap2  = new OrderedMultiValueDictionary <Guid, int>();
                NavPoints      = new UIndex[0];
                numbers        = new int[0];
            }
            sc.Serialize(ref CrossLevelActors, SCExt.Serialize);
            if (sc.Game == MEGame.UDK)
            {
                int dummy = 0;
                sc.Serialize(ref dummy);
                sc.Serialize(ref dummy);
                sc.Serialize(ref dummy);
            }

            if (sc.Game == MEGame.ME1)
            {
                sc.Serialize(ref ArtPlaceable1);
                sc.Serialize(ref ArtPlaceable2);
            }
            else if (sc.IsLoading)
            {
                ArtPlaceable1 = new UIndex(0);
                ArtPlaceable2 = new UIndex(0);
            }

            if (sc.Game == MEGame.UDK && sc.IsSaving)
            {
                sc.ms.WriteBoolInt(false); //PrecomputedLightVolume bIsInitialized
                sc.ms.WriteZeros(28);      //Zero-ed PrecomputedVisibilityHandler
                sc.ms.WriteZeros(45);      //unk data
            }

            if (sc.Game == MEGame.ME3)
            {
                //PrecomputedLightVolume
                bool bIsInitialized = false;
                sc.Serialize(ref bIsInitialized);
                //should always be false, but just in case;
                if (bIsInitialized)
                {
                    throw new Exception($"PersistentLevel has a PreComputedLightVolume! Level in: {sc.Pcc.FilePath}");
                }
            }
        }