// Copyright © 2018 Procedural Worlds Pty Limited. All Rights Reserved. using UnityEngine; using System.Collections.Generic; /* * Scriptable Object containing settings for a stamper */ namespace Gaia { /// Contains information about a Sequence of clips to play and how [CreateAssetMenu(menuName = "Procedural Worlds/Gaia/Stamper Settings")] [System.Serializable] public class StamperSettings : ScriptableObject, ISerializationCallbackReceiver { #region Public Variables /// /// Stamp x location - done this way to expose in the editor as a simple slider /// public double m_x = 0; /// /// Stamp y location - done this way to expose in the editor as a simple slider /// public double m_y = 50; /// /// Stamp z location - done this way to expose in the editor as a simple slider /// public double m_z = 0; /// /// Are these stamper settings folded out when viewed in an editor? /// public bool m_isFoldedOut; /// /// Stamp width - this is the horizontal scaling factor - applied to both x & z /// public float m_width = 10f; /// /// Stamp height - this is the vertical scaling factor /// public float m_height = 10f; /// /// Stamp rotation /// public float m_rotation = 0f; /// /// Is this stamper intended to be used on world map terrains? /// public bool m_isWorldmapStamper = false; /// /// The current operation that the stamper will perform on the terrain when pressing the stamp button /// public GaiaConstants.FeatureOperation m_operation = GaiaConstants.FeatureOperation.RaiseHeight; /// /// The ground / base level - value in 0..1 that determines where the base of the stamp is as a % pf overall stamp height. /// Initially loaded from scanned value stored in the stamp, but can be overridden. /// public float m_baseLevel = 0f; /// /// Whether or not to draw any portion of the stamp below the base level of the stamp /// public bool m_drawStampBase = true; /// /// Should the base level adapt itself to the existing shape of the terrain? /// public bool m_adaptiveBase = false; /// /// size of the increased features when using Effects>Contrast /// public float m_contrastFeatureSize = 10; /// /// strength of the contrast effect when using Effects>Contrast /// public float m_contrastStrength = 2; /// /// size of the features being included in a terrace when using Effects>Terraces /// public float m_terraceCount = 100f; /// /// Added Jitter when using Effects>Terraces /// public float m_terraceJitterCount = 0.5f; /// /// Bevel Amount when using Effects>Terraces /// public float m_terraceBevelAmountInterior; /// /// Sharpness when using Effects>Sharpen Ridges /// public float m_sharpenRidgesMixStrength = 0.5f; /// /// Erosion Amount when using Effects>Sharpen Ridges /// public float m_sharpenRidgesIterations = 16f; public float m_powerOf; public float m_smoothVerticality = 0f; public float m_smoothBlurRadius = 10f; /// /// A fixed Image masked used as input for some of the operations. /// public ImageMask m_stamperInputImageMask = new ImageMask(); /// /// The mix level of the stamp for the mix height operation. /// public float m_mixMidPoint = 0.5f; /// /// The strength of the mix height operation. /// public float m_mixHeightStrength = 0.5f; public GaiaConstants.AutoSpawnerArea m_autoSpawnerArea = GaiaConstants.AutoSpawnerArea.Local; public GaiaConstants.AutoSpawnerArea m_autoMaskExportArea = GaiaConstants.AutoSpawnerArea.Local; /// /// height transform curve when using Effects > Height Transform /// public AnimationCurve m_heightTransformCurve = ImageMask.NewAnimCurveStraightUpwards(); #region Erosion Settings public float m_erosionSimScale = 0.5f; public float m_erosionHydroTimeDelta = 0.07f; public int m_erosionHydroIterations = 10; public float m_erosionThermalTimeDelta = 0.01f; public int m_erosionThermalIterations = 8; public int m_erosionThermalReposeAngle = 80; public float m_erosionPrecipRate = 0.5f; public float m_erosionEvaporationRate = 0.5f; public float m_erosionFlowRate = 0.5f; public float m_erosionSedimentCapacity = 0.5f; public float m_erosionSedimentDepositRate = 0.8f; public float m_erosionSedimentDissolveRate = 0.5f; public float m_erosionRiverBankDepositRate = 7.0f; public float m_erosionRiverBankDissolveRate = 5.0f; public float m_erosionRiverBedDepositRate = 5.0f; public float m_erosionRiverBedDissolveRate = 5.0f; #endregion //All image filters that are being applied in this stamping process public ImageMask[] m_imageMasks = new ImageMask[0]; /// /// Removes References to Texture2Ds in Image masks. The image mask will still remember the GUID of that texture to load it when needed. /// Call this when you are "done" with the stamper settings to free up memory caused by these references. /// public void ClearImageMaskTextures() { m_stamperInputImageMask.FreeTextureReferences(); if (m_imageMasks != null) { foreach (ImageMask im in m_imageMasks) { im.FreeTextureReferences(); } } Resources.UnloadUnusedAssets(); } private void OnDestroy() { ClearImageMaskTextures(); } #endregion #region Serialization public void OnBeforeSerialize() { } public void OnAfterDeserialize() { //if (m_clipData != null && m_clipData.Length > 0) //{ // m_clipData = new ClipData[m_clips.Length]; // for (int i = 0; i < m_clips.Length; ++i) // { // m_clipData[i] = new ClipData(m_clips[i], 1f); // } // m_clips = null; //} } #endregion } }