예제 #1
0
        }                                                        // UMaterialInterface[]

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

            var stripDataFlags = Ar.Read <FStripDataFlags>();

            bCooked   = Ar.ReadBoolean();
            BodySetup = new FPackageIndex(Ar);
            if (Ar.Ver >= EUnrealEngineObjectUE4Version.STATIC_MESH_STORE_NAV_COLLISION)
            {
                NavCollision = new FPackageIndex(Ar);
            }

            if (!stripDataFlags.IsEditorDataStripped())
            {
                Log.Warning("Static Mesh with Editor Data not implemented yet");
                Ar.Position = validPos;
                return;
                // if (Ar.Ver < UE4Version.VER_UE4_DEPRECATED_STATIC_MESH_THUMBNAIL_PROPERTIES_REMOVED)
                // {
                //     var dummyThumbnailAngle = Ar.Read<FRotator>();
                //     var dummyThumbnailDistance = Ar.Read<float>();
                // }
                // var highResSourceMeshName = Ar.ReadFString();
                // var highResSourceMeshCRC = Ar.Read<uint>();
            }

            LightingGuid = Ar.Read <FGuid>(); // LocalLightingGuid
            Sockets      = Ar.ReadArray(() => new FPackageIndex(Ar));
            RenderData   = new FStaticMeshRenderData(Ar, bCooked);

            if (bCooked && Ar.Game is >= EGame.GAME_UE4_20 and < EGame.GAME_UE5_0)
            {
                var bHasOccluderData = Ar.ReadBoolean();
                if (bHasOccluderData)
                {
                    Ar.ReadArray <FVector>(); // Vertices
                    Ar.ReadArray <ushort>();  // Indices
                }
            }

            if (Ar.Game >= EGame.GAME_UE4_14)
            {
                var bHasSpeedTreeWind = Ar.ReadBoolean();
                if (bHasSpeedTreeWind)
                {
                    Ar.Position = validPos;
                    return;
                }

                if (FEditorObjectVersion.Get(Ar) >= FEditorObjectVersion.Type.RefactorMeshEditorMaterials)
                {
                    // UE4.14+ - "Materials" are deprecated, added StaticMaterials
                    StaticMaterials = Ar.ReadArray(() => new FStaticMaterial(Ar));
                }
            }

            if (StaticMaterials is { Length : > 0 })
예제 #2
0
        public override void Deserialize(FAssetArchive Ar, long validPos)
        {
            base.Deserialize(Ar, validPos);

            var stripDataFlags = Ar.Read <FStripDataFlags>();

            bCooked   = Ar.ReadBoolean();
            BodySetup = new FPackageIndex(Ar);
            if (Ar.Ver >= UE4Version.VER_UE4_STATIC_MESH_STORE_NAV_COLLISION)
            {
                NavCollision = new FPackageIndex(Ar);
            }

            if (!stripDataFlags.IsEditorDataStripped())
            {
                throw new NotImplementedException("Static Mesh with Editor Data not implemented yet");
                // if (Ar.Ver < UE4Version.VER_UE4_DEPRECATED_STATIC_MESH_THUMBNAIL_PROPERTIES_REMOVED)
                // {
                //     var dummyThumbnailAngle = Ar.Read<FRotator>();
                //     var dummyThumbnailDistance = Ar.Read<float>();
                // }
                // var highResSourceMeshName = Ar.ReadFString();
                // var highResSourceMeshCRC = Ar.Read<uint>();
            }

            LightingGuid = Ar.Read <FGuid>(); // LocalLightingGuid
            Sockets      = Ar.ReadArray(() => new FPackageIndex(Ar));
            RenderData   = new FStaticMeshRenderData(Ar, bCooked);

            if (bCooked & Ar.Game >= EGame.GAME_UE4_20)
            {
                var hasOccluderData = Ar.ReadBoolean();
                if (hasOccluderData)
                {
                    Ar.ReadArray <FVector>(); // Vertices
                    Ar.ReadArray <ushort>();  // Indics
                }
            }

            if (Ar.Game >= EGame.GAME_UE4_14)
            {
                var hasSpeedTreeWind = Ar.ReadBoolean();
                if (hasSpeedTreeWind)
                {
                    Ar.Seek(validPos, SeekOrigin.Begin);
                    return;
                }

                if (FEditorObjectVersion.Get(Ar) >= FEditorObjectVersion.Type.RefactorMeshEditorMaterials)
                {
                    // UE4.14+ - "Materials" are deprecated, added StaticMaterials
                    StaticMaterials = Ar.ReadArray(() => new FStaticMaterial(Ar));
                }
            }

            if (StaticMaterials != null && StaticMaterials.Length != 0)
            {
                Materials = new Lazy <UMaterialInterface?> [StaticMaterials.Length];
                for (var i = 0; i < Materials.Length; i++)
                {
                    Materials[i] = StaticMaterials[i].MaterialInterface;
                }
            }
        }