private static void ReadPerTrackVectorData(FArchive Ar, string trackKind, ref FVector[] dstKeys, ref float[] dstTimeKeys, int numFrames) { var packedInfo = Ar.Read <uint>(); var keyFormat = (AnimationCompressionFormat)(packedInfo >> 28); var componentMask = (int)((packedInfo >> 24) & 0xF); var numKeys = (int)(packedInfo & 0xFFFFFF); var hasTimeTracks = (componentMask & 8) != 0; var mins = FVector.ZeroVector; var ranges = FVector.ZeroVector; dstKeys = new FVector[numKeys]; if (keyFormat == ACF_IntervalFixed32NoW) { // read mins/maxs if ((componentMask & 1) != 0) { mins.X = Ar.Read <float>(); ranges.X = Ar.Read <float>(); } if ((componentMask & 2) != 0) { mins.Y = Ar.Read <float>(); ranges.Y = Ar.Read <float>(); } if ((componentMask & 4) != 0) { mins.Z = Ar.Read <float>(); ranges.Z = Ar.Read <float>(); } } for (var keyIndex = 0; keyIndex < numKeys; keyIndex++) { switch (keyFormat) { case ACF_None: case ACF_Float96NoW: { FVector v; if ((componentMask & 7) != 0) { v = new FVector( (componentMask & 1) != 0 ? Ar.Read <float>() : 0, (componentMask & 2) != 0 ? Ar.Read <float>() : 0, (componentMask & 4) != 0 ? Ar.Read <float>() : 0 ); } else { // ACF_Float96NoW has a special case for ((ComponentMask & 7) == 0) v = Ar.Read <FVector>(); } dstKeys[keyIndex] = v; break; } case ACF_IntervalFixed32NoW: { var v = Ar.ReadVectorIntervalFixed32(mins, ranges); dstKeys[keyIndex] = v; break; } case ACF_Fixed48NoW: { var v = new FVector( (componentMask & 1) != 0 ? DecodeFixed48_PerTrackComponent(Ar.Read <ushort>(), 7) : 0, (componentMask & 2) != 0 ? DecodeFixed48_PerTrackComponent(Ar.Read <ushort>(), 7) : 0, (componentMask & 4) != 0 ? DecodeFixed48_PerTrackComponent(Ar.Read <ushort>(), 7) : 0 ); dstKeys[keyIndex] = v; break; } case ACF_Identity: dstKeys[keyIndex] = FVector.ZeroVector; break; default: throw new ParserException(Ar, $"Unknown {trackKind} compression method: {(int) keyFormat} ({keyFormat})"); } } // align to 4 bytes Ar.Position = Ar.Position.Align(4); if (hasTimeTracks) { ReadTimeArray(Ar, numKeys, out dstTimeKeys, numFrames); } }
public override void Deserialize(FArchive reader) { reader.Read(out _outputIndex); base.Deserialize(reader); }
public override void Deserialize(FArchive reader) { base.Deserialize(reader); reader.Read(out _value); }
public FArchive Serialize(FArchive archive) { var VersionNumber = (ELocResVersion)archive.AssetVersion; var IsCompact = VersionNumber >= ELocResVersion.Compact; List <LocalizationString> LocalizedStringArray = new List <LocalizationString>(); if (IsCompact) { long localizedStringArrayOffset = 0; archive.Read(ref localizedStringArrayOffset); if (localizedStringArrayOffset != -1) { var offset = archive.Tell(); archive.Seek(localizedStringArrayOffset); if (VersionNumber >= ELocResVersion.Optimized) { archive.Read(ref LocalizedStringArray !); } else { List <FString>?tempStringArray = default; archive.Read(ref tempStringArray); LocalizedStringArray.AddRange(tempStringArray.Select(t => new LocalizationString(t))); } archive.Seek(offset); } } if (VersionNumber >= ELocResVersion.Optimized) { uint entryCount = 0; archive.Read(ref entryCount); } int namespaceCount = 0; archive.Read(ref namespaceCount); for (var i = 0; i < namespaceCount; i++) { LocalizationKey?_namespace = default; archive.Read(ref _namespace); var KeyTable = _namespaces.FindOrAdd(_namespace); int keyCount = 0; archive.Read(ref keyCount); for (var j = 0; j < keyCount; j++) { LocalizationKey?_key = default; archive.Read(ref _key); var Entry = KeyTable.FindOrAdd(_key); int hash = 0; archive.Read(ref hash); Entry.SourceStringHash = hash; if (IsCompact) { int localizedStringIndex = 0; archive.Read(ref localizedStringIndex); if (localizedStringIndex > -1 && localizedStringIndex < LocalizedStringArray.Count) { Entry.LocalizedString = LocalizedStringArray[localizedStringIndex].Value; } } else { FString?localizedString = default; archive.Read(ref localizedString); Entry.LocalizedString = localizedString; } } } return(archive); }
public void Deserialize(FArchive reader) { var version = reader.Version; reader.Read(out _classIndex); reader.Read(out _superIndex); if (version >= UE4Version.VER_UE4_TemplateIndex_IN_COOKED_EXPORTS) { reader.Read(out _templateIndex); } reader.Read(out _outerIndex); reader.Read(out _objectName); reader.ReadUnsafe(out _objectFlags); if (version < UE4Version.VER_UE4_64BIT_EXPORTMAP_SERIALSIZES) { reader.Read(out int size); reader.Read(out int offset); _serialSize = size; _serialOffset = offset; } else { reader.Read(out _serialSize); reader.Read(out _serialOffset); } reader.Read(out _bForcedExport); reader.Read(out _bNotForClient); reader.Read(out _bNotForServer); reader.Read(out _packageGuid); reader.ReadUnsafe(out _packageFlags); if (version >= UE4Version.VER_UE4_LOAD_FOR_EDITOR_GAME) { reader.Read(out _bNotAlwaysLoadedForEditorGame); } if (version >= UE4Version.VER_UE4_COOKED_ASSETS_IN_EDITOR_SUPPORT) { reader.Read(out _bIsAsset); } if (version >= UE4Version.VER_UE4_PRELOAD_DEPENDENCIES_IN_COOKED_EXPORTS) { reader.Read(out _firstExportDependency); reader.Read(out _serializationBeforeSerializationDependencies); reader.Read(out _createBeforeSerializationDependencies); reader.Read(out _serializationBeforeCreateDependencies); reader.Read(out _createBeforeCreateDependencies); } }
public FExportBundleHeader(FArchive Ar) { SerialOffset = Ar.Game >= EGame.GAME_UE5_0 ? Ar.Read <ulong>() : ulong.MaxValue; FirstEntryIndex = Ar.Read <uint>(); EntryCount = Ar.Read <uint>(); }
public override FArchive Serialize(FArchive archive) => archive.Read(ref _format) .Read(ref _argument);
public virtual FArchive Serialize(FArchive archive) { archive.Read(ref _objectIndex); Resource = _objectIndex.Resolve(archive); return(archive); }
public FTextLocalizationResourceString(FArchive Ar) { String = Ar.ReadFString(); RefCount = Ar.Read <int>(); }
public void Deserialize(FArchive reader) { reader.Read(out _sourceString); reader.Read(out _sourceStringMetaData); }
public FArchive Serialize(FArchive archive) => archive.Read(ref _tags);
public void Deserialize(FArchive reader) { reader.Read(out _rot); reader.Read(out _trans); reader.Read(out _scale); }
public FLevelSequenceLegacyObjectReference(FArchive Ar) { ObjectId = Ar.Read <FGuid>(); ObjectPath = Ar.ReadFString(); }
private static void ReadKeyLerpData(FArchive reader, UAnimSequence animSequence, CAnimTrack track, int trackIndex, bool hasTimeTracks) { var compressedData = (FUECompressedAnimData)animSequence.CompressedDataStructure; var transOffset = compressedData.CompressedTrackOffsets[trackIndex * 4]; var transKeys = compressedData.CompressedTrackOffsets[trackIndex * 4 + 1]; var rotOffset = compressedData.CompressedTrackOffsets[trackIndex * 4 + 2]; var rotKeys = compressedData.CompressedTrackOffsets[trackIndex * 4 + 3]; track.KeyPos = new FVector[transKeys]; track.KeyQuat = new FQuat[rotKeys]; var mins = FVector.ZeroVector; var ranges = FVector.ZeroVector; // read translation keys if (transKeys > 0) { reader.Position = transOffset; var translationCompressionFormat = compressedData.TranslationCompressionFormat; if (transKeys == 1) { translationCompressionFormat = ACF_None; // single key is stored without compression } // read mins/ranges if (translationCompressionFormat == ACF_IntervalFixed32NoW) { mins = reader.Read <FVector>(); ranges = reader.Read <FVector>(); } for (var keyIndex = 0; keyIndex < transKeys; keyIndex++) { track.KeyPos[keyIndex] = translationCompressionFormat switch { ACF_None => reader.Read <FVector>(), ACF_Float96NoW => reader.Read <FVector>(), ACF_IntervalFixed32NoW => reader.ReadVectorIntervalFixed32(mins, ranges), ACF_Fixed48NoW => reader.ReadVectorFixed48(), ACF_Identity => FVector.ZeroVector, _ => throw new ParserException($"Unknown translation compression method: {(int) translationCompressionFormat} ({translationCompressionFormat})") }; } // align to 4 bytes reader.Position = reader.Position.Align(4); if (hasTimeTracks) { ReadTimeArray(reader, transKeys, out track.KeyPosTime, animSequence.NumFrames); } } else { // A.KeyPos.Add(FVector.ZeroVector); // appNotify("No translation keys!"); } // read rotation keys reader.Position = rotOffset; var rotationCompressionFormat = compressedData.RotationCompressionFormat; if (rotKeys == 1) { rotationCompressionFormat = ACF_Float96NoW; // single key is stored without compression } else if (rotKeys > 1 && rotationCompressionFormat == ACF_IntervalFixed32NoW) { // Mins/Ranges are read only when needed - i.e. for ACF_IntervalFixed32NoW mins = reader.Read <FVector>(); ranges = reader.Read <FVector>(); } for (var k = 0; k < rotKeys; k++) { track.KeyQuat[k] = rotationCompressionFormat switch { ACF_None => reader.Read <FQuat>(), ACF_Float96NoW => reader.ReadQuatFloat96NoW(), ACF_Fixed48NoW => reader.ReadQuatFixed48NoW(), ACF_Fixed32NoW => reader.ReadQuatFixed32NoW(), ACF_IntervalFixed32NoW => reader.ReadQuatIntervalFixed32NoW(mins, ranges), ACF_Float32NoW => reader.ReadQuatFloat32NoW(), ACF_Identity => FQuat.Identity, _ => throw new ParserException($"Unknown rotation compression method: {(int) rotationCompressionFormat} ({rotationCompressionFormat})") }; } if (hasTimeTracks) { // align to 4 bytes reader.Position = reader.Position.Align(4); ReadTimeArray(reader, rotKeys, out track.KeyQuatTime, animSequence.NumFrames); } }
public override void Deserialize(FArchive reader) { reader.Read(out _property); base.Deserialize(reader); }
public FArchive Serialize(FArchive archive) => archive.Read(ref _rot) .Read(ref _trans) .Read(ref _scale);
public override void Deserialize(FArchive reader) { base.Deserialize(reader); reader.Read(out _prop); Expression = Token.Read(reader); }
public FArchive Serialize(FArchive archive) => archive.Read(ref _x) .Read(ref _y) .Read(ref _z) .Read(ref _w);
public void Deserialize(FArchive reader) => reader.Read(out _values);
public FArchive Serialize(FArchive archive) => archive.Read(ref _major) .Read(ref _minor) .Read(ref _patch) .Read(ref _changelist) .Read(ref _branch);
public void Deserialize(FArchive reader) => reader.Read(out _guid);
public FWeightedRandomSampler(FArchive Ar) { Prob = Ar.ReadArray <float>(); Alias = Ar.ReadArray <int>(); TotalWeight = Ar.Read <float>(); }
public readonly FStaticMeshUVItem[] UV; // TangentsData ? public FStaticMeshVertexBuffer(FArchive Ar) { var stripDataFlags = new FStripDataFlags(Ar, FPackageFileVersion.CreateUE4Version(EUnrealEngineObjectUE4Version.STATIC_SKELETAL_MESH_SERIALIZATION_FIX)); // SerializeMetaData NumTexCoords = Ar.Read <int>(); Strides = Ar.Game < EGame.GAME_UE4_19 ? Ar.Read <int>() : -1; NumVertices = Ar.Read <int>(); UseFullPrecisionUVs = Ar.ReadBoolean(); UseHighPrecisionTangentBasis = Ar.Game >= EGame.GAME_UE4_12 && Ar.ReadBoolean(); if (!stripDataFlags.IsDataStrippedForServer()) { if (Ar.Game < EGame.GAME_UE4_19) { UV = Ar.ReadBulkArray(() => new FStaticMeshUVItem(Ar, UseHighPrecisionTangentBasis, NumTexCoords, UseFullPrecisionUVs)); } else { var tempTangents = Array.Empty <FPackedNormal[]>(); if (Ar.Game == EGame.GAME_StarWarsJediFallenOrder && Ar.ReadBoolean()) // bDropNormals { goto texture_coordinates; } // BulkSerialize var itemSize = Ar.Read <int>(); var itemCount = Ar.Read <int>(); var position = Ar.Position; if (itemCount != NumVertices) { throw new ParserException($"NumVertices={itemCount} != NumVertices={NumVertices}"); } tempTangents = Ar.ReadArray(NumVertices, () => FStaticMeshUVItem.SerializeTangents(Ar, UseHighPrecisionTangentBasis)); if (Ar.Position - position != itemCount * itemSize) { throw new ParserException($"Read incorrect amount of tangent bytes, at {Ar.Position}, should be: {position + itemSize * itemCount} behind: {position + (itemSize * itemCount) - Ar.Position}"); } texture_coordinates: itemSize = Ar.Read <int>(); itemCount = Ar.Read <int>(); position = Ar.Position; if (itemCount != NumVertices * NumTexCoords) { throw new ParserException($"NumVertices={itemCount} != {NumVertices * NumTexCoords}"); } var uv = Ar.ReadArray(NumVertices, () => FStaticMeshUVItem.SerializeTexcoords(Ar, NumTexCoords, UseFullPrecisionUVs)); if (Ar.Position - position != itemCount * itemSize) { throw new ParserException($"Read incorrect amount of Texture Coordinate bytes, at {Ar.Position}, should be: {position + itemSize * itemCount} behind: {position + (itemSize * itemCount) - Ar.Position}"); } UV = new FStaticMeshUVItem[NumVertices]; for (var i = 0; i < NumVertices; i++) { if (Ar.Game == EGame.GAME_StarWarsJediFallenOrder && tempTangents.Length == 0) { UV[i] = new FStaticMeshUVItem(new [] { new FPackedNormal(0), new FPackedNormal(0), new FPackedNormal(0) }, uv[i]); } else { UV[i] = new FStaticMeshUVItem(tempTangents[i], uv[i]); } } } } else { UV = Array.Empty <FStaticMeshUVItem>(); } }
public FArchive Serialize(FArchive archive) => archive.Read(ref _min) .Read(ref _max) .Read(ref _isValid);
public override FArchive Serialize(FArchive reader, PropertyTag tag) => reader.Read(ref _value);
public FArchive Serialize(FArchive archive) { const long MinimumPackageSize = 32; if (archive.Length() < MinimumPackageSize) { return(archive); } archive.Read(ref _tag); if (!IsAssetFile) { return(archive); } const int CurrentLegacyFileVersion = -7; int LegacyFileVersion = 0; archive.Read(ref LegacyFileVersion); if (LegacyFileVersion < 0) { if (LegacyFileVersion < CurrentLegacyFileVersion) { _fileVersionUE4 = 0; _fileVersionLicenseeUE4 = 0; return(archive); } if (LegacyFileVersion != -4) { int LegacyUE3Version = 0; // skip legacy ue3 version archive.Read(ref LegacyUE3Version); } archive.ReadUnsafe(ref _fileVersionUE4); archive.Read(ref _fileVersionLicenseeUE4); if (LegacyFileVersion <= -2) { CustomVersionContainer = new CustomVersionContainer(CustomVersionFormatForArchive(LegacyFileVersion)); CustomVersionContainer.Serialize(archive); } if (_fileVersionUE4 == 0 && _fileVersionLicenseeUE4 == 0) { IsUnversioned = true; if (archive.Version == 0) { // Set latest archive.Version = _fileVersionUE4 = UE4Version.VER_UE4_AUTOMATIC_VERSION; _fileVersionLicenseeUE4 = 0; } else { _fileVersionUE4 = archive.Version; // version read from config file } } } else { _fileVersionUE4 = 0; _fileVersionLicenseeUE4 = 0; } archive.Read(ref _totalHeaderSize) .Read(ref _folderName) .ReadUnsafe(ref _packageFlags) .Read(ref _nameCount) .Read(ref _nameOffset); if ((_packageFlags & EPackageFlags.FilterEditorOnly) == 0 && _fileVersionUE4 >= UE4Version.VER_UE4_ADDED_PACKAGE_SUMMARY_LOCALIZATION_ID) { archive.Read(ref _localizationId); } if (_fileVersionUE4 >= UE4Version.VER_UE4_SERIALIZE_TEXT_IN_PACKAGES) { archive.Read(ref _gatherableTextDataCount) .Read(ref _gatherableTextDataOffset); } archive.Read(ref _exportCount) .Read(ref _exportOffset) .Read(ref _importCount) .Read(ref _importOffset) .Read(ref _dependsOffset); if (_fileVersionUE4 < UE4Version.VER_UE4_OLDEST_LOADABLE_PACKAGE) { return(archive); } if (_fileVersionUE4 >= UE4Version.VER_UE4_ADD_STRING_ASSET_REFERENCES_MAP) { archive.Read(ref _softPackageReferencesCount) .Read(ref _softPackageReferencesOffset); } if (_fileVersionUE4 >= UE4Version.VER_UE4_ADDED_SEARCHABLE_NAMES) { archive.Read(ref _searchableNamesOffset); } archive.Read(ref _thumbnailTableOffset) .Read(ref _guid) .Read(ref _generations); if (_fileVersionUE4 >= UE4Version.VER_UE4_ENGINE_VERSION_OBJECT) { archive.Read(ref _savedByEngineVersion); } else { uint changelist = 0; archive.Read(ref changelist); _savedByEngineVersion = new EngineVersion(4, 0, 0, changelist, string.Empty); } if (_fileVersionUE4 >= UE4Version.VER_UE4_PACKAGE_SUMMARY_HAS_COMPATIBLE_ENGINE_VERSION) { archive.Read(ref _compatibleWithEngineVersion); } else { _compatibleWithEngineVersion = _savedByEngineVersion; } archive.Read(ref _compressionFlags) .Read(ref _compressedChunks); if (_compressedChunks.Count > 0) { throw new NotSupportedException("Package Level Compression is not supported by UE4 anymore."); } archive.Read(ref _packageSource); // No longer used: List of additional packages that are needed to be cooked for this package (ie streaming levels) // Keeping the serialization code for backwards compatibility without bumping the package version List <FString>?_additionalPackagesToCook = default; archive.Read(ref _additionalPackagesToCook); if (LegacyFileVersion > -7) { // Texture allocations no longer supported. int NumTextureAllocations = 0; archive.Read(ref NumTextureAllocations); } archive.Read(ref _assetRegistryDataOffset) .Read(ref _bulkDataStartOffset); if (_fileVersionUE4 >= UE4Version.VER_UE4_WORLD_LEVEL_INFO) { archive.Read(ref _worldTileInfoDataOffset); } if (_fileVersionUE4 >= UE4Version.VER_UE4_CHANGED_CHUNKID_TO_BE_AN_ARRAY_OF_CHUNKIDS) { archive.Read(ref _chunkIDs); } else if (_fileVersionUE4 >= UE4Version.VER_UE4_ADDED_CHUNKID_TO_ASSETDATA_AND_UPACKAGE) { archive.Read(ref _chunkIDs, 1); } if (_fileVersionUE4 >= UE4Version.VER_UE4_PRELOAD_DEPENDENCIES_IN_COOKED_EXPORTS) { archive.Read(ref _preloadDependencyCount) .Read(ref _preloadDependencyOffset); } return(archive); }
public override void Deserialize(FArchive reader, PropertyTag tag) => reader.Read(out _value);
public void Deserialize(FArchive reader) { reader.Read(out _x); reader.Read(out _y); }
public FPackageFileSummary(FArchive Ar) { Tag = Ar.Read <uint>(); LegacyFileVersion = Ar.Read <int>(); LegacyUE3Version = Ar.Read <int>(); FileVersionUE4 = Ar.Read <int>(); FileVersionLicenseUE4 = Ar.Read <int>(); CustomContainerVersion = Ar.ReadArray <FCustomVersion>(); TotalHeaderSize = Ar.Read <int>(); FolderName = Ar.ReadFString(); PackageFlags = Ar.Read <PackageFlags>(); NameCount = Ar.Read <int>(); NameOffset = Ar.Read <int>(); GatherableTextDataCount = Ar.Read <int>(); GatherableTextDataOffset = Ar.Read <int>(); ExportCount = Ar.Read <int>(); ExportOffset = Ar.Read <int>(); ImportCount = Ar.Read <int>(); ImportOffset = Ar.Read <int>(); DependsOffset = Ar.Read <int>(); SoftPackageReferencesCount = Ar.Read <int>(); SoftPackageReferencesOffset = Ar.Read <int>(); SearchableNamesOffset = Ar.Read <int>(); ThumbnailTableOffset = Ar.Read <int>(); if (Ar.Game == EGame.GAME_VALORANT) { Ar.Position += 8; } Guid = Ar.Read <FGuid>(); Generations = Ar.ReadArray <FGenerationInfo>(); SavedByEngineVersion = new FEngineVersion(Ar); CompatibleWithEngineVersion = new FEngineVersion(Ar); CompressionFlags = Ar.Read <uint>(); CompressedChunks = Ar.ReadArray <FCompressedChunk>(); PackageSource = Ar.Read <uint>(); AdditionalPackagesToCook = Ar.ReadArray(Ar.ReadFString); AssetRegistryDataOffset = Ar.Read <int>(); BulkDataStartOffset = Ar.Read <int>(); WorldTileInfoDataOffset = Ar.Read <int>(); ChunkIds = Ar.ReadArray <int>(); PreloadDependencyCount = Ar.Read <int>(); PreloadDependencyOffset = Ar.Read <int>(); }
public void Deserialize(FArchive reader) { ReadVersion(reader); reader.Read(out _localizationTable); }