ProceduralPlanets
ProceduralPlanets.PlanetManager Class Reference

PlanetManager is a required component that must exist as a single instance in all scenes where ProceduralPlanets are used. More...

Public Types

enum  DebugLevels {
  Off = 0,
  Basic = 1,
  Detailed = 2,
  Full = 3
}
 
enum  MeshDetailModes {
  Static,
  LOD
}
 
enum  TextureDetailModes {
  Static,
  Static_Separate,
  Progressive,
  Progressive_Separate,
  LOD,
  LOD_Separate
}
 

Static Public Member Functions

static void Initialize ()
 Force initialization of PlanetManager if it is not already initialized. More...
 
static Planet CreatePlanet (Vector3 _position, string _jsonString)
 Creates a planet using a JSON-string. More...
 
static Planet CreatePlanet (Vector3 _position, int _planetSeed=-1, string _blueprintName="", string _jsonString=null)
 Creates a planet. More...
 
static string ExportAllBlueprints (StringFormat _stringFormat=StringFormat.JSON_ESCAPED)
 Exports all planet blueprints (and any child ring blueprints) to a JSON string. More...
 
static void ImportBlueprints (string _jsonString)
 Imports planet blueprints (and related ring blueprints) from a JSON string. More...
 

Properties

static Camera cameraLOD [get, set]
 Gets or sets the camera used for Level of Detail (LOD) determination. Default is Camera.main. More...
 
static MeshDetailModes MeshDetailMode [get, set]
 Sets or gets if a static (MeshDetailModes.Static) sized mesh or 2 or more Level Of Detail (MeshDetailModes.LOD) meshes should be used for planets. More...
 
static int MeshStaticSubdivisions [get, set]
 Specifies the static mesh subdivisions level (Valid values: 0 - 6). More...
 
static int MeshLODSteps [get, set]
 Specifies the number of LOD steps that should be used if MeshDetailMode.LOD is used. Valid values = 2-5. More...
 
static int [] MeshLODSubdivisions [get, set]
 Array of Level of Detail (LOD) subdivisions levels. Valid values in array: 0 - 6.


The first entry in array is highest level of detail, last entry in array is lowest level of detail. More...
 
static float [] MeshLODPlanetSizes [get, set]
 Array of Level of Detail (LOD) planet size levels. Valid values in array = 0.0f and up The first entry in array is highest level of detail, last entry in array is lowest level of detail. More...
 
static Mesh [] MeshLODMeshes [get]
 (Read-only) Array of meshes for Level of Detail (LOD) levels. This is automatically created when specifying More...
 
static TextureDetailModes TextureDetailMode [get, set]
 Texture detail mode specifies how textures should be generated. Planets consists of multiple textures (e.g. Composition Texture, 2 x Biome Textures, Clouds Texture, etc.). More...
 
static int TextureStaticCommon [get, set]
 Gets or sets texture resolution for all textures when TextureDetailMode is set to TextureDetailModes.Static More...
 
static int TextureStaticComposition [get, set]
 Gets or sets texture resolution for Composition texture when TextureDetailMode is set to TextureDetailModes.Static_Separate. More...
 
static int TextureStaticBiome [get, set]
 Gets or sets texture resolution for Biome texture when TextureDetailMode is set to TextureDetailModes.Static_Separate. More...
 
static int TextureStaticClouds [get, set]
 Gets or sets texture resolution for Clouds texture when TextureDetailMode is set to TextureDetailModes.Static_Separate. More...
 
static int TextureStaticCities [get, set]
 Gets or sets texture resolution for Cities texture when TextureDetailMode is set to TextureDetailModes.Static_Separate. More...
 
static int TextureStaticLava [get, set]
 Gets or sets texture resolution for Lava texture when TextureDetailMode is set to TextureDetailModes.Static_Separate. More...
 
static int TextureStaticPolarIce [get, set]
 Gets or sets texture resolution for PolarIce texture when TextureDetailMode is set to TextureDetailModes.Static_Separate. More...
 
static int TextureStaticGas [get, set]
 Gets or sets texture resolution for Gas texture when TextureDetailMode is set to TextureDetailModes.Static_Separate. More...
 
static int TextureProgressiveSteps [get, set]
 Gets or sets the number of steps / levels for progressive texture resolutions.. More...
 
static int [] TextureProgressiveCommon [get, set]
 Gets or sets the array of texture resolution levels for progressive textures when TextureDetailMode = TextureDetailModes.Progressive More...
 
static int [] TextureProgressiveComposition [get, set]
 Gets or sets the array of texture resolution levels for Composition progressive textures when TextureDetailMode = TextureDetailModes.Progressive_Separate More...
 
static int [] TextureProgressiveBiome [get, set]
 Gets or sets the array of texture resolution levels for Biome progressive textures when TextureDetailMode = TextureDetailModes.Progressive_Separate More...
 
static int [] TextureProgressiveClouds [get, set]
 Gets or sets the array of texture resolution levels for Clouds progressive textures when TextureDetailMode = TextureDetailModes.Progressive_Separate More...
 
static int [] TextureProgressiveCities [get, set]
 Gets or sets the array of texture resolution levels for Cities progressive textures when TextureDetailMode = TextureDetailModes.Progressive_Separate More...
 
static int [] TextureProgressiveLava [get, set]
 Gets or sets the array of texture resolution levels for Lava progressive textures when TextureDetailMode = TextureDetailModes.Progressive_Separate More...
 
static int [] TextureProgressivePolarIce [get, set]
 Gets or sets the array of texture resolution levels for PolarIce progressive textures when TextureDetailMode = TextureDetailModes.Progressive_Separate More...
 
static int [] TextureProgressiveGas [get, set]
 Gets or sets the array of texture resolution levels for Gas progressive textures when TextureDetailMode = TextureDetailModes.Progressive_Separate More...
 
static int TextureLODSteps [get, set]
 Specifies the number of Level Of Detail (LOD) steps that should be used if TextureDetailMode.LOD or TextureDetailMode.LOD_Separate is used. Valid values = 2-5. More...
 
static int [] TextureLODCommon [get, set]
 Gets or sets the texture LOD Common texture resolutions array. More...
 
static int [] TextureLODComposition [get, set]
 Gets or sets the texture LOD Composition texture resolutions array. More...
 
static int [] TextureLODBiome [get, set]
 Gets or sets the texture LOD Biome texture resolutions array. More...
 
static int [] TextureLODClouds [get, set]
 Gets or sets the texture LOD Clouds texture resolutions array. More...
 
static int [] TextureLODCities [get, set]
 Gets or sets the texture LOD Composition texture resolutions array. More...
 
static int [] TextureLODLava [get, set]
 Gets or sets the texture LOD Lava texture resolutions array. More...
 
static int [] TextureLODPolarIce [get, set]
 Gets or sets the texture LOD PolarIce texture resolutions array. More...
 
static int [] TextureLODGas [get, set]
 Gets or sets the texture LOD Gas texture resolutions array. More...
 
static float [] TextureLODPlanetSizes [get, set]
 Array of Level of Detail (LOD) planet size levels. Valid values in array = 0.0f and up The first entry in array is highest level of detail, last entry in array is lowest level of detail. More...
 
static DebugLevels DebugLevel [get, set]
 Sets the debug level. This affects the output to console event log during runtime and for scripts executing in edit mode. More...
 
static bool IsInitialized [get]
 Gets a value indicating whether this T:ProceduralPlanets.PlanetManager is initialized. More...
 
- Properties inherited from ProceduralPlanets.Singleton< PlanetManager >
static T Instance [get]
 

Public Member Functions

void RefreshLists ()
 Refreshes planet blueprint lists bases on the children of the Manager. It ensures there are no blueprint duplicate names. More...
 
void RefreshBlueprintDictionary ()
 Refreshes the blueprint dictionary which is used to store probability of each blueprint in relation of one another (so some planet types can be more common than others) More...
 
BlueprintRing GetRingBlueprintByPlanetBlueprintName (string _planetBlueprintName)
 Gets the ring blueprint by parent planet blueprint name More...
 
int GetPlanetBlueprintIndexByName (string _name)
 Gets the index number of a planet blueprint based on the blueprint name (could be either solid or gas planet) More...
 
string GetPlanetBlueprintNameByIndex (int _index, Object _caller)
 Gets the planet blueprint name by index in a blueprint list More...
 
BlueprintPlanet GetPlanetBlueprintByIndex (int _index, Object _caller)
 Gets the planet blueprint by index in a blueprint list. More...
 
void ExportAllBlueprintsToClipboard ()
 Exports all planet blueprints (and any child ring blueprints) to clipboard as a JSON string. More...
 
void ImportBlueprintsFromClipboard ()
 Imports blueprints from clipboard. More...
 
string GetUniqueBlueprintName ()
 Gets ta new unique blueprint name More...
 
ProceduralMaterial GetUniqueProceduralMaterial (ProceduralMaterial _proceduralMaterial, GameObject _gameObject, string _mapName)
 
void RecreateProceduralMeshes ()
 Creates procedural meshes (including configured Level of Detail (LOD) versions used by planets as shared meshes. More...
 
void RebuildAllPlanetTextures (bool _force=false)
 Rebuilds all planet textures. More...
 
int GetAppropriateMeshLODLevel (float _percent)
 Gets the appropriate Mesh LOD level based on planet size on screen (planet percent = planet diameter to screen height ratio). More...
 
int GetAppropriateTextureLODLevel (float _percent)
 Gets the appropriate Texture LOD level based on planet size on screen (planet percent = planet diameter to screen height ratio). More...
 
void RecreateGenericBlueprint ()
 Recreates a generic blueprint used to add rings to planet without ring blueprint. Public so editor script can call this method. More...
 
- Public Member Functions inherited from ProceduralPlanets.Singleton< PlanetManager >
virtual void Awake ()
 

Public Attributes

const float CONST_MESH_RADIUS = 5.0f
 
const int TEXTURE_RESOLUTION_COUNT = 8
 
const string GENERIC_PLANET_BLUEPRINT_NAME = "Generic Planet Blueprint"
 
int [] _meshLODSubdivisions = new int[5] { 6, 5, 4, 3, 2 }
 
float [] _meshLODPlanetSizes = new float[4] { 0.8f, 0.3f, 0.01f, 0.05f }
 
List< BlueprintSolidPlanetlistSolidPlanetBlueprints = new List<BlueprintSolidPlanet>(0)
 
List< BlueprintGasPlanetlistGasPlanetBlueprints = new List<BlueprintGasPlanet>(0)
 
List< ProceduralMaterial > solidCompositionMaterials = new List<ProceduralMaterial>(0)
 
List< ProceduralMaterial > solidBiomeMaterials = new List<ProceduralMaterial>(0)
 
List< ProceduralMaterial > solidCloudsMaterials = new List<ProceduralMaterial>(0)
 
List< ProceduralMaterial > solidCitiesMaterials = new List<ProceduralMaterial>(0)
 
List< ProceduralMaterial > solidLavaMaterials = new List<ProceduralMaterial>(0)
 
List< ProceduralMaterial > solidPolarIceMaterials = new List<ProceduralMaterial>(0)
 
List< ProceduralMaterial > gasMaterials = new List<ProceduralMaterial>(0)
 
List< ProceduralMaterial > ringMaterials = new List<ProceduralMaterial>(0)
 
List< ProceduralMaterial > substanceDuplicates = new List<ProceduralMaterial>(0)
 
bool showEditorMeshLOD = false
 
bool showEditorTextureLOD = false
 

Detailed Description

PlanetManager is a required component that must exist as a single instance in all scenes where ProceduralPlanets are used.

The PlanetManager is a Singleton class and can only exist as one instance. It also uses DontDestroyOnLoad so once it is created it will persist in all scenes and survive scene switching until you manually destroy the PlanetManager.

The PlanetManager has the following main purposes:

Configuration

  • Keeps track of Planet Blueprints (a blueprint controls ranges for random values for planet types)
  • Keeps references to Procedural Materials that are used to generate planet textures
  • Keeps track of probability of blueprints being used when creating random planets
  • Keeps track of Level of Detail(LOD) for planet mesh and texture details
  • Has one(or more) procedurally generated spherical meshes that planets share
  • Enables creation of planets from scripts using public static methods

Public Static Methods
Main methods used to create planets from scripts:

See also
CreatePlanet(Vector3, string), CreatePlanet(Vector3, int, string, string), ExportAllBlueprints(StringFormat), ImportBlueprints(string)

Utilities:

The PlanetManager also has a range of public properties that can be used to control level of detail for planet meshes annd texture resolitions.

See also
MeshDetailMode, TextureDetailMode

Version 1.0 - 2018 (c) Imphenzia AB - Author: Stefan Persson

Inheritance diagram for ProceduralPlanets.PlanetManager:
ProceduralPlanets.Singleton< PlanetManager >

The documentation for this class was generated from the following file: