Class GalaxyGenerator
BillboardDataset objects.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumGalaxy morphologies according to Edwin Hubble's classification. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.utils.JsonValueconvertToHybridJson(com.badlogic.ashley.core.Entity billboard, com.badlogic.ashley.core.Entity volume) Converts a hybrid galaxy into a JSON descriptor: the billboard entity with its compact emitters, and the child volume entity that carries the density fields of the diffuse channels.com.badlogic.gdx.utils.JsonValueconvertToJson(com.badlogic.ashley.core.Entity e) com.badlogic.gdx.utils.JsonValueconvertToJson(com.badlogic.ashley.core.Entity full, com.badlogic.ashley.core.Entity half) com.badlogic.gdx.utils.JsonValueconvertVolumeToJson(com.badlogic.ashley.core.Entity e) Converts the volume half of a hybrid galaxy into a JSON object.static com.badlogic.gdx.utils.JsonValuefieldsToJson(GalaxyAttributes[] fields) generateGalaxy(GalaxyGenerator.GalaxyMorphology gm, long seed) Generates galaxies given a morphology, as billboard datasets only.static StringgenerateGalaxySpec(GalaxyGenerator.GalaxyMorphology gm, long seed) Generates the complete description of a galaxy given a morphology: its billboard datasets and the volume fields that describe the same gas, bulge and dust analytically.double[]getRandomColors(double[][] colorMatrix) static StringtoJsonString(com.badlogic.gdx.utils.JsonValue json) Serialises a descriptor for export.
-
Constructor Details
-
GalaxyGenerator
public GalaxyGenerator()
-
-
Method Details
-
generateGalaxyName
-
generateGalaxy
public Pair<BillboardDataset[], BillboardDataset[]> generateGalaxy(GalaxyGenerator.GalaxyMorphology gm, long seed) Generates galaxies given a morphology, as billboard datasets only.- Parameters:
gm- The galaxy morphology.seed- The RNG seed.- Returns:
- A couple of
BillboardDatasetarrays, the first being the full-resolution channel, and the second being the half-resolution channel.
-
generateGalaxySpec
Generates the complete description of a galaxy given a morphology: its billboard datasets and the volume fields that describe the same gas, bulge and dust analytically.Both come from a single seeded draw, so the volume of a hybrid galaxy is the one its billboards describe. No extra random numbers are consumed when building the volume fields - they are copies of the descriptors this draw already produced - which is why a seed yields the same billboards as it did before the volume path existed.
- Parameters:
gm- The galaxy morphology. If null, one is picked at random and recorded in the spec.seed- The RNG seed.- Returns:
- The spec, which is never null.
-
getRandomColors
public double[] getRandomColors(double[][] colorMatrix) -
convertToJson
public com.badlogic.gdx.utils.JsonValue convertToJson(com.badlogic.ashley.core.Entity full, com.badlogic.ashley.core.Entity half) -
convertToHybridJson
public com.badlogic.gdx.utils.JsonValue convertToHybridJson(com.badlogic.ashley.core.Entity billboard, com.badlogic.ashley.core.Entity volume) Converts a hybrid galaxy into a JSON descriptor: the billboard entity with its compact emitters, and the child volume entity that carries the density fields of the diffuse channels.- Parameters:
billboard- The billboard entity of the pair.volume- The child volume entity of the pair.- Returns:
- The descriptor, ready to be printed.
-
convertVolumeToJson
public com.badlogic.gdx.utils.JsonValue convertVolumeToJson(com.badlogic.ashley.core.Entity e) Converts the volume half of a hybrid galaxy into a JSON object.A volume entity is a plain
Volumearchetype: a unit sphere scaled by the body size, with the galaxy shader and the field list thatVolumeInitializervoxelises at load time. No material is written: a procedural volume without one gets a default material, which is exactly what this galaxy was built with.- Parameters:
e- The volume entity.- Returns:
- The descriptor of the entity.
-
toJsonString
Serialises a descriptor for export.Deliberately not
JsonValue.toJson(JsonWriter.OutputType): that path prints a whole double as an integer literal (0.0becomes0, seeJsonValue.toJson(OutputType, Writer)), sopositionPcand every otherdoubleattribute comes back from the file as aLong/int[]and the loader finds nosetPositionPc(double[]). Pretty printing keeps the decimal point, and is easier to read and hand-edit besides.- Parameters:
json- The descriptor.- Returns:
- The JSON text.
-
fieldsToJson
-
convertToJson
public com.badlogic.gdx.utils.JsonValue convertToJson(com.badlogic.ashley.core.Entity e)
-