コード例 #1
0
        void AddVegetationItemsToScene(VegetationCell vegetationCell, GameObject parent, VegetationItemInfoPro vegetationItemInfoPro)
        {
            if (!vegetationItemInfoPro.VegetationPrefab)
            {
                return;
            }
            VegetationSystemPro vegetationSystemPro = _sceneVegetationBaker.VegetationSystemPro;

            vegetationSystemPro.SpawnVegetationCell(vegetationCell, vegetationItemInfoPro.VegetationItemID);
            NativeList <MatrixInstance> vegetationInstanceList =
                vegetationSystemPro.GetVegetationItemInstances(vegetationCell, vegetationItemInfoPro.VegetationItemID);

            for (int j = 0; j <= vegetationInstanceList.Length - 1; j++)
            {
                Matrix4x4  vegetationItemMatrix = vegetationInstanceList[j].Matrix;
                Vector3    position             = MatrixTools.ExtractTranslationFromMatrix(vegetationItemMatrix);
                Vector3    scale    = MatrixTools.ExtractScaleFromMatrix(vegetationItemMatrix);
                Quaternion rotation = MatrixTools.ExtractRotationFromMatrix(vegetationItemMatrix);

                GameObject vegetationItem = Instantiate(vegetationItemInfoPro.VegetationPrefab, parent.transform);
                vegetationItem.transform.position   = position;
                vegetationItem.transform.localScale = scale;
                vegetationItem.transform.rotation   = rotation;
                vegetationItem.isStatic             = _sceneVegetationBaker.ExportStatic;
            }
            vegetationCell.ClearCache();
        }
コード例 #2
0
    public ColliderPool(VegetationItemInfoPro vegetationItemInfoPro, VegetationItemModelInfo vegetationItemModelInfo, VegetationSystemPro vegetationSystemPro, Transform colliderParent, bool showColliders)
    {
        _vegetationItemInfoPro   = vegetationItemInfoPro;
        _vegetationItemModelInfo = vegetationItemModelInfo;
        _vegetationSystemPro     = vegetationSystemPro;
        _colliderParent          = colliderParent;
        _showColliders           = showColliders;

        _colliderLayer = vegetationSystemPro.VegetationSettings.GetLayer(vegetationItemInfoPro.VegetationType);
        _colliderTag   = vegetationItemInfoPro.ColliderTag;
        if (_colliderTag == "")
        {
            _colliderTag = "Untagged";
        }

        if (_vegetationItemInfoPro.ColliderType == ColliderType.FromPrefab)
        {
            GameObject tmpColliderObject = Object.Instantiate(vegetationItemInfoPro.VegetationPrefab);
            if (_vegetationItemInfoPro.ColliderTag != "")
            {
                tmpColliderObject.tag = vegetationItemInfoPro.ColliderTag;
            }

            tmpColliderObject.hideFlags = HideFlags.DontSave;
            tmpColliderObject.name      = "ColliderSource_" + _vegetationItemInfoPro.VegetationItemID;
            tmpColliderObject.transform.SetParent(_colliderParent);
            _sourceColliderObject = CreateColliderObject(tmpColliderObject);
            DestroyObject(tmpColliderObject);
        }
    }
コード例 #3
0
        public static VegetationSystemPro GetTopVegetationSystem()
        /// Finds main system to be used as source for clones
        {
            GameObject[] rootObjects = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();

            foreach (GameObject rootObject in rootObjects)
            {
                if (rootObject.GetComponent <VegetationStudioManager>())
                {
                    int childCount = rootObject.transform.childCount;
                    for (int c = 0; c < childCount; c++)
                    {
                        Transform           child = rootObject.transform.GetChild(c);
                        VegetationSystemPro sys   = child.GetComponent <VegetationSystemPro>();

                        if (sys != null)
                        {
                            return(sys);
                        }
                    }
                }
            }

            return(null);
        }
コード例 #4
0
        public static void SetObjects(List <Transition>[] allTransitions, string[] allIds)
        {
            VegetationSystemPro         system  = GameObject.FindObjectOfType <VegetationSystemPro>();
            PersistentVegetationStorage storage = system.PersistentVegetationStorage;

            for (int i = 0; i < allTransitions.Length; i++)
            {
                if (allTransitions[i] == null)
                {
                    continue;
                }
                foreach (Transition obj in allTransitions[i])
                {
                    storage.AddVegetationItemInstance(
                        allIds[i],
                        obj.pos,
                        obj.scale,
                        obj.rotation,
                        applyMeshRotation: true,
                        vegetationSourceID: VS_MM_id,
                        distanceFalloff: 1,
                        clearCellCache: true);
                }
            }

            //for (int i=0; i<system.VegetationCellList.Count; i++)
            //	system.VegetationCellList[i].ClearCache();

            system.RefreshBillboards();

                                #if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(storage.PersistentVegetationStoragePackage);
            UnityEditor.EditorUtility.SetDirty(system);
                                #endif
        }
コード例 #5
0
        /// <summary>
        /// Returns a unique list of all VegetationPackages used in the scene.
        /// </summary>
        /// <returns></returns>
        public static List <VegetationPackagePro> GetVegetationPackageList(BiomeType biomeType)
        {
            List <VegetationPackagePro> vegetationPackageList = new List <VegetationPackagePro>();

            if (!Instance)
            {
                FindInstance();
            }

            if (!Instance)
            {
                return(vegetationPackageList);
            }

            for (int i = 0; i <= Instance.VegetationSystemList.Count - 1; i++)
            {
                VegetationSystemPro vegetationSystemPro = Instance.VegetationSystemList[i];
                if (vegetationSystemPro)
                {
                    VegetationPackagePro vegetationPackagePro =
                        vegetationSystemPro.GetVegetationPackageFromBiome(biomeType);
                    if (vegetationPackagePro)
                    {
                        vegetationPackageList.Add(vegetationPackagePro);
                    }
                }
            }

            return(vegetationPackageList);
        }
コード例 #6
0
        public static void SetTextures(VegetationSystemPro system, VegetationPackagePro package, Texture2D[] textures, int[] maskGroupNums, Rect terrainRect)
        {
            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
            system.RefreshTerrainHeightmap();
        }
コード例 #7
0
        /// <summary>
        /// Returns a unique list of all VegetationPackages used in the scene.
        /// </summary>
        /// <returns></returns>
        public static List <VegetationPackagePro> GetAllVegetationPackageList()
        {
            List <VegetationPackagePro> vegetationPackageList = new List <VegetationPackagePro>();

            if (!Instance)
            {
                FindInstance();
            }

            if (!Instance)
            {
                return(vegetationPackageList);
            }

            for (int i = 0; i <= Instance.VegetationSystemList.Count - 1; i++)
            {
                VegetationSystemPro vegetationSystemPro = Instance.VegetationSystemList[i];
                if (vegetationSystemPro)
                {
                    vegetationPackageList.AddRange(vegetationSystemPro.VegetationPackageProList);
                }
            }

            return(vegetationPackageList);
        }
コード例 #8
0
 private void FindVegetationSystemPro()
 {
     if (!VegetationSystemPro)
     {
         VegetationSystemPro = GetComponent <VegetationSystemPro>();
     }
 }
コード例 #9
0
        public ColliderManager(VisibleVegetationCellSelector visibleVegetationCellSelector,
                               VegetationSystemPro vegetationSystemPro, VegetationItemInfoPro vegetationItemInfoPro,
                               Transform colliderParent, bool showColliders)
        {
            _showColliders         = showColliders;
            _vegetationSystemPro   = vegetationSystemPro;
            _vegetationItemInfoPro = vegetationItemInfoPro;

            float cullingDistance = vegetationSystemPro.VegetationSettings.GetVegetationDistance() *
                                    vegetationItemInfoPro.ColliderDistanceFactor;


            VegetationItemSelector = new VegetationItemSelector(visibleVegetationCellSelector, vegetationSystemPro,
                                                                vegetationItemInfoPro, false, 1, 0)
            {
                CullingDistance = cullingDistance
            };

            VegetationItemSelector.OnVegetationItemVisibleDelegate   += OnVegetationItemVisible;
            VegetationItemSelector.OnVegetationItemInvisibleDelegate += OnVegetationItemInvisible;
            VegetationItemSelector.OnVegetationCellInvisibleDelegate += OnVegetationCellInvisible;

            VegetationItemModelInfo vegetationItemModelInfo =
                vegetationSystemPro.GetVegetationItemModelInfo(vegetationItemInfoPro.VegetationItemID);

            ColliderPool         = new ColliderPool(vegetationItemInfoPro, vegetationItemModelInfo, vegetationSystemPro, colliderParent, _showColliders);
            RuntimePrefabStorage = new RuntimePrefabStorage(ColliderPool);
        }
コード例 #10
0
        private static void AddBiomeMaskToVegetationSystem(VegetationSystemPro vegetationSystem, PolygonBiomeMask maskArea)
        {
            int biomeSortOrder = vegetationSystem.GetBiomeSortOrder(maskArea.BiomeType);

            maskArea.BiomeSortOrder = biomeSortOrder;

            Rect maskRect = RectExtension.CreateRectFromBounds(maskArea.MaskBounds);

            if (vegetationSystem.VegetationCellQuadTree != null && vegetationSystem.BillboardCellQuadTree != null)
            {
                List <VegetationCell> selectedCellList = new List <VegetationCell>();
                vegetationSystem.VegetationCellQuadTree.Query(maskRect, selectedCellList);
                for (int i = 0; i <= selectedCellList.Count - 1; i++)
                {
                    selectedCellList[i].AddBiomeMask(maskArea);
                }

                List <BillboardCell> selectedBillboardCellList = new List <BillboardCell>();
                vegetationSystem.BillboardCellQuadTree.Query(maskRect, selectedBillboardCellList);
                for (int i = 0; i <= selectedBillboardCellList.Count - 1; i++)
                {
                    selectedBillboardCellList[i].ClearCache();
                }
            }
        }
コード例 #11
0
        private static void AddVegetationMaskToVegetationSystem(VegetationSystemPro vegetationSystem, BaseMaskArea maskArea)
        {
            vegetationSystem.CompleteCellLoading();

            VegetationItemIndexes vegetationItemIndexes = new VegetationItemIndexes();

            if (maskArea.VegetationItemID != "")
            {
                vegetationItemIndexes = vegetationSystem.GetVegetationItemIndexes(maskArea.VegetationItemID);
            }
            else
            {
                vegetationItemIndexes.VegetationPackageIndex = -1;
                vegetationItemIndexes.VegetationItemIndex    = -1;
            }

            Rect maskRect = RectExtension.CreateRectFromBounds(maskArea.MaskBounds);

            if (vegetationSystem.VegetationCellQuadTree == null ||
                vegetationSystem.BillboardCellQuadTree == null)
            {
                return;
            }

            List <VegetationCell> selectedCellList = new List <VegetationCell>();

            vegetationSystem.VegetationCellQuadTree.Query(maskRect, selectedCellList);

            if (vegetationItemIndexes.VegetationPackageIndex > -1)
            {
                for (int i = 0; i <= selectedCellList.Count - 1; i++)
                {
                    selectedCellList[i]
                    .AddVegetationMask(
                        maskArea, vegetationItemIndexes.VegetationPackageIndex, vegetationItemIndexes.VegetationItemIndex);
                }

                List <BillboardCell> selectedBillboardCellList = new List <BillboardCell>();
                vegetationSystem.BillboardCellQuadTree.Query(maskRect, selectedBillboardCellList);
                for (int i = 0; i <= selectedBillboardCellList.Count - 1; i++)
                {
                    selectedBillboardCellList[i].ClearCache(vegetationItemIndexes.VegetationPackageIndex, vegetationItemIndexes.VegetationItemIndex);
                }
            }
            else
            {
                for (int i = 0; i <= selectedCellList.Count - 1; i++)
                {
                    selectedCellList[i].AddVegetationMask(maskArea);
                }

                List <BillboardCell> selectedBillboardCellList = new List <BillboardCell>();
                vegetationSystem.BillboardCellQuadTree.Query(maskRect, selectedBillboardCellList);
                for (int i = 0; i <= selectedBillboardCellList.Count - 1; i++)
                {
                    selectedBillboardCellList[i].ClearCache();
                }
            }
        }
コード例 #12
0
        void RenderVegetationNow(VegetationSystemPro vegetationSystemPro, ShadowMaskCreator shadowMaskCreator)
        {
            Shader overrideShader = Shader.Find("AwesomeTechnologies/Shadows/ShadowHeight");
            List <VegetationCell> processCellList = new List <VegetationCell>();

            vegetationSystemPro.VegetationCellQuadTree.Query(shadowMaskCreator.AreaRect, processCellList);
            for (int i = 0; i <= vegetationSystemPro.VegetationPackageProList.Count - 1; i++)
            {
                for (int j = 0; j <= vegetationSystemPro.VegetationPackageProList[i].VegetationInfoList.Count - 1; j++)
                {
                    VegetationItemInfoPro vegetationItemInfoPro =
                        vegetationSystemPro.VegetationPackageProList[i].VegetationInfoList[j];

                    if (!RenderVegetationType(vegetationItemInfoPro.VegetationType, shadowMaskCreator))
                    {
                        continue;
                    }
                    for (int k = 0; k <= processCellList.Count - 1; k++)
                    {
                        if (j % 10 == 0)
                        {
                            EditorUtility.DisplayProgressBar("Render vegetation item: " + vegetationItemInfoPro.Name,
                                                             "Render cell " + k + "/" + (processCellList.Count - 1),
                                                             k / ((float)processCellList.Count - 1));
                        }

                        VegetationCell vegetationCell   = processCellList[k];
                        string         vegetationItemID = vegetationItemInfoPro.VegetationItemID;

                        vegetationSystemPro.SpawnVegetationCell(vegetationCell, vegetationItemID);

                        NativeList <MatrixInstance> vegetationInstanceList =
                            vegetationSystemPro.GetVegetationItemInstances(vegetationCell, vegetationItemID);

                        VegetationItemModelInfo vegetationItemModelInfo =
                            vegetationSystemPro.GetVegetationItemModelInfo(vegetationItemID);

                        for (int l = 0; l <= vegetationItemModelInfo.VegetationMeshLod0.subMeshCount - 1; l++)
                        {
                            vegetationItemModelInfo.VegetationMaterialsLOD0[l].SetFloat(CullFarStart, 50000);
                            vegetationItemModelInfo.VegetationMaterialsLOD0[l].SetFloat(CullFarDistance, 20);
                        }

                        for (int l = 0; l <= vegetationItemModelInfo.VegetationMeshLod0.subMeshCount - 1; l++)
                        {
                            Material tempMaterial = new Material(vegetationItemModelInfo.VegetationMaterialsLOD0[l]);
                            tempMaterial.shader = overrideShader;
                            tempMaterial.SetPass(0);
                            for (int m = 0; m <= vegetationInstanceList.Length - 1; m++)
                            {
                                Graphics.DrawMeshNow(vegetationItemModelInfo.VegetationMeshLod0, vegetationInstanceList[m].Matrix);
                            }
                            DestroyImmediate(tempMaterial);
                        }
                    }
                    EditorUtility.ClearProgressBar();
                }
            }
        }
コード例 #13
0
 // ReSharper disable once UnusedMember.Local
 void Reset()
 {
     VegetationSystemPro = GetComponent <VegetationSystemPro>();
     if (VegetationSystemPro)
     {
         VegetationSystemPro.DetectPersistentVegetationStorage();
     }
 }
コード例 #14
0
 public static void SetSceneDirty(VegetationSystemPro vegetationSystemPro)
 {
     if (!Application.isPlaying)
     {
         EditorSceneManager.MarkSceneDirty(vegetationSystemPro.gameObject.scene);
         EditorUtility.SetDirty(vegetationSystemPro);
     }
 }
コード例 #15
0
        public static void FlushObjects(Rect terrainRect, bool clearCache = true)
        {
            VegetationSystemPro system = GameObject.FindObjectOfType <VegetationSystemPro>();

            if (system == null)
            {
                return;
            }

            PersistentVegetationStorage storage = system.PersistentVegetationStorage;

            PersistentVegetationStoragePackage storagePackage = system.PersistentVegetationStorage.PersistentVegetationStoragePackage;

            if (storagePackage == null)
            {
                return;
            }

            List <VegetationCell> overlapCellList = new List <VegetationCell>();

            system.VegetationCellQuadTree.Query(terrainRect, overlapCellList);

            for (int i = 0; i < overlapCellList.Count; i++)
            {
                int cellIndex = overlapCellList[i].Index;

                //storagePackage.PersistentVegetationCellList[cellIndex].ClearCell();

                var infoList = storagePackage.PersistentVegetationCellList[cellIndex].PersistentVegetationInfoList;
                for (int j = 0; j < infoList.Count; j++)
                {
                    var itemList = infoList[j].VegetationItemList;

                    for (int k = itemList.Count - 1; k >= 0; k--)
                    {
                        Vector3 pos  = itemList[k].Position + system.VegetationSystemPosition;
                        Vector2 pos2 = pos.V2();

                        if (terrainRect.Contains(pos2))
                        {
                            itemList.RemoveAt(k);
                            //storage.RemoveVegetationItemInstance(infoList[j].VegetationItemID, pos, 1, clearCellCache:false);
                        }
                    }
                }

                //VegetationItemIndexes indexes = VegetationSystemPro.GetVegetationItemIndexes(vegetationItemID);
                //system.ClearCache(overlapCellList[i],indexes.VegetationPackageIndex,indexes.VegetationItemIndex);
            }

            //if (clearCache)
            //{
            //	for (int i=0; i<system.VegetationCellList.Count; i++)
            //		system.VegetationCellList[i].ClearCache();
            //}

            system.RefreshBillboards();
        }
コード例 #16
0
        public static void SetObjects(List <ObjectPool.Transition>[] allTransitions, string[] allIds)
        {
            if (system == null)
            {
                system = GameObject.FindObjectOfType <VegetationSystemPro>();
            }
            if (system == null)
            {
                throw new System.Exception("MapMagic could not find Vegetation System in scene./n Add Window -> AwesomeTechnologies -> Vegetation System to scene");
            }

            PersistentVegetationStorage storage = system.PersistentVegetationStorage;

            PersistentVegetationStoragePackage storagePackage = system.PersistentVegetationStorage.PersistentVegetationStoragePackage;

            if (storagePackage == null)
            {
                throw new System.Exception("Vegetation System has no storage package assigned to be used with MapMagic./nAssign a Persistent Vegetation Storage Package to Persistent Vegetation Storage component and initialize it.");
            }

            for (int i = 0; i < allTransitions.Length; i++)
            {
                if (allTransitions[i] == null)
                {
                    continue;
                }

                var itemInfo = system.GetVegetationItemInfo(allIds[i]);
                if (itemInfo == null)
                {
                    throw new System.Exception("Item applied by MapMagic is not present in Vegetation System storage");
                }

                foreach (ObjectPool.Transition obj in allTransitions[i])
                {
                    storage.AddVegetationItemInstance(
                        allIds[i],
                        obj.pos,
                        obj.scale,
                        obj.rotation,
                        applyMeshRotation: true,
                        vegetationSourceID: VS_MM_id,
                        distanceFalloff: 1,
                        clearCellCache: true);
                }
            }

            //for (int i=0; i<system.VegetationCellList.Count; i++)
            //	system.VegetationCellList[i].ClearCache();
            //system.ClearCache();

            system.RefreshBillboards();

                                #if UNITY_EDITOR
            UnityEditor.EditorUtility.SetDirty(storagePackage);
            UnityEditor.EditorUtility.SetDirty(system);
                                #endif
        }
コード例 #17
0
ファイル: RuntimePrefabSpawner.cs プロジェクト: d-oglesby/VS
        private void OnRenderComplete(VegetationSystemPro vegetationSystemPro)
        {
            if (PackageRuntimePrefabInfoList.Count == 0)
            {
                return;
            }

            TestFloatingOrigin();

            UnityEngine.Profiling.Profiler.BeginSample("Runtime prefab system processing");
            JobHandle cullingJobHandle = default(JobHandle);

            for (int i = 0; i <= PackageRuntimePrefabInfoList.Count - 1; i++)
            {
                VegetationPackageRuntimePrefabInfo packageRuntimePrefabInfo = PackageRuntimePrefabInfoList[i];
                for (int j = 0; j <= packageRuntimePrefabInfo.RuntimePrefabManagerList.Count - 1; j++)
                {
                    VegetationItemRuntimePrefabInfo vegetationItemRuntimePrefabInfo =
                        packageRuntimePrefabInfo.RuntimePrefabManagerList[j];

                    for (int k = 0; k <= vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList.Count - 1; k++)
                    {
                        RuntimePrefabManager runtimePrefabManager =
                            vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList[k];
                        if (runtimePrefabManager == null)
                        {
                            continue;
                        }
                        cullingJobHandle =
                            runtimePrefabManager.VegetationItemSelector.ProcessInvisibleCells(cullingJobHandle);
                        cullingJobHandle =
                            runtimePrefabManager.VegetationItemSelector.ProcessVisibleCells(cullingJobHandle);
                        cullingJobHandle = runtimePrefabManager.VegetationItemSelector.ProcessCulling(cullingJobHandle);
                    }
                }
            }

            cullingJobHandle.Complete();

            for (int i = 0; i <= PackageRuntimePrefabInfoList.Count - 1; i++)
            {
                VegetationPackageRuntimePrefabInfo packageRuntimePrefabInfo = PackageRuntimePrefabInfoList[i];
                for (int j = 0; j <= packageRuntimePrefabInfo.RuntimePrefabManagerList.Count - 1; j++)
                {
                    VegetationItemRuntimePrefabInfo vegetationItemRuntimePrefabInfo =
                        packageRuntimePrefabInfo.RuntimePrefabManagerList[j];

                    for (int k = 0; k <= vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList.Count - 1; k++)
                    {
                        RuntimePrefabManager runtimePrefabManager =
                            vegetationItemRuntimePrefabInfo.RuntimePrefabManagerList[k];
                        runtimePrefabManager?.VegetationItemSelector.ProcessEvents();
                    }
                }
            }

            UnityEngine.Profiling.Profiler.EndSample();
        }
コード例 #18
0
//		public VisibleVegetationCellSelector()
//		{
//
//		}

        public void Init(VegetationSystemPro vegetationSystemPro)
        {
            _vegetationSystemPro = vegetationSystemPro;

            _vegetationSystemPro.OnAddCameraDelegate += OnAddCamera;
            _vegetationSystemPro.OnAddCameraDelegate += OnRemoveCamera;

            AddVisibleVegetationCells();
        }
コード例 #19
0
 public RuntimePrefabPool(RuntimePrefabRule runtimePrefabRule, VegetationItemInfoPro vegetationItemInfoPro,
                          Transform prefabParent, bool showPrefabsInHierarchy, VegetationSystemPro vegetationSystemPro)
 {
     _vegetationSystemPro    = vegetationSystemPro;
     _vegetationItemInfoPro  = vegetationItemInfoPro;
     _prefabParent           = prefabParent;
     _showPrefabsInHierarchy = showPrefabsInHierarchy;
     _runtimePrefabRule      = runtimePrefabRule;
 }
コード例 #20
0
        void Reset()
        {
            VegetationSystemPro vegetationSystemPro = this.GetComponent <VegetationSystemPro>();

            if (vegetationSystemPro)
            {
                AreaRect = RectExtension.CreateRectFromBounds(vegetationSystemPro.VegetationSystemBounds);
            }
        }
コード例 #21
0
            public void OnGUI(Layout layout, bool selected, int num, object parent)
            {
                                #if VEGETATION_STUDIO_PRO
                VSProObjectsOutput   vsOut   = (VSProObjectsOutput)parent;
                VegetationPackagePro package = vsOut.package;                  //(VegetationPackagePro)vsOut.serializedPackage;
                VegetationSystemPro  system  = GameObject.FindObjectOfType <VegetationSystemPro>();
                Layer layer = vsOut.baseLayers[num];

                layout.margin = 20; layout.rightMargin = 5;
                layout.Par(20);

                input.DrawIcon(layout);

                if (package != null)
                {
                    int itemInfoIndex = package.VegetationInfoList.FindIndex(i => i.VegetationItemID == layer.id);
                    VegetationItemInfoPro itemInfo = itemInfoIndex >= 0 ? package.VegetationInfoList[itemInfoIndex] : null;

                    Texture2D icon = null;
                    if (itemInfo != null)
                    {
                                                #if UNITY_EDITOR
                        if (itemInfo.PrefabType == VegetationPrefabType.Mesh)
                        {
                            icon = AssetPreviewCache.GetAssetPreview(itemInfo.VegetationPrefab);
                        }
                        else
                        {
                            icon = AssetPreviewCache.GetAssetPreview(itemInfo.VegetationTexture);
                        }
                                                #endif
                    }
                    layout.Icon(icon, rect: layout.Inset(20), frame: true, alphaBlend: false);
                    layout.Inset(10);

                    itemInfoIndex = layout.Popup(itemInfoIndex, objectNames, rect: layout.Inset(layout.field.width - 20 - 45));
                    if (itemInfoIndex >= 0)
                    {
                        layer.id = package.VegetationInfoList[itemInfoIndex].VegetationItemID;
                    }
                }

                if (selected)
                {
                    layout.Toggle(ref relativeHeight, "Relative Height");
                    layout.Toggle(ref rotate, "Rotate");
                    layout.Toggle(ref takeTerrainNormal, "Incline by Terrain");
                    layout.Par(); layout.Toggle(ref scale, "Scale", rect: layout.Inset(60));
                    layout.disabled = !scale;
                    layout.Toggle(ref scaleY, rect: layout.Inset(18)); layout.Label("Y only", rect: layout.Inset(45));                     //if (layout.lastChange) scaleU = false;
                    layout.disabled = false;
                }
                                #endif
            }
コード例 #22
0
 public void RemoveUnityTerrain()
 {
     if (system == null)
     {
         system = GameObject.FindObjectOfType <VegetationSystemPro>();
     }
     if (system != null)
     {
         system.RemoveTerrain(gameObject);
     }
 }
コード例 #23
0
 public static void OnVegetationCellRefresh(VegetationSystemPro vegetationSystem)
 {
     if (!Instance)
     {
         FindInstance();
     }
     if (Instance)
     {
         Instance.Internal_OnVegetationCellRefresh(vegetationSystem);
     }
 }
コード例 #24
0
ファイル: ColliderSystemPro.cs プロジェクト: d-oglesby/VS
 private void OnClearCacheVegetationCell(VegetationSystemPro vegetationSystemPro, VegetationCell vegetationCell)
 {
     for (int i = 0; i <= PackageColliderInfoList.Count - 1; i++)
     {
         VegetationPackageColliderInfo vegetationPackageColliderInfo = PackageColliderInfoList[i];
         for (int j = 0; j <= vegetationPackageColliderInfo.ColliderManagerList.Count - 1; j++)
         {
             ColliderManager colliderManager = vegetationPackageColliderInfo.ColliderManagerList[j];
             colliderManager?.VegetationItemSelector.RefreshVegetationCell(vegetationCell);
         }
     }
 }
コード例 #25
0
        /// <summary>
        ///  Internal function used by VegetationSystem components to unregister with the manager
        /// </summary>
        /// <param name="vegetationSystem"></param>
        public static void UnregisterVegetationSystem(VegetationSystemPro vegetationSystem)
        {
            if (!Instance)
            {
                FindInstance();
            }

            if (Instance)
            {
                Instance.Instance_UnregisterVegetationSystem(vegetationSystem);
            }
        }
コード例 #26
0
 /// <summary>
 /// Internal function used by VegetationSystem components to register with the manager
 /// </summary>
 /// <param name="vegetationSystem"></param>
 protected void Instance_RegisterVegetationSystem(VegetationSystemPro vegetationSystem)
 {
     if (!VegetationSystemList.Contains(vegetationSystem))
     {
         VegetationSystemList.Add(vegetationSystem);
         OnAddVegetationSystem(vegetationSystem);
         if (OnAddVegetationSystemDelegate != null)
         {
             OnAddVegetationSystemDelegate(vegetationSystem);
         }
     }
 }
コード例 #27
0
        public void Internal_OnVegetationCellRefresh(VegetationSystemPro vegetationSystem)
        {
            for (int i = 0; i <= _biomeMaskList.Count - 1; i++)
            {
                AddBiomeMaskToVegetationSystem(vegetationSystem, _biomeMaskList[i]);
            }

            for (int i = 0; i <= _vegetationMaskList.Count - 1; i++)
            {
                AddVegetationMaskToVegetationSystem(vegetationSystem, _vegetationMaskList[i]);
            }
        }
コード例 #28
0
ファイル: ColliderSystemPro.cs プロジェクト: d-oglesby/VS
        private void OnRenderComplete(VegetationSystemPro vegetationSystemPro)
        {
            if (PackageColliderInfoList.Count == 0)
            {
                return;
            }

            TestFloatingOrigin();

            Profiler.BeginSample("Collider system processing");
            JobHandleList.Clear();
            JobHandle cullingJobHandle = default(JobHandle);

            for (int i = 0; i <= PackageColliderInfoList.Count - 1; i++)
            {
                VegetationPackageColliderInfo vegetationPackageColliderInfo = PackageColliderInfoList[i];
                for (int j = 0; j <= vegetationPackageColliderInfo.ColliderManagerList.Count - 1; j++)
                {
                    ColliderManager colliderManager = vegetationPackageColliderInfo.ColliderManagerList[j];
                    if (colliderManager == null)
                    {
                        continue;
                    }

                    JobHandle itemCullingHandle = cullingJobHandle;

                    itemCullingHandle = colliderManager.VegetationItemSelector.ProcessInvisibleCells(itemCullingHandle);
                    itemCullingHandle = colliderManager.VegetationItemSelector.ProcessVisibleCells(itemCullingHandle);
                    itemCullingHandle = colliderManager.VegetationItemSelector.ProcessCulling(itemCullingHandle);
                    JobHandleList.Add(itemCullingHandle);
                }
            }

            JobHandle mergedHandle = JobHandle.CombineDependencies(JobHandleList);

            mergedHandle.Complete();

            for (int i = 0; i <= PackageColliderInfoList.Count - 1; i++)
            {
                VegetationPackageColliderInfo vegetationPackageColliderInfo = PackageColliderInfoList[i];
                for (int j = 0; j <= vegetationPackageColliderInfo.ColliderManagerList.Count - 1; j++)
                {
                    ColliderManager colliderManager = vegetationPackageColliderInfo.ColliderManagerList[j];
                    colliderManager?.VegetationItemSelector.ProcessEvents();
                }
            }
            Profiler.EndSample();
        }
コード例 #29
0
ファイル: ColliderSystemPro.cs プロジェクト: d-oglesby/VS
 private void OnClearCacheVegetationItem(VegetationSystemPro vegetationSystemPro, int vegetationPackageIndex,
                                         int vegetationItemIndex)
 {
     for (int i = 0; i <= PackageColliderInfoList.Count - 1; i++)
     {
         VegetationPackageColliderInfo vegetationPackageColliderInfo = PackageColliderInfoList[i];
         for (int j = 0; j <= vegetationPackageColliderInfo.ColliderManagerList.Count - 1; j++)
         {
             if (i == vegetationPackageIndex && j == vegetationItemIndex)
             {
                 ColliderManager colliderManager = vegetationPackageColliderInfo.ColliderManagerList[j];
                 colliderManager?.VegetationItemSelector.RefreshAllVegetationCells();
             }
         }
     }
 }
コード例 #30
0
    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);
        }
    }