public FDistanceFieldVolumeData(FArchive Ar) { if (Ar.Game >= EGame.GAME_UE4_16) { CompressedDistanceFieldVolume = Ar.ReadArray <byte>(); Size = Ar.Read <FIntVector>(); LocalBoundingBox = Ar.Read <FBox>(); DistanceMinMax = Ar.Read <FVector2D>(); bMeshWasClosed = Ar.ReadBoolean(); bBuiltAsIfTwoSided = Ar.ReadBoolean(); bMeshWasPlane = Ar.ReadBoolean(); DistanceFieldVolume = new ushort[0]; } else { DistanceFieldVolume = Ar.ReadArray <ushort>(); Size = Ar.Read <FIntVector>(); LocalBoundingBox = Ar.Read <FBox>(); bMeshWasClosed = Ar.ReadBoolean(); bBuiltAsIfTwoSided = Ar.Ver >= EUnrealEngineObjectUE4Version.RENAME_CROUCHMOVESCHARACTERDOWN && Ar.ReadBoolean(); bMeshWasPlane = Ar.Ver >= EUnrealEngineObjectUE4Version.DEPRECATE_UMG_STYLE_ASSETS && Ar.ReadBoolean(); CompressedDistanceFieldVolume = new byte[0]; DistanceMinMax = new FVector2D(0f, 0f); } }
public FStaticComponentMaskParameter(FArchive Ar) : base(Ar) { R = Ar.ReadBoolean(); G = Ar.ReadBoolean(); B = Ar.ReadBoolean(); A = Ar.ReadBoolean(); bOverride = Ar.ReadBoolean(); ExpressionGuid = Ar.Read <FGuid>(); }
public FStaticTerrainLayerWeightParameter(FArchive Ar) : base(Ar) { if (FFortniteMainBranchObjectVersion.Get(Ar) >= FFortniteMainBranchObjectVersion.Type.StaticParameterTerrainLayerWeightBlendType) { bWeightBasedBlend = Ar.ReadBoolean(); } WeightmapIndex = Ar.Read <int>(); bOverride = Ar.ReadBoolean(); ExpressionGuid = Ar.Read <FGuid>(); }
public FLightmassPrimitiveSettings(FArchive Ar) { bUseTwoSidedLighting = Ar.ReadBoolean(); bShadowIndirectOnly = Ar.ReadBoolean(); FullyOccludedSamplesFraction = Ar.Read <float>(); bUseEmissiveForStaticLighting = Ar.ReadBoolean(); bUseVertexNormalForHemisphereGather = Ar.Ver >= EUnrealEngineObjectUE4Version.NEW_LIGHTMASS_PRIMITIVE_SETTING && Ar.ReadBoolean(); EmissiveLightFalloffExponent = Ar.Read <float>(); EmissiveLightExplicitInfluenceRadius = Ar.Read <float>(); EmissiveBoost = Ar.Read <float>(); DiffuseBoost = Ar.Read <float>(); }
public FRigVMRegister(FArchive Ar) { Type = Ar.Read <ERigVMRegisterType>(); ByteIndex = Ar.Read <uint>(); ElementSize = Ar.Read <ushort>(); ElementCount = Ar.Read <ushort>(); SliceIndex = Ar.Read <ushort>(); SliceCount = Ar.Read <ushort>(); AlignmentBytes = Ar.Read <byte>(); TrailingBytes = Ar.Read <ushort>(); Name = Ar.ReadFName(); ScriptStructIndex = Ar.Read <int>(); bIsArray = Ar.ReadBoolean(); bIsDynamic = Ar.ReadBoolean(); }
public FMorphTargetLODModel(FArchive Ar) { Vertices = Ar.ReadArray(() => new FMorphTargetDelta(Ar)); NumBaseMeshVerts = Ar.Read <int>(); SectionIndices = Ar.ReadArray <int>(); bGeneratedByEngine = Ar.ReadBoolean(); }
public FStaticMeshSection(FArchive Ar) { MaterialIndex = Ar.Read <int>(); FirstIndex = Ar.Read <int>(); NumTriangles = Ar.Read <int>(); MinVertexIndex = Ar.Read <int>(); MaxVertexIndex = Ar.Read <int>(); EnableCollision = Ar.ReadBoolean(); CastShadow = Ar.ReadBoolean(); ForceOpaque = FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.StaticMeshSectionForceOpaqueField && Ar.ReadBoolean(); VisibleInRayTracing = Ar.Game >= EGame.GAME_UE4_26 && Ar.ReadBoolean(); if (Ar.Game == EGame.GAME_ROGUECOMPANY) { Ar.Position += 4; } }
public FMovieSceneSegment(FArchive Ar) { Range = Ar.Read <TRange <FFrameNumber> >(); ID = Ar.Read <FMovieSceneSegmentIdentifier>(); bAllowEmpty = Ar.ReadBoolean(); Impls = Ar.ReadArray <FSectionEvaluationData>(); }
public FPrecomputedLightVolumeData(FArchive Ar) { var bValid = Ar.ReadBoolean(); if (bValid) { Volume = new FPrecomputedLightVolumeData(Ar); // It serializes itself? } }
public FURL(FArchive Ar) { Protocol = Ar.ReadFString(); Host = Ar.ReadFString(); Map = Ar.ReadFString(); Portal = Ar.ReadFString(); Op = Ar.ReadArray(Ar.ReadFString); Port = Ar.Read <int>(); Valid = Ar.ReadBoolean(); }
public FStaticMaterialLayersParameter(FArchive Ar) { ParameterInfo = new FMaterialParameterInfo(Ar); bOverride = Ar.ReadBoolean(); ExpressionGuid = Ar.Read <FGuid>(); if (FReleaseObjectVersion.Get(Ar) >= FReleaseObjectVersion.Type.MaterialLayersParameterSerializationRefactor) { Value = new FMaterialLayersFunctions(Ar); } }
public FStaticMeshSection(FArchive Ar) { MaterialIndex = Ar.Read <int>(); FirstIndex = Ar.Read <int>(); NumTriangles = Ar.Read <int>(); MinVertexIndex = Ar.Read <int>(); MaxVertexIndex = Ar.Read <int>(); bEnableCollision = Ar.ReadBoolean(); bCastShadow = Ar.ReadBoolean(); if (Ar.Game == EGame.GAME_PlayerUnknownsBattlegrounds) { Ar.Position += 5; // byte + int } bForceOpaque = FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.StaticMeshSectionForceOpaqueField && Ar.ReadBoolean(); bVisibleInRayTracing = !Ar.Versions["StaticMesh.HasVisibleInRayTracing"] || Ar.ReadBoolean(); if (Ar.Game == EGame.GAME_RogueCompany) { Ar.Position += 4; } }
public FPerQualityLevelInt(FArchive Ar) { bCooked = Ar.ReadBoolean(); Default = Ar.Read <int>(); PerQuality = new Dictionary <int, int>(); int perQualityNum = Ar.Read <int>(); for (int i = 0; i < perQualityNum; i++) { PerQuality[Ar.Read <int>()] = Ar.Read <int>(); } }
public FRawStaticIndexBuffer(FArchive Ar) : this() { if (Ar.Ver < EUnrealEngineObjectUE4Version.SUPPORT_32BIT_STATIC_MESH_INDICES) { Indices16 = Ar.ReadBulkArray <ushort>(); } else { var is32bit = Ar.ReadBoolean(); var data = Ar.ReadBulkArray <byte>(); var tempAr = new FByteArchive("IndicesReader", data, Ar.Versions); if (Ar.Versions["RawIndexBuffer.HasShouldExpandTo32Bit"]) { var bShouldExpandTo32Bit = Ar.ReadBoolean(); } if (tempAr.Length == 0) { tempAr.Dispose(); return; } if (is32bit) { var count = (int)tempAr.Length / 4; Indices32 = tempAr.ReadArray <uint>(count); } else { var count = (int)tempAr.Length / 2; Indices16 = tempAr.ReadArray <ushort>(count); } tempAr.Dispose(); } }
public FRawStaticIndexBuffer(FArchive Ar) : this() { if (Ar.Ver < UE4Version.VER_UE4_SUPPORT_32BIT_STATIC_MESH_INDICES) { Indices16 = Ar.ReadBulkArray <ushort>(); } else { var is32bit = Ar.ReadBoolean(); var data = Ar.ReadBulkArray <byte>(); var tempAr = new FByteArchive("IndicesReader", data, Ar.Versions); if (Ar.Game >= EGame.GAME_UE4_25) { Ar.Position += 4; } if (tempAr.Length == 0) { tempAr.Dispose(); return; } if (is32bit) { var count = (int)tempAr.Length / 4; Indices32 = tempAr.ReadArray <uint>(count); } else { var count = (int)tempAr.Length / 2; Indices16 = tempAr.ReadArray <ushort>(count); } tempAr.Dispose(); } }
public PlayerNameData(FArchive archive) { Handle = archive.ReadByte(); Unknown1 = archive.ReadByte(); IsPlayer = archive.ReadBoolean(); EncodedName = archive.ReadFString(); string decodedName = String.Empty; if (IsPlayer) { for (int i = 0; i < EncodedName.Length; i++) { int shift = (EncodedName.Length % 4 * 3 % 8 + 1 + i) * 3 % 8; decodedName += (char)(EncodedName[i] + shift); } DecodedName = decodedName; } else { DecodedName = EncodedName; } }
public FMeshUVChannelInfo(FArchive Ar) { bInitialized = Ar.ReadBoolean(); bOverrideDensities = Ar.ReadBoolean(); LocalUVDensities = Ar.ReadArray <float>(TEXSTREAM_MAX_NUM_UVCHANNELS); }
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 WwiseReader(FArchive Ar) { IdToString = new Dictionary <uint, string>(); WwiseEncodedMedias = new Dictionary <string, byte[]>(); while (Ar.Position < Ar.Length) { var sectionIdentifier = Ar.Read <ESectionIdentifier>(); var sectionLength = Ar.Read <int>(); var position = Ar.Position; switch (sectionIdentifier) { case ESectionIdentifier.AKPK: if (!Ar.ReadBoolean()) { throw new ParserException(Ar, $"'{Ar.Name}' has unsupported endianness."); } Ar.Position += 16; Folders = Ar.ReadArray(() => new AkFolder(Ar)); foreach (var folder in Folders) { folder.PopulateName(Ar); } foreach (var folder in Folders) { folder.Entries = new AkEntry[Ar.Read <uint>()]; for (var i = 0; i < folder.Entries.Length; i++) { var entry = new AkEntry(Ar); entry.Path = Folders[entry.FolderId].Name; var savePos = Ar.Position; Ar.Position = entry.Offset; entry.IsSoundBank = Ar.Read <ESectionIdentifier>() == ESectionIdentifier.BKHD; Ar.Position -= 4; entry.Data = Ar.ReadBytes(entry.Size); Ar.Position = savePos; folder.Entries[i] = entry; } } break; case ESectionIdentifier.BKHD: Header = Ar.Read <BankHeader>(); break; case ESectionIdentifier.INIT: Initialization = Ar.ReadArray(() => { Ar.Position += 4; return(Ar.ReadFString()); }); break; case ESectionIdentifier.DIDX: WemIndexes = Ar.ReadArray(sectionLength / 12, Ar.Read <DataIndex>); break; case ESectionIdentifier.DATA: if (WemIndexes == null) { break; } WemSounds = new byte[WemIndexes.Length][]; for (var i = 0; i < WemSounds.Length; i++) { Ar.Position = position + WemIndexes[i].Offset; WemSounds[i] = Ar.ReadBytes(WemIndexes[i].Length); WwiseEncodedMedias[WemIndexes[i].Id.ToString()] = WemSounds[i]; } break; case ESectionIdentifier.HIRC: Hierarchy = Ar.ReadArray(() => new Hierarchy(Ar)); break; case ESectionIdentifier.RIFF: // read byte[sectionLength] it's simply a wem file break; case ESectionIdentifier.STID: Ar.Position += 4; var count = Ar.Read <int>(); for (var i = 0; i < count; i++) { IdToString[Ar.Read <uint>()] = Ar.ReadString(); } break; case ESectionIdentifier.STMG: break; case ESectionIdentifier.ENVS: break; case ESectionIdentifier.FXPR: break; case ESectionIdentifier.PLAT: Platform = Ar.ReadFString(); break; default: #if DEBUG Log.Warning($"Unknown section {sectionIdentifier:X} at {position - sizeof(uint) - sizeof(uint)}"); #endif break; } if (Ar.Position != position + sectionLength) { var shouldBe = position + sectionLength; #if DEBUG Log.Warning($"Didn't read 0x{sectionIdentifier:X} correctly (at {Ar.Position}, should be {shouldBe})"); #endif Ar.Position = shouldBe; } } if (Folders != null) { foreach (var folder in Folders) { foreach (var entry in folder.Entries) { if (entry.IsSoundBank || entry.Data == null) { continue; } WwiseEncodedMedias[IdToString.TryGetValue(entry.NameHash, out var k) ? k : $"{entry.Path.ToUpper()}_{entry.NameHash}"] = entry.Data;
public readonly FStaticMeshUVItem[] UV; // TangentsData ? public FStaticMeshVertexBuffer(FArchive Ar) { var stripDataFlags = new FStripDataFlags(Ar, (int)UE4Version.VER_UE4_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 { // 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}"); } var 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}"); } 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++) { UV[i] = new FStaticMeshUVItem(tempTangents[i], uv[i]); } } } else { UV = new FStaticMeshUVItem[0]; } }
public FSkinWeightVertexBuffer(FArchive Ar, bool numSkelCondition) { var bNewWeightFormat = FAnimObjectVersion.Get(Ar) >= FAnimObjectVersion.Type.UnlimitedBoneInfluences; #region FSkinWeightDataVertexBuffer var dataStripFlags = Ar.Read <FStripDataFlags>(); #region FSkinWeightDataVertexBuffer::SerializeMetaData bool bVariableBonesPerVertex; bool bExtraBoneInfluences; uint maxBoneInfluences; bool bUse16BitBoneIndex; uint numVertices; uint numBones; if (Ar.Game < EGame.GAME_UE4_24) { bExtraBoneInfluences = Ar.ReadBoolean(); numVertices = Ar.Read <uint>(); maxBoneInfluences = bExtraBoneInfluences ? 8u : 4u; } else if (!bNewWeightFormat) { bExtraBoneInfluences = Ar.ReadBoolean(); if (FSkeletalMeshCustomVersion.Get(Ar) >= FSkeletalMeshCustomVersion.Type.SplitModelAndRenderData) { Ar.Position += 4; // var stride = Ar.Read<uint>(); } numVertices = Ar.Read <uint>(); maxBoneInfluences = bExtraBoneInfluences ? 8u : 4u; numBones = maxBoneInfluences * numVertices; bVariableBonesPerVertex = false; } else { bVariableBonesPerVertex = Ar.ReadBoolean(); maxBoneInfluences = Ar.Read <uint>(); numBones = Ar.Read <uint>(); numVertices = Ar.Read <uint>(); bExtraBoneInfluences = maxBoneInfluences > _NUM_INFLUENCES_UE4; // bUse16BitBoneIndex doesn't exist before version IncreaseBoneIndexLimitPerChunk if (FAnimObjectVersion.Get(Ar) >= FAnimObjectVersion.Type.IncreaseBoneIndexLimitPerChunk) { bUse16BitBoneIndex = Ar.ReadBoolean(); } } #endregion byte[] newData = Array.Empty <byte>(); if (!dataStripFlags.IsDataStrippedForServer()) { if (!bNewWeightFormat) { Weights = Ar.ReadBulkArray(() => new FSkinWeightInfo(Ar, bExtraBoneInfluences)); } else { newData = Ar.ReadBulkArray <byte>(); } } else { bExtraBoneInfluences = numSkelCondition; } #endregion if (bNewWeightFormat) { #region FSkinWeightLookupVertexBuffer var lookupStripFlags = Ar.Read <FStripDataFlags>(); #region FSkinWeightLookupVertexBuffer::SerializeMetaData //if (bNewWeightFormat) //{ var numLookupVertices = Ar.Read <int>(); //} #endregion if (!lookupStripFlags.IsDataStrippedForServer()) { Ar.ReadBulkArray <uint>(); // LookupData } #endregion // Convert influence data if (newData.Length > 0) { using var tempAr = new FByteArchive("WeightsReader", newData, Ar.Versions); Weights = new FSkinWeightInfo[numVertices]; for (var i = 0; i < Weights.Length; i++) { Weights[i] = new FSkinWeightInfo(tempAr, bExtraBoneInfluences); } } } }
public FStaticSwitchParameter(FArchive Ar) : base(Ar) { Value = Ar.ReadBoolean(); bOverride = Ar.ReadBoolean(); ExpressionGuid = Ar.Read <FGuid>(); }
public FAnimCurveType(FArchive Ar) { bMaterial = Ar.ReadBoolean(); bMorphtarget = Ar.ReadBoolean(); }