public override void Deserialize(FAssetArchive Ar, long validPos)
        {
            base.Deserialize(Ar, validPos);

            var stripFlags = new FStripDataFlags(Ar);

            if (!stripFlags.IsDataStrippedForServer())
            {
                var numEntries = Ar.Read <int>();
                MeshBuildData = new Dictionary <FGuid, FMeshMapBuildData>(numEntries);
                for (var i = 0; i < numEntries; ++i)
                {
                    MeshBuildData[Ar.Read <FGuid>()] = new FMeshMapBuildData(Ar);
                }

                numEntries = Ar.Read <int>();
                LevelPrecomputedLightVolumeBuildData = new Dictionary <FGuid, FPrecomputedLightVolumeData>(numEntries);
                for (var i = 0; i < numEntries; ++i)
                {
                    LevelPrecomputedLightVolumeBuildData[Ar.Read <FGuid>()] = new FPrecomputedLightVolumeData(Ar);
                }

                if (FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.VolumetricLightmaps)
                {
                    numEntries = Ar.Read <int>();
                    LevelPrecomputedVolumetricLightmapBuildData = new Dictionary <FGuid, FPrecomputedVolumetricLightmapData>(numEntries);
                    for (var i = 0; i < numEntries; ++i)
                    {
                        LevelPrecomputedVolumetricLightmapBuildData[Ar.Read <FGuid>()] = new FPrecomputedVolumetricLightmapData(Ar);
                    }
                }

                numEntries     = Ar.Read <int>();
                LightBuildData = new Dictionary <FGuid, FLightComponentMapBuildData>(numEntries);
                for (var i = 0; i < numEntries; ++i)
                {
                    LightBuildData[Ar.Read <FGuid>()] = new FLightComponentMapBuildData(Ar);
                }

                if (FReflectionCaptureObjectVersion.Get(Ar) >= FReflectionCaptureObjectVersion.Type.MoveReflectionCaptureDataToMapBuildData)
                {
                    numEntries = Ar.Read <int>();
                    ReflectionCaptureBuildData = new Dictionary <FGuid, FReflectionCaptureMapBuildData>(numEntries);
                    for (var i = 0; i < numEntries; ++i)
                    {
                        ReflectionCaptureBuildData[Ar.Read <FGuid>()] = new FReflectionCaptureMapBuildData(Ar);
                    }
                }

                if (FRenderingObjectVersion.Get(Ar) >= FRenderingObjectVersion.Type.SkyAtmosphereStaticLightingVersioning)
                {
                    numEntries             = Ar.Read <int>();
                    SkyAtmosphereBuildData = new Dictionary <FGuid, FSkyAtmosphereMapBuildData>(numEntries);
                    for (var i = 0; i < numEntries; ++i)
                    {
                        SkyAtmosphereBuildData[Ar.Read <FGuid>()] = new FSkyAtmosphereMapBuildData(Ar);
                    }
                }
            }
        }
Example #2
0
        public FSkeletalMeshVertexColorBuffer(FAssetArchive Ar)
        {
            var stripDataFlags = new FStripDataFlags(Ar, (int)UE4Version.VER_UE4_STATIC_SKELETAL_MESH_SERIALIZATION_FIX);

            if (!stripDataFlags.IsDataStrippedForServer())
            {
                Data = Ar.ReadBulkArray <FColor>();
            }
            else
            {
                Data = new FColor[0];
            }
        }
        public FSkeletalMeshVertexClothBuffer(FArchive Ar)
        {
            var stripDataFlags = new FStripDataFlags(Ar, (int)UE4Version.VER_UE4_STATIC_SKELETAL_MESH_SERIALIZATION_FIX);

            if (stripDataFlags.IsDataStrippedForServer())
            {
                return;
            }

            Ar.SkipBulkArrayData();
            if (FSkeletalMeshCustomVersion.Get(Ar) >= FSkeletalMeshCustomVersion.Type.CompactClothVertexBuffer)
            {
                ClothIndexMapping = Ar.ReadArray <ulong>();
            }
        }
Example #4
0
        public FSkeletalMeshVertexClothBuffer(FArchive Ar)
        {
            var stripDataFlags = new FStripDataFlags(Ar, FPackageFileVersion.CreateUE4Version(EUnrealEngineObjectUE4Version.STATIC_SKELETAL_MESH_SERIALIZATION_FIX));

            if (stripDataFlags.IsDataStrippedForServer())
            {
                return;
            }

            Ar.SkipBulkArrayData();
            if (FSkeletalMeshCustomVersion.Get(Ar) >= FSkeletalMeshCustomVersion.Type.CompactClothVertexBuffer)
            {
                ClothIndexMapping = Ar.ReadArray <ulong>();
            }
        }
Example #5
0
        public FColorVertexBuffer(FArchive Ar)
        {
            var stripDataFlags = new FStripDataFlags(Ar, (int)UE4Version.VER_UE4_STATIC_SKELETAL_MESH_SERIALIZATION_FIX);

            Stride      = Ar.Read <int>();
            NumVertices = Ar.Read <int>();

            if (!stripDataFlags.IsDataStrippedForServer() & NumVertices > 0)
            {
                Data = Ar.ReadBulkArray <FColor>();
            }
            else
            {
                Data = new FColor[0];
            }
        }
Example #6
0
        public FColorVertexBuffer(FArchive Ar)
        {
            var stripDataFlags = new FStripDataFlags(Ar, FPackageFileVersion.CreateUE4Version(EUnrealEngineObjectUE4Version.STATIC_SKELETAL_MESH_SERIALIZATION_FIX));

            Stride      = Ar.Read <int>();
            NumVertices = Ar.Read <int>();

            if (!stripDataFlags.IsDataStrippedForServer() & NumVertices > 0)
            {
                Data = Ar.ReadBulkArray <FColor>();
            }
            else
            {
                Data = Array.Empty <FColor>();
            }
        }
Example #7
0
        private void SerializeInlineDataRepresentations(FAssetArchive Ar)
        {
            // Defined class flags for possible stripping
            const byte CardRepresentationDataStripFlag = 2;

            var stripFlags = new FStripDataFlags(Ar);

            if (!stripFlags.IsDataStrippedForServer() && !stripFlags.IsClassDataStripped(CardRepresentationDataStripFlag))
            {
                foreach (var lod in LODs)
                {
                    var bValid = Ar.ReadBoolean();
                    if (bValid)
                    {
                        lod.CardRepresentationData = new FCardRepresentationData(Ar);
                    }
                }
            }
        }
Example #8
0
        public FNaniteResources(FAssetArchive Ar)
        {
            var stripFlags = new FStripDataFlags(Ar);

            if (!stripFlags.IsDataStrippedForServer())
            {
                ResourceFlags          = Ar.Read <uint>();
                RootClusterPage        = Ar.ReadArray <byte>();
                StreamableClusterPages = new FByteBulkData(Ar);
                PageStreamingStates    = Ar.ReadArray <FPageStreamingState>();

                HierarchyNodes       = Ar.ReadArray(() => new FPackedHierarchyNode(Ar));
                HierarchyRootOffsets = Ar.ReadArray <uint>();
                PageDependencies     = Ar.ReadArray <uint>();
                ImposterAtlas        = Ar.ReadArray <ushort>();
                PositionPrecision    = Ar.Read <int>();
                NumInputTriangles    = Ar.Read <uint>();
                NumInputVertices     = Ar.Read <uint>();
                NumInputMeshes       = Ar.Read <ushort>();
                NumInputTexCoords    = Ar.Read <ushort>();
            }
        }
Example #9
0
        public FStaticMeshComponentLODInfo(FArchive Ar)
        {
            var stripFlags = new FStripDataFlags(Ar);

            if (!stripFlags.IsDataStrippedForServer())
            {
                MapBuildDataId = Ar.Read <FGuid>();
            }

            if (!stripFlags.IsClassDataStripped(OverrideColorsStripFlag))
            {
                var bLoadVertexColorData = Ar.Read <byte>();

                if (bLoadVertexColorData == 1)
                {
                    OverrideVertexColors = new FColorVertexBuffer(Ar);
                }
            }

            if (!stripFlags.IsEditorDataStripped())
            {
                PaintedVertices = Ar.ReadArray(() => new FPaintedVertex(Ar));
            }
        }
        public FSkeletalMeshVertexColorBuffer(FAssetArchive Ar)
        {
            var stripDataFlags = new FStripDataFlags(Ar, FPackageFileVersion.CreateUE4Version(EUnrealEngineObjectUE4Version.STATIC_SKELETAL_MESH_SERIALIZATION_FIX));

            Data = !stripDataFlags.IsDataStrippedForServer() ? Ar.ReadBulkArray <FColor>() : new FColor[0];
        }
Example #11
0
        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 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>();
            }
        }