private void DoImport() { if (DesTerrain != null) { GBackup.TryCreateInitialBackup(HISTORY_PREFIX, DesTerrain, GCommon.AllResourceFlags); } GUnityTerrainDataImporter importer = new GUnityTerrainDataImporter(); importer.SrcTerrain = SrcTerrain; importer.SrcData = SrcData; importer.DesData = DesData; importer.DesTerrain = DesTerrain; importer.ImportGeometry = ImportGeometry; importer.UseUnityTerrainSize = UseUnityTerrainSize; importer.ImportSplats = ImportSplats; importer.ImportSplatsAsAlbedo = ImportSplatsAsAlbedo; importer.CreateNewSplatPrototypesGroup = CreateNewSplatPrototypesGroup; importer.ImportTrees = ImportTrees; importer.CreateNewTreePrototypesGroup = CreateNewTreePrototypesGroup; importer.ImportGrasses = ImportGrasses; importer.CreateNewGrassPrototypesGroup = CreateNewGrassPrototypesGroup; importer.GrassDensity = GrassDensity; importer.Import(); if (DesTerrain != null) { GBackup.TryCreateBackup(HISTORY_PREFIX, DesTerrain, GCommon.AllResourceFlags); } }
private void Editor_CreateInitialHistoryEntry(GFoliagePainterArgs args) { if (!Editor_EnableHistory) { return; } List <GTerrainResourceFlag> flags = new List <GTerrainResourceFlag>(); flags.AddRange(ActivePainter.GetResourceFlagForHistory(args)); GBackup.TryCreateInitialBackup(ActivePainter.HistoryPrefix, GroupId, ActivePainter.GetResourceFlagForHistory(args), false); }
private void DoBulkImport() { string[] guid = AssetDatabase.FindAssets("t:Texture2D", new string[] { Directory }); List <Texture2D> textures = new List <Texture2D>(); for (int i = 0; i < guid.Length; ++i) { string path = AssetDatabase.GUIDToAssetPath(guid[i]); Texture2D tex = AssetDatabase.LoadAssetAtPath <Texture2D>(path); textures.Add(tex); } GCommon.ForEachTerrain( BulkImportGroupId, (t) => { if (t == null || t.TerrainData == null) { return; } GBackup.TryCreateInitialBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags); Texture2D hm = textures.Find(tex => tex.name.StartsWith("HeightMap") && tex.name.EndsWith(t.TerrainData.Id)); Texture2D mkm = textures.Find(tex => tex.name.StartsWith("MaskMap") && tex.name.EndsWith(t.TerrainData.Id)); Texture2D vm = textures.Find(tex => tex.name.StartsWith("VisibilityMap") && tex.name.EndsWith(t.TerrainData.Id)); Texture2D am = textures.Find(tex => tex.name.StartsWith("AlbedoMap") && tex.name.EndsWith(t.TerrainData.Id)); Texture2D mm = textures.Find(tex => tex.name.StartsWith("MetallicMap") && tex.name.EndsWith(t.TerrainData.Id)); Texture2D[] cm = new Texture2D[t.TerrainData.Shading.SplatControlMapCount]; for (int i = 0; i < cm.Length; ++i) { cm[i] = textures.Find(tex => tex.name.StartsWith("ControlMap" + i.ToString()) && tex.name.EndsWith(t.TerrainData.Id)); } GTextureImporter importer = new GTextureImporter(); importer.Terrain = t; importer.DesData = t.TerrainData; importer.HeightMap = hm; importer.MaskMap = mkm; importer.VisibilityMap = vm; importer.AlbedoMap = am; importer.MetallicMap = mm; importer.SplatControlMaps = cm; importer.Import(); GBackup.TryCreateBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags); }); GStylizedTerrain.MatchEdges(BulkImportGroupId); }
private void CreateInitialBackup() { string historyPrefix = instance.Channel == GTextureStampChannel.AlbedoMetallicSmoothness ? HISTORY_PREFIX_COLOR : instance.Channel == GTextureStampChannel.Splat ? HISTORY_PREFIX_TEXTURE : "Unknown Action"; List <GTerrainResourceFlag> resourcesFlag = new List <GTerrainResourceFlag>(); if (instance.Channel == GTextureStampChannel.AlbedoMetallicSmoothness) { resourcesFlag.Add(GTerrainResourceFlag.AlbedoMap); resourcesFlag.Add(GTerrainResourceFlag.MetallicMap); } else if (instance.Channel == GTextureStampChannel.Splat) { resourcesFlag.Add(GTerrainResourceFlag.SplatControlMaps); } GBackup.TryCreateInitialBackup(historyPrefix, instance.GroupId, resourcesFlag); }
private void CreateInitialBackup() { string historyPrefix = instance.Channel == GPathPainter.PaintChannel.AlbedoAndMetallic ? HISTORY_PREFIX_ALBEDO_METALLIC : instance.Channel == GPathPainter.PaintChannel.Splat ? HISTORY_PREFIX_SPLAT : "Unknown Action"; List <GTerrainResourceFlag> resourceFlag = new List <GTerrainResourceFlag>(); if (instance.Channel == GPathPainter.PaintChannel.AlbedoAndMetallic) { resourceFlag.Add(GTerrainResourceFlag.AlbedoMap); resourceFlag.Add(GTerrainResourceFlag.MetallicMap); } else if (instance.Channel == GPathPainter.PaintChannel.Splat) { resourceFlag.Add(GTerrainResourceFlag.SplatControlMaps); } GBackup.TryCreateInitialBackup(historyPrefix, instance.SplineCreator.GroupId, resourceFlag); }
private void DoBulkImport() { string ext = BitDepth == GBitDepth.Bit8 ? "raw" : "r16"; List <string> files = new List <string>(Directory.GetFiles(DataDirectory)); files.RemoveAll(f => !f.EndsWith(ext)); GCommon.ForEachTerrain( BulkImportGroupId, (t) => { if (t == null || t.TerrainData == null) { return; } string file = files.Find( s => { string f = Path.GetFileNameWithoutExtension(s); return(f.StartsWith(BitDepth == GBitDepth.Bit8 ? "RAW8" : "RAW16") && f.EndsWith(t.TerrainData.Id)); }); if (string.IsNullOrEmpty(file)) { return; } GBackup.TryCreateInitialBackup(HISTORY_PREFIX, t, GCommon.HeightMapAndFoliageResourceFlags); GRawImporter importer = new GRawImporter(); importer.Terrain = t; importer.DesData = t.TerrainData; importer.BitDepth = BitDepth; importer.UseRawResolution = UseRawResolution; importer.FilePath = file; importer.Import(); GBackup.TryCreateBackup(HISTORY_PREFIX, t, GCommon.HeightMapAndFoliageResourceFlags); }); GStylizedTerrain.MatchEdges(BulkImportGroupId); }
private void DoImport() { if (Terrain != null) { GBackup.TryCreateInitialBackup(HISTORY_PREFIX, Terrain, GCommon.HeightMapAndFoliageResourceFlags); } GRawImporter importer = new GRawImporter(); importer.Terrain = Terrain; importer.DesData = DesData; importer.BitDepth = BitDepth; importer.UseRawResolution = UseRawResolution; importer.FilePath = FilePath; importer.Import(); if (Terrain != null) { GBackup.TryCreateBackup(HISTORY_PREFIX, Terrain, GCommon.HeightMapAndFoliageResourceFlags); } }
private void Editor_CreateInitialHistoryEntry(GTexturePainterArgs args, List <GStylizedTerrain> overlappedTerrains) { if (!Editor_EnableHistory) { return; } if (overlappedTerrains.Count == 0) { return; } List <GTerrainResourceFlag> flags = new List <GTerrainResourceFlag>(); flags.AddRange(ActivePainter.GetResourceFlagForHistory(args)); if (InitialRecordedTerrains.Count == 0) { currentInitialBackupName = GBackup.TryCreateInitialBackup(ActivePainter.HistoryPrefix, overlappedTerrains[0], flags, false); if (!string.IsNullOrEmpty(currentInitialBackupName)) { InitialRecordedTerrains.Add(overlappedTerrains[0]); } } else { if (!string.IsNullOrEmpty(currentInitialBackupName)) { for (int i = 0; i < overlappedTerrains.Count; ++i) { if (InitialRecordedTerrains.Contains(overlappedTerrains[i])) { continue; } GBackup.BackupTerrain(overlappedTerrains[i], currentInitialBackupName, flags); InitialRecordedTerrains.Add(overlappedTerrains[i]); } } } }
private void DoImport() { if (Terrain != null) { GBackup.TryCreateInitialBackup(HISTORY_PREFIX, Terrain, GCommon.AllResourceFlags); } GTextureImporter importer = new GTextureImporter(); importer.Terrain = Terrain; importer.DesData = DesData; importer.HeightMap = HeightMap; importer.VisibilityMap = VisibilityMap; importer.AlbedoMap = AlbedoMap; importer.MetallicMap = MetallicMap; importer.SplatControlMaps = SplatControlMaps; importer.Import(); if (Terrain != null) { GBackup.TryCreateBackup(HISTORY_PREFIX, Terrain, GCommon.AllResourceFlags); } }
private void CreateInitialBackup() { GBackup.TryCreateInitialBackup(HISTORY_PREFIX, instance.GroupId, GCommon.FoliageInstancesResourceFlags); }
private void DoBulkImport() { string[] guid = AssetDatabase.FindAssets("t:TerrainData", new string[] { Directory }); List <TerrainData> terrainDatas = new List <TerrainData>(); for (int i = 0; i < guid.Length; ++i) { string path = AssetDatabase.GUIDToAssetPath(guid[i]); TerrainData data = AssetDatabase.LoadAssetAtPath <TerrainData>(path); terrainDatas.Add(data); } GCommon.ForEachTerrain( BulkImportGroupId, (t) => { if (t == null || t.TerrainData == null) { return; } TerrainData srcData = terrainDatas.Find(d => d.name.StartsWith("TerrainData") && d.name.EndsWith(t.TerrainData.Id)); if (srcData == null) { return; } GBackup.TryCreateInitialBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags); GUnityTerrainDataImporter importer = new GUnityTerrainDataImporter(); importer.SrcTerrain = null; importer.SrcData = srcData; importer.DesData = t.TerrainData; importer.DesTerrain = t; importer.ImportGeometry = ImportGeometry; importer.UseUnityTerrainSize = UseUnityTerrainSize; importer.ImportSplats = ImportSplats; importer.ImportSplatsAsAlbedo = ImportSplatsAsAlbedo; bool createNewSplatGroup = CreateNewSplatPrototypesGroup; if (t.TerrainData.Shading.Splats == null || t.TerrainData.Shading.Splats == GGriffinSettings.Instance.TerrainDataDefault.Shading.Splats) { createNewSplatGroup = true; } importer.CreateNewSplatPrototypesGroup = createNewSplatGroup; importer.ImportTrees = ImportTrees; bool createNewTreeGroup = CreateNewTreePrototypesGroup; if (t.TerrainData.Foliage.Trees == null || t.TerrainData.Foliage.Trees == GGriffinSettings.Instance.TerrainDataDefault.Foliage.Trees) { createNewTreeGroup = true; } importer.CreateNewTreePrototypesGroup = createNewTreeGroup; importer.ImportGrasses = ImportGrasses; bool createNewGrassGroup = CreateNewGrassPrototypesGroup; if (t.TerrainData.Foliage.Grasses == null || t.TerrainData.Foliage.Grasses == GGriffinSettings.Instance.TerrainDataDefault.Foliage.Grasses) { createNewGrassGroup = true; } importer.CreateNewGrassPrototypesGroup = createNewGrassGroup; GrassDensity = GUnityTerrainDataImporter.GetAdjustedGrassDensity(srcData); importer.GrassDensity = GrassDensity; importer.Import(); GBackup.TryCreateBackup(HISTORY_PREFIX, t, GCommon.AllResourceFlags); }); GStylizedTerrain.MatchEdges(BulkImportGroupId); }
private void CreateInitialBackup() { GBackup.TryCreateInitialBackup(HISTORY_PREFIX, instance.SplineCreator.GroupId, GCommon.HeightMapAndFoliageResourceFlags); }