public static bool IsSpeedTree(EFoliageType type)
        {
            switch (type)
            {
            case EFoliageType.SPEEDTREE_GRASS:
            case EFoliageType.SPEEDTREE_TREE:
            case EFoliageType.SPEEDTREE_TREE_BILLBOARD:
                return(true);
            }


            return(false);
        }
        public static bool CanChangeType(FoliageType type, EFoliageType newType)
        {
            GameObject prefab = type.m_Prefab;
            // PrefabType prefabType = PrefabUtility.GetPrefabType(prefab);
            string path = AssetDatabase.GetAssetPath(prefab);

            if (IsSpeedTree(newType))
            {
                // We want to change to a SpeedTree type

                if (path.EndsWith(".spm") == false)
                {
                    FoliageLog.e("Can't change to SpeedTree foliage: " + type.m_Name + " since it's path does not end with '.spm'! It means that it's not a SpeedTree!");
                    return(false);
                }

                LODGroup group = prefab.GetComponent <LODGroup>();

                if (group == null)
                {
                    FoliageLog.e("Can't change to SpeedTree foliage: " + type.m_Name + " since it doesn't contain a 'LODGroup' component!");
                    return(false);
                }

                if (newType == EFoliageType.SPEEDTREE_TREE_BILLBOARD)
                {
                    bool containsBillboardRenderer = false;

                    LOD[] lods = group.GetLODs();

                    foreach (LOD lod in lods)
                    {
                        if (lod.renderers[0].GetComponent <BillboardRenderer>() != null)
                        {
                            containsBillboardRenderer = true;
                            break;
                        }
                    }

                    if (containsBillboardRenderer == false)
                    {
                        FoliageLog.e("Can't change to SpeedTree with billboard the foliage: " + type.m_Name + " since it doesn't contain a billboard renderer!");
                        return(false);
                    }
                }
            }

            // We're cool no error
            return(true);
        }
Ejemplo n.º 3
0
        public static float GetMaxDistance(EFoliageType type)
        {
            switch (type)
            {
            case EFoliageType.OTHER_GRASS:
            case EFoliageType.SPEEDTREE_GRASS:
                return(FOLIAGE_MAX_GRASS_DISTANCE);

            case EFoliageType.OTHER_TREE:
            case EFoliageType.SPEEDTREE_TREE:
            case EFoliageType.SPEEDTREE_TREE_BILLBOARD:
                return(FOLIAGE_MAX_TREE_DISTANCE);

            default:
                FoliageLog.Assert(false, "Wrong type!");
                return(FOLIAGE_MAX_GRASS_DISTANCE);
            }
        }
Ejemplo n.º 4
0
        public static float ClampDistance(EFoliageType type, float maxViewDistance)
        {
            switch (type)
            {
            case EFoliageType.OTHER_GRASS:
            case EFoliageType.SPEEDTREE_GRASS:
                return(Mathf.Clamp(maxViewDistance, 0, FOLIAGE_MAX_GRASS_DISTANCE));

            case EFoliageType.OTHER_TREE:
            case EFoliageType.SPEEDTREE_TREE:
            case EFoliageType.SPEEDTREE_TREE_BILLBOARD:
                return(Mathf.Clamp(maxViewDistance, 0, FOLIAGE_MAX_TREE_DISTANCE));

            default:
                FoliageLog.Assert(false, "Wrong type!");
                return(Mathf.Clamp(maxViewDistance, 0, FOLIAGE_MAX_GRASS_DISTANCE));
            }
        }