private void ExportNormal() { if (Terrain.activeTerrain == null) { EditorUtility.DisplayDialog("OOPS!", "You must have a valid terrain in your scene!!", "OK"); return; } GaiaWorldManager mgr = new GaiaWorldManager(Terrain.activeTerrains); if (mgr.TileCount > 0) { string path = "Assets/GaiaMasks/"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } mgr.LoadFromWorld(); path = Path.Combine(path, Gaia.Utils.FixFileName(m_maskName)); mgr.ExportNormalmapAsPng(path); AssetDatabase.Refresh(); EditorUtility.DisplayDialog("Export complete", " Your normal map has been saved to : " + path, "OK"); } }
void OnGUI() { //Set up the box style if (m_boxStyle == null) { m_boxStyle = new GUIStyle(GUI.skin.box); m_boxStyle.normal.textColor = GUI.skin.label.normal.textColor; m_boxStyle.fontStyle = FontStyle.Bold; m_boxStyle.alignment = TextAnchor.UpperLeft; } //Setup the wrap style if (m_wrapStyle == null) { m_wrapStyle = new GUIStyle(GUI.skin.label); m_wrapStyle.fontStyle = FontStyle.Normal; m_wrapStyle.wordWrap = true; } //Text intro GUILayout.BeginVertical("Gaia Terrain Height Adjuster", m_boxStyle); GUILayout.Space(20); EditorGUILayout.LabelField("The terrain height adjuster allows you to set the height of the terrains in your scene to the given height.", m_wrapStyle); GUILayout.EndVertical(); Terrain terrain = Gaia.TerrainHelper.GetActiveTerrain(); if (terrain != null) { m_maxTerrainHeight = terrain.terrainData.size.y; } m_terrainHeight = EditorGUILayout.Slider(GetLabel("New Terrain Height (m)"), m_terrainHeight, 0f, m_maxTerrainHeight); GUILayout.Space(5); EditorGUI.indentLevel++; if (DisplayButton(GetLabel("Adjust Terrain Heights"))) { if (terrain == null) { EditorUtility.DisplayDialog("OOPS!", "You must have at least one active terrain in your scene to use this feature!", "OK"); return; } GaiaWorldManager mgr = new GaiaWorldManager(Terrain.activeTerrains); mgr.LoadFromWorld(); mgr.SetHeightWU(m_terrainHeight); mgr.SaveToWorld(); } EditorGUI.indentLevel--; }
private void ExportNormal() { if (Terrain.activeTerrain == null) { EditorUtility.DisplayDialog("OOPS!", "You must have a valid terrain in your scene!!", "OK"); return; } GaiaWorldManager mgr = new GaiaWorldManager(Terrain.activeTerrains); if (mgr.TileCount > 0) { GaiaSessionManager gsm = GaiaSessionManager.GetSessionManager(); string path = GaiaDirectories.GetExportDirectory(gsm.m_session); mgr.LoadFromWorld(); path = Path.Combine(path, PWCommon4.Utils.FixFileName(m_maskName)); mgr.ExportNormalmapAsPng(path); AssetDatabase.Refresh(); EditorUtility.DisplayDialog("Export complete", " Your normal map has been saved to : " + path, "OK"); } }
void OnGUI() { //Set up the box style if (m_boxStyle == null) { m_boxStyle = new GUIStyle(GUI.skin.box); m_boxStyle.normal.textColor = GUI.skin.label.normal.textColor; m_boxStyle.fontStyle = FontStyle.Bold; m_boxStyle.alignment = TextAnchor.UpperLeft; } //Setup the wrap style if (m_wrapStyle == null) { m_wrapStyle = new GUIStyle(GUI.skin.label); m_wrapStyle.fontStyle = FontStyle.Normal; m_wrapStyle.wordWrap = true; } //Text intro GUILayout.BeginVertical("Gaia WaterFlow Mask Exporter", m_boxStyle); GUILayout.Space(20); EditorGUILayout.LabelField("The Gaia waterflow exporter allows you to calculate and export a water flow mask from your terrain.", m_wrapStyle); GUILayout.EndVertical(); if (string.IsNullOrEmpty(m_maskName)) { m_maskName = string.Format("TerrainWaterFlow-{0:yyyyMMdd-HHmmss}", DateTime.Now); } m_maskName = EditorGUILayout.TextField(GetLabel("Mask Name"), m_maskName); m_waterFlowMap.m_dropletVolume = EditorGUILayout.Slider(GetLabel("Droplet Volume"), m_waterFlowMap.m_dropletVolume, 0.1f, 2f); m_waterFlowMap.m_dropletAbsorbtionRate = EditorGUILayout.Slider(GetLabel("Droplet Absorbtion Rate"), m_waterFlowMap.m_dropletAbsorbtionRate, 0.01f, 1f); m_waterFlowMap.m_waterflowSmoothIterations = EditorGUILayout.IntSlider(GetLabel("Smooth Iterations"), m_waterFlowMap.m_waterflowSmoothIterations, 0, 10); GUILayout.Space(5); EditorGUI.indentLevel++; if (DisplayButton(GetLabel("Create Mask"))) { Terrain terrain = Gaia.TerrainHelper.GetActiveTerrain(); if (terrain == null) { EditorUtility.DisplayDialog("OOPS!", "You must have a valid terrain!!", "OK"); return; } GaiaSessionManager gsm = GaiaSessionManager.GetSessionManager(); string path = GaiaDirectories.GetExportDirectory(gsm.m_session); path = Path.Combine(path, PWCommon4.Utils.FixFileName(m_maskName)); m_waterFlowMap.CreateWaterFlowMap(terrain); m_waterFlowMap.ExportWaterMapToPath(path); GaiaWorldManager mgr = new GaiaWorldManager(Terrain.activeTerrains); mgr.LoadFromWorld(); path += "WaterFlow"; mgr.ExportWaterflowMapAsPng(m_waterFlowMap.m_waterflowSmoothIterations, path); AssetDatabase.Refresh(); EditorUtility.DisplayDialog("Done!", "Your mask is available at " + path, "OK"); } EditorGUI.indentLevel--; }