Пример #1
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            TerrainData.Read(reader);
            TreeDistance            = reader.ReadSingle();
            TreeBillboardDistance   = reader.ReadSingle();
            TreeCrossFadeLength     = reader.ReadSingle();
            TreeMaximumFullLODCount = reader.ReadInt32();
            DetailObjectDistance    = reader.ReadSingle();
            DetailObjectDensity     = reader.ReadSingle();
            HeightmapPixelError     = reader.ReadSingle();
            SplatMapDistance        = reader.ReadSingle();
            HeightmapMaximumLOD     = reader.ReadInt32();
            if (HasShadowCastingMode(reader.Version))
            {
                ShadowCastingMode = (ShadowCastingMode)reader.ReadInt32();
            }
            else
            {
                bool CastShadows = reader.ReadBoolean();
                ShadowCastingMode = CastShadows ? ShadowCastingMode.TwoSided : ShadowCastingMode.Off;
            }
            if (HasDrawHeightmap(reader.Version))
            {
                DrawHeightmap = reader.ReadBoolean();
            }
            if (HasDrawInstanced(reader.Version))
            {
                DrawInstanced = reader.ReadBoolean();
            }
            DrawTreesAndFoliage = reader.ReadBoolean();
            reader.AlignStream();

            if (HasReflectionProbeUsage(reader.Version))
            {
                ReflectionProbeUsage = (ReflectionProbeUsage)reader.ReadInt32();
            }
            if (HasMaterialType(reader.Version))
            {
                MaterialType = (MaterialType)reader.ReadInt32();
                LegacySpecular.Read(reader);
                LegacyShininess = reader.ReadSingle();
            }
            if (HasDefaultSmoothness(reader.Version))
            {
                UseDefaultSmoothness = reader.ReadBoolean();
                DefaultSmoothness    = reader.ReadSingle();
            }
            MaterialTemplate.Read(reader);
            if (HasLightmapIndex(reader.Flags))
            {
                LightmapIndex        = reader.ReadUInt16();
                LightmapIndexDynamic = reader.ReadUInt16();
                LightmapTilingOffset.Read(reader);
                LightmapTilingOffsetDynamic.Read(reader);
            }
            if (HasExplicitProbeSetHash(reader.Version, reader.Flags))
            {
                ExplicitProbeSetHash.Read(reader);
            }

            if (HasBakeLightProbesForTrees(reader.Version))
            {
                BakeLightProbesForTrees = reader.ReadBoolean();
            }
            if (HasPreserveTreePrototypeLayers(reader.Version))
            {
                PreserveTreePrototypeLayers = reader.ReadBoolean();
            }
            if (HasDeringLightProbesForTrees(reader.Version, reader.Flags))
            {
                DeringLightProbesForTrees = reader.ReadBoolean();
            }
            if (IsAlign(reader.Version))
            {
                reader.AlignStream();
            }
#if UNIVERSAL
            if (HasScaleInLightmap(reader.Flags))
            {
                ScaleInLightmap = reader.ReadSingle();
                LightmapParameters.Read(reader);
            }
#endif
            if (HasDynamicUVST(reader.Version, reader.Flags))
            {
                DynamicUVST.Read(reader);
                ChunkDynamicUVST.Read(reader);
                reader.AlignStream();
            }
            if (HasGroupingID(reader.Version))
            {
                GroupingID       = reader.ReadInt32();
                AllowAutoConnect = reader.ReadBoolean();
            }
        }
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.AddSerializedVersion(ToSerializedVersion(container.ExportVersion));
            node.Add(TerrainDataName, TerrainData.ExportYAML(container));
            node.Add(TreeDistanceName, TreeDistance);
            node.Add(TreeBillboardDistanceName, TreeBillboardDistance);
            node.Add(TreeCrossFadeLengthName, TreeCrossFadeLength);
            node.Add(TreeMaximumFullLODCountName, TreeMaximumFullLODCount);
            node.Add(DetailObjectDistanceName, DetailObjectDistance);
            node.Add(DetailObjectDensityName, DetailObjectDensity);
            node.Add(HeightmapPixelErrorName, HeightmapPixelError);
            node.Add(SplatMapDistanceName, SplatMapDistance);
            node.Add(HeightmapMaximumLODName, HeightmapMaximumLOD);
            if (HasShadowCastingMode(container.ExportVersion))
            {
                node.Add(ShadowCastingModeName, (int)ShadowCastingMode);
            }
            else
            {
                node.Add(CastShadowsName, CastShadows);
            }
            node.Add(DrawHeightmapName, DrawHeightmap);
            if (HasDrawInstanced(container.ExportVersion))
            {
                node.Add(DrawInstancedName, DrawInstanced);
            }
            node.Add(DrawTreesAndFoliageName, DrawTreesAndFoliage);
            node.Add(ReflectionProbeUsageName, (int)ReflectionProbeUsage);
            if (HasMaterialType(container.ExportVersion))
            {
                node.Add(MaterialTypeName, (int)GetMaterialType(container.Version));
                node.Add(LegacySpecularName, LegacySpecular.ExportYAML(container));
                node.Add(LegacyShininessName, LegacyShininess);
            }
            node.Add(MaterialTemplateName, ExportMaterialTemplate(container));
            node.Add(BakeLightProbesForTreesName, BakeLightProbesForTrees);
            if (HasPreserveTreePrototypeLayers(container.ExportVersion))
            {
                node.Add(PreserveTreePrototypeLayersName, PreserveTreePrototypeLayers);
            }
            if (HasDeringLightProbesForTrees(container.ExportVersion, container.ExportFlags))
            {
                node.Add(DeringLightProbesForTreesName, GetDeringLightProbesForTrees(container.Version, container.Flags));
            }
#warning TODO: get lightmap by index and fill those values
            node.Add(ScaleInLightmapName, GetScaleInLightmap(container.Flags));
            node.Add(LightmapParametersName, GetLightmapParameters(container.Flags).ExportYAML(container));
            if (HasGroupingID(container.ExportVersion))
            {
                node.Add(GroupingIDName, GroupingID);
            }
            if (HasRenderingLayerMask(container.ExportVersion))
            {
                node.Add(RenderingLayerMaskName, GetRenderingLayerMask(container.Version));
            }
            if (HasGroupingID(container.ExportVersion))
            {
                node.Add(AllowAutoConnectName, AllowAutoConnect);
            }
            return(node);
        }