public void Init() { if (TouchReactCamera) { TouchReactCamera.enabled = true; } if (!TouchReactCamera) { CreateTouchReactCamera(); } UpdateTouchReactCamera(); if (AutoselectCamera) { SelectedCamera = Camera.main; } #if VEGETATION_STUDIO || VEGETATION_STUDIO_PRO VegetationStudioManager.EnableTouchReact(true); #endif SetupMaterial(); UpdateCamera(); }
// ReSharper disable once UnusedMember.Local public static void AddVegetationStudioManager() { VegetationStudioManager vegetationStudioManager = FindObjectOfType <VegetationStudioManager>(); if (vegetationStudioManager) { EditorUtility.DisplayDialog("Vegetation Studio Component", "There is already a Vegetation Studio Manager Component in the scene. There can be only one.", "OK"); } else { GameObject go = new GameObject { name = "VegetationStudio" }; go.AddComponent <VegetationStudioManager>(); GameObject vegetationSystem = new GameObject { name = "VegetationSystem" }; vegetationSystem.transform.SetParent(go.transform); vegetationSystem.AddComponent <VegetationSystem>(); vegetationSystem.AddComponent <TerrainSystem>(); vegetationSystem.AddComponent <BillboardSystem>(); vegetationSystem.AddComponent <ColliderSystem>(); vegetationSystem.AddComponent <PersistentVegetationStorage>(); GameObject touchReactSystem = new GameObject { name = "TouchReactSystem" }; touchReactSystem.transform.SetParent(go.transform); #if TOUCH_REACT touchReactSystem.AddComponent <TouchReactSystem>(); #endif } }
public void GenerateMeshTerrain() { _objects = new List <ObjectData>(); for (int i = 0; i <= MeshTerrainMeshSourceList.Count - 1; i++) { if (MeshTerrainMeshSourceList[i].MeshRenderer.GetComponent <MeshFilter>().sharedMesh == null) { continue; } ObjectData o = new ObjectData(MeshTerrainMeshSourceList[i].MeshRenderer, (int)MeshTerrainMeshSourceList[i].TerrainSourceID); if (o.IsValid) { _objects.Add(o); } } BVH.Build(ref _objects, out _nodes, out Tris, out _finalPrims); BVH.BuildLbvhData(_nodes, _finalPrims, out MeshTerrainData.lNodes, out MeshTerrainData.lPrims); MeshTerrainData.Bounds = CalculateTerrainBounds(); #if UNITY_EDITOR EditorUtility.SetDirty(MeshTerrainData); #endif //GenerateCellCoverage(); CreateNativeArrays(); VegetationStudioManager.RefreshTerrainArea(TerrainBounds); }
public void UpdateVegetationMask() { if (!enabled || !gameObject.activeSelf) { return; } BeaconMaskArea maskArea = new BeaconMaskArea { Radius = Radius, Position = transform.position }; maskArea.SetFalloutCurve(FalloffCurve.GenerateCurveArray(4096)); maskArea.Init(); AddVegetationTypes(maskArea); if (_currentMaskArea != null) { VegetationStudioManager.RemoveVegetationMask(_currentMaskArea); _currentMaskArea = null; } _currentMaskArea = maskArea; VegetationStudioManager.AddVegetationMask(maskArea); }
// ReSharper disable once UnusedMember.Local void OnDrawGizmosSelected() { Gizmos.color = Color.blue; Gizmos.DrawWireCube( RaycastTerrainBounds.center + TerrainPosition + VegetationStudioManager.GetFloatingOriginOffset(), RaycastTerrainBounds.size); }
public static void SetTextures(Rect terrainRect, Texture2D[] textures, int[] maskGroupNums, VegetationPackagePro package) { for (int i = 0; i < textures.Length; i++) { Texture2D tex = textures[i]; if (tex == null) { continue; } TextureMaskGroup maskGroup = package.TextureMaskGroupList[maskGroupNums[i]]; //creating new mask only if the mask with the same rect doesn't exist TextureMask mask = maskGroup.TextureMaskList.Find(m => m.TextureRect == terrainRect); if (mask == null) { mask = new TextureMask { TextureRect = terrainRect }; maskGroup.TextureMaskList.Add(mask); } mask.MaskTexture = tex; } //VegetationSystemPro system = GameObject.FindObjectOfType<VegetationSystemPro>(); //if (system != null) // system.ClearCache(); //clearing cache causes flickering VegetationStudioManager.RefreshTerrainHeightMap(); }
// ReSharper disable once UnusedMember.Local void OnDisable() { if (_currentMaskArea != null) { VegetationStudioManager.RemoveBiomeMask(_currentMaskArea); _currentMaskArea = null; } }
void OnDisable() { if (Light == null) { return; } VegetationStudioManager.SetSunDirectionalLight(null); }
// ReSharper disable once UnusedMember.Local public void RefreshPostProcessVolume() { #if UNITY_POST_PROCESSING_STACK_V2 PostProcessProfileInfo postProcessProfileInfo = VegetationStudioManager.GetPostProcessProfileInfo(BiomeType); RefreshPostProcessVolume(postProcessProfileInfo, VegetationStudioManager.GetPostProcessingLayer()); #endif }
void OnDisable() { if (Camera == null) { return; } VegetationStudioManager.RemoveCamera(Camera); }
public void OnEnable() { VegetationStudioInstance = VegetationStudioProUtils.FindVegetationStudioInstance(); extension = (BatchFunctions)target; // biomes biomeType = FindProperty(x => x.biomeType); }
void OnEnable() { if (Camera == null) { return; } VegetationStudioManager.AddCamera(Camera, false, true); }
//Prepare public void CheckAddComponent(Chunk chunk) { #if VEGETATION_STUDIO Profiler.BeginSample("VS Prepare"); //adding the main vegetation object VegetationStudioManager.AddVegetationStudioManagerToScene(); //checking if all packs for all of the generators are the same if (packageShared == null) { packageShared = package; } else { package = packageShared; } //finding/creating vegetation system component VegetationSystem vetSys = chunk.terrain.gameObject.GetComponentInChildren <VegetationSystem>(); if (vetSys == null) { vetSys = VegetationStudioManager.AddVegetationSystemToTerrain(chunk.terrain, package, createPersistentVegetationStoragePackage: true); } if (vetSys.VegetationPackageList.Count == 0) { vetSys.VegetationPackageList.Add(package); } if (vetSys.VegetationPackageList.Count == 1 && vetSys.VegetationPackageList[0] == null) { vetSys.VegetationPackageList[0] = package; } if (!vetSys.VegetationPackageList.Contains(package)) { vetSys.VegetationPackageList.Add(package); } if (!vetSys.InitDone) { vetSys.SetupVegetationSystem(); vetSys.RefreshVegetationPackage(); } cellSize = vetSys.CellSize; //saving per-chunk storage (to access it from thread) PersistentVegetationStorage storage = vetSys.gameObject.GetComponent <PersistentVegetationStorage>(); if (!vetStorComponents.ContainsKey(chunk.rect)) { vetStorComponents.Add(chunk.rect, null); } vetStorComponents[chunk.rect] = storage; Profiler.EndSample(); #endif }
// ReSharper disable once UnusedMember.Local void OnDisable() { _initDone = false; if (AutoAddToVegegetationSystem && Application.isPlaying) { VegetationStudioManager.RemoveTerrain(gameObject); } else { VegetationStudioManager.RefreshTerrainArea(TerrainBounds); } }
public void OnEnable() { VegetationStudioInstance = VegetationStudioProUtils.FindVegetationStudioInstance(); extension = (BatchFunctions)target; // biomes modifyAll = FindProperty(x => x.modifyAll); biomeType = FindProperty(x => x.biomeType); // get only the added biome types, we don't want all of the enum in the popup addedBiomes = new PopupData <BiomeType>(VegetationStudioProUtils.GetAddedBiomeTypes().ToArray()); }
// ReSharper disable once UnusedMember.Local void OnDisable() { if (_lineMaskList.Count > 0) { for (int i = 0; i <= _lineMaskList.Count - 1; i++) { VegetationStudioManager.RemoveVegetationMask(_lineMaskList[i]); _lineMaskList[i].Dispose(); } _lineMaskList.Clear(); } }
public override void OnInspectorGUI() { //OverrideLogoTextureName = "SectionBanner_VegetationStudioManager"; HelpTopic = "vegetation-studio-manager"; LargeLogo = true; _vegetationStudioManager = (VegetationStudioManager)target; base.OnInspectorGUI(); if (_vegetationStudioManager.HasSleepingVegetationSystems()) { GUILayout.BeginVertical("box"); var oldColor = GUI.backgroundColor; Color backgroundColor = new Color(110f / 255f, 235f / 255f, 110f / 255f); GUI.backgroundColor = backgroundColor; if (GUILayout.Button("Start all Vegetation Systems", GUILayout.Height(35))) { _vegetationStudioManager.WakeUpVegetationSystems(); } GUI.backgroundColor = oldColor; EditorGUILayout.HelpBox("Vegetation Studio starts in sleep mode when scene loads in editor. In playmode and builds it starts as normal.", MessageType.Info); GUILayout.EndVertical(); } EditorGUILayout.HelpBox( "Vegetation System Manager will manage all Vegetation, Terrain, Collider, Masks and Billboard Systems in the scene. Only one instance per scene.", MessageType.Info); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Vegetation systems", LabelStyle); EditorGUI.BeginDisabledGroup(true); for (int i = 0; i <= _vegetationStudioManager.VegetationSystemList.Count - 1; i++) { EditorGUILayout.ObjectField("Vegetation System", _vegetationStudioManager.VegetationSystemList[i], typeof(VegetationSystem), true); } EditorGUI.EndDisabledGroup(); GUILayout.EndVertical(); GUILayout.BeginVertical("box"); EditorGUILayout.LabelField("Terrain systems", LabelStyle); EditorGUI.BeginDisabledGroup(true); for (int i = 0; i <= _vegetationStudioManager.TerrainSystemList.Count - 1; i++) { EditorGUILayout.ObjectField("Terrain System", _vegetationStudioManager.TerrainSystemList[i], typeof(TerrainSystem), true); } EditorGUI.EndDisabledGroup(); GUILayout.EndVertical(); }
// ReSharper disable once UnusedMember.Local void OnEnable() { _initDone = true; //SetTerrainPosition(); if (AutoAddToVegegetationSystem && Application.isPlaying) { VegetationStudioManager.AddTerrain(gameObject, false); } else { VegetationStudioManager.RefreshTerrainArea(TerrainBounds); } }
void CopyCurve() { if (_mCurves.Count > 0) { foreach (var curve in _mCurves) { VegetationStudioManager.AddAnimationCurveToClipboard(curve.Key); break; } } else { VegetationStudioManager.AddAnimationCurveToClipboard(null);; } }
public void OnEnable() { this.editor = this; VegetationStudioInstance = VegetationStudioProUtils.FindVegetationStudioInstance(); extension = (BiomeMaskSpawnerExtension)target; #region settings modules rectangularPartitionModule = new RectangularPartitionModule(this); voronoiModule = new VoronoiModule(this); hexagonModule = new HexagonModule(this); lineModule = new LineModule(this); lakeModule = new LakeModule(this); shapeModule = new ShapeModule(this); biomeModule = new BiomeModule(this); processingModule = new ProcessingModule(this); riverModule = new RiverModule(this); roadModule = new RoadModule(this); #endregion settings modules #region action modules maskCreationActionModule = new MaskCreationActionModule(this); roadCreationActionModule = new RoadCreationActionModule(this); vegetationStudioProActionModule = new VegetationStudioProActionModule(this); #endregion action modules #region module OnEnable biomeModule.OnEnable(); lakeModule.OnEnable(); shapeModule.OnEnable(); processingModule.OnEnable(); rectangularPartitionModule.OnEnable(); voronoiModule.OnEnable(); hexagonModule.OnEnable(); lineModule.OnEnable(); riverModule.OnEnable(); roadModule.OnEnable(); #endregion module OnEnable #region Consistency Check performInitialConsistencyCheck = true; #endregion Consistency Check }
// ReSharper disable once UnusedMember.Local void OnEnable() { _debugMaterial = Resources.Load("MeshTerrainDebugMaterial", typeof(Material)) as Material; _initDone = true; if (AutoAddToVegegetationSystem && Application.isPlaying) { VegetationStudioManager.AddTerrain(gameObject, false); } else { VegetationStudioManager.RefreshTerrainArea(TerrainBounds); } }
/// <summary> /// Ensure the prefab has a VegetationItemID /// </summary> /// <param name="prefabSettings"></param> private void updateVSProSettings(PrefabSettings prefabSettings, bool forceVegetationItemIDUpdate) { #if VEGETATION_STUDIO_PRO GameObject prefab = prefabSettings.prefab; // check if we have a VegetationItemID, otherwise create it using the current prefab if (string.IsNullOrEmpty(prefabSettings.vspro_VegetationItemID) || forceVegetationItemIDUpdate) { // get the asset guid if (string.IsNullOrEmpty(prefabSettings.assetGUID)) { string assetPath = AssetDatabase.GetAssetPath(prefab); if (!string.IsNullOrEmpty(assetPath)) { string assetGUID = AssetDatabase.AssetPathToGUID(assetPath); prefabSettings.assetGUID = assetGUID; } } // if we have a guid, get the vs pro id if (!string.IsNullOrEmpty(prefabSettings.assetGUID)) { // get the VegetationItemID prefabSettings.vspro_VegetationItemID = VegetationStudioManager.GetVegetationItemID(prefabSettings.assetGUID); // if the vegetation item id doesn't exist, create a new vegetation item if (string.IsNullOrEmpty(prefabSettings.vspro_VegetationItemID)) { VegetationType vegetationType = VegetationType.Objects; bool enableRuntimeSpawn = false; // no runtime spawn, we want it spawned from persistent storage BiomeType biomeType = BiomeType.Default; prefabSettings.vspro_VegetationItemID = VegetationStudioManager.AddVegetationItem(prefab, vegetationType, enableRuntimeSpawn, biomeType); } } else { Debug.LogError("Can't get assetGUID for prefab " + prefab); } } if (string.IsNullOrEmpty(prefabSettings.vspro_VegetationItemID)) { Debug.LogError("Can't get VegetationItemId for prefab " + prefab); } #endif }
public static void RefreshVegetation() { VegetationStudioManager VegetationStudioInstance = FindVegetationStudioInstance(); List <VegetationSystemPro> VegetationSystemList = VegetationStudioInstance.VegetationSystemList; for (int i = 0; i <= VegetationSystemList.Count - 1; i++) { VegetationSystemPro vegetationSystemPro = VegetationSystemList[i]; vegetationSystemPro.ClearCache(); vegetationSystemPro.RefreshTerrainHeightmap(); SceneView.RepaintAll(); SetSceneDirty(vegetationSystemPro); } }
//// ReSharper disable once UnusedMember.Local void OnEnable() { // if (!Heights.IsCreated) LoadHeightData(); //if (_nativeManagedFloatArray == null) LoadHeightData(); RefreshSplatMaps(); _initDone = true; if (AutoAddToVegegetationSystem && Application.isPlaying) { AddTerrainToVegetationSystem(); } else { VegetationStudioManager.RefreshTerrainArea(TerrainBounds); } }
// ReSharper disable once UnusedMember.Local private void OnDisable() { #if VEGETATION_STUDIO || VEGETATION_STUDIO_PRO VegetationStudioManager.EnableTouchReact(false); #endif if (TouchReactCamera) { TouchReactCamera.enabled = false; } if (TouchReactCamera) { RenderTexture rt = TouchReactCamera.targetTexture; TouchReactCamera.targetTexture = null; DestroyImmediate(rt); } }
void PasteCurve() { AnimationCurve animationCurve = VegetationStudioManager.GetAnimationCurveFromClippboard(); if (animationCurve != null) { foreach (var curve in _mCurves) { Keyframe[] keyframes = animationCurve.keys; curve.Key.keys = new Keyframe[0]; for (var i = 0; i <= keyframes.Length - 1; i++) { curve.Key.AddKey(keyframes[i].time, keyframes[i].value); } break; } } }
public void UpdateBiomeMask() { if (!enabled || !gameObject.activeSelf) { return; } List <Vector3> worldSpaceNodeList = GetWorldSpaceNodePositions(); List <bool> disableEdgeList = GetDisableEdgeList(); PolygonBiomeMask maskArea = new PolygonBiomeMask { BiomeType = BiomeType, BlendDistance = BlendDistance, UseNoise = UseNoise, NoiseScale = NoiseScale }; maskArea.AddPolygon(worldSpaceNodeList, disableEdgeList); if (!ValidateAnimationCurve(BlendCurve)) { BlendCurve = CreateResetAnimationCurve(); } if (!ValidateAnimationCurve(InverseBlendCurve)) { InverseBlendCurve = CreateResetAnimationCurve(); } if (!ValidateAnimationCurve(TextureBlendCurve)) { TextureBlendCurve = CreateResetAnimationCurve(); } maskArea.SetCurve(BlendCurve.GenerateCurveArray()); maskArea.SetInverseCurve(InverseBlendCurve.GenerateCurveArray()); maskArea.SetTextureCurve(TextureBlendCurve.GenerateCurveArray()); if (_currentMaskArea != null) { VegetationStudioManager.RemoveBiomeMask(_currentMaskArea); _currentMaskArea = null; } _currentMaskArea = maskArea; VegetationStudioManager.AddBiomeMask(maskArea); RefreshPostProcessVolume(); }
public static void SetupTerrain(Terrain terrain, ref VegetationPackage package, out VegetationSystem system, out PersistentVegetationStorage storage) { var vetSystems = GetVegetationSystemsForTerrain(terrain); VegetationSystem vetSys = null; for (var i = 0; i < vetSystems.Count; ++i) { var candidate = vetSystems[i]; if (candidate.CurrentVegetationPackage == package) { vetSys = candidate; break; } } if (vetSys == null) { vetSys = VegetationStudioManager.AddVegetationSystemToTerrain(terrain, package, createPersistentVegetationStoragePackage: true); } if (package != null) { if (vetSys.VegetationPackageList.Count == 0) { vetSys.VegetationPackageList.Add(package); } if (vetSys.VegetationPackageList.Count == 1 && vetSys.VegetationPackageList[0] == null) { vetSys.VegetationPackageList[0] = package; } if (!vetSys.VegetationPackageList.Contains(package)) { vetSys.VegetationPackageList.Add(package); } } if (!vetSys.InitDone) { vetSys.SetupVegetationSystem(); vetSys.RefreshVegetationPackage(); } vetSys.SetSleepMode(false); package = vetSys.CurrentVegetationPackage; system = vetSys; storage = vetSys.GetComponent <PersistentVegetationStorage>(); }
override public void Update(StrokeSegment[] segments) { #if VEGETATION_STUDIO_PRO if (segments.Length > 0) { StrokeSegment segment = segments[0]; Bounds bounds = new Bounds(new Vector3(segment.currUV.x, 0, segment.currUV.y), Vector3.zero);; for (int i = 1; i < segments.Length; i++) { segment = segments[i]; Vector2 boundsWS = TransformUtilities.transformToWorld(segment.currTerrain, segment.currUV); bounds.Encapsulate(new Vector3(boundsWS.x, 0, boundsWS.y)); } VegetationStudioManager.RefreshTerrainHeightMap(bounds); } #endif }
/// <summary> /// Get the added biome types, i. e. only those which have an added vegetation package /// </summary> /// <param name="vegetationSystemPro"></param> /// <returns></returns> public static List <BiomeType> GetAddedBiomeTypes() { List <BiomeType> biomeTypes = new List <BiomeType>(); VegetationStudioManager VegetationStudioInstance = FindVegetationStudioInstance(); List <VegetationSystemPro> VegetationSystemList = VegetationStudioInstance.VegetationSystemList; for (int i = 0; i <= VegetationSystemList.Count - 1; i++) { VegetationSystemPro vegetationSystemPro = VegetationSystemList[i]; foreach (VegetationPackagePro vegetationPackagePro in vegetationSystemPro.VegetationPackageProList) { biomeTypes.Add(vegetationPackagePro.BiomeType); } } return(biomeTypes); }