C# Class ProceduralGenerationOnMesh, gmap377_leathGloves_inc

Generates a poisson distribution on the mesh.
Inheritance: MonoBehaviour
Afficher le fichier Open project: bi3mer/gmap377_leathGloves_inc

Méthodes publiques

Свойство Type Description
planetName string
serializedSamplePointsByPlanet serializedInformation>.Dictionary

Méthodes publiques

Méthode Description
InstantiateBasedOnPlayerLocation ( ) : void

Depending on player location, it will pull objects from the object pool and set them to appear in the chunks that the player can see. Chunks that are too far away will be deactivated and the objects sent back into the pool.

LoadPlanet ( ) : void
activateChunk ( long key ) : void

Activates the chunk by pulling from the object pool and activating those objects within the chunk.

disableChunk ( long key ) : void

Disables the chunk and send objects back into object pool.

generateAll ( ) : IEnumerator

Generates objects at eaach sample point at once.

generateInitialObjects ( ) : void

Generates the initial pool of objects to be used in chunk by chunk generation.

generateObjectsByName ( ) : void

Generates the objects in the objectsByName pool. To be used during reloading sample points from save file.

generatePoisson ( float minDistance, int newPointsCount ) : List>.Dictionary

Generates the poisson sampling points that can be used to determine where to place objects.

generateRandomPointAround ( int triangleIndex, List triangles, List uvsToTriangles, float minDistance ) : ProceduralGenerationPoint,

Generates the random point around an existing point.

getColorAtTriangle ( ProceduralGenerationPoint, point ) : Color

Gets the color at a location.

getColorChance ( Color c ) : Vector2

Gets the chance for an object to be created at a certain size based on the color of the point in heatmap.

getDensity ( Color c ) : float

Gets the density value for a color. This is determined by how dark the color is, which is determined her by how close the average of the 3 RBG values. Brightest algorithm: brightness = sqrt( .241 R2 + .691 G2 + .068 B2 )

getInterpolation ( Vector3 triangle ) : Vector3

Gets the point on the face of the triangle given a triangle represented by 3 location points.

getSize ( Vector2 colorChances ) : float

Gets the size that the object should be based on the heatmap.

inRange ( Vector2 pos1, Vector2 pos2, float minDist ) : bool

Is too close to another object. Calculated based upon isophotic distance

meshPointToUv ( ProceduralGenerationPoint, point ) : Vector2

Turns a Vector3 position on the mesh to a Vector2 uv point.

overlappingPoint ( ProceduralGenerationPoint>.Dictionary grid, ProceduralGenerationPoint, point, float minDistance, float cellSize, int triangle ) : bool

Checks the neighboring grid locations to see if there's an object that is too close to a certain point.

reconstructSamplePoints ( string name ) : void

Reconstructs the sample points after save file load.

serializeSamplePoints ( ) : void

Sets up the sample points for serialization.

toGrid ( Vector2 point, float minSize, long gridOffset ) : long

Takes in a uv point and returns a grid location. Can be used for grids of different sizes, for example the main point grid which keeps track of where each point generated is on the mesh, or for the chunk grid which divides up the mesh into sections for generation. The value returned is an long representation of a vector2. The x value is in the lower decimal places, and the y value is in the higher decimal places. How far apart the two numbers are is determined by the gridOffset. For example, if the gridOffset is 1000, that is, there can be up to 999 x values, then if x is 30, and y is 89, the value returned will be 89030.

waitForLoad ( ) : IEnumerator

Waits for loading of the save file so that on continue, it will wait until the file has been loaded before the procedural generation will be set off.

Private Methods

Méthode Description
Start ( ) : void
Update ( ) : void

Method Details

InstantiateBasedOnPlayerLocation() public méthode

Depending on player location, it will pull objects from the object pool and set them to appear in the chunks that the player can see. Chunks that are too far away will be deactivated and the objects sent back into the pool.
public InstantiateBasedOnPlayerLocation ( ) : void
Résultat void

LoadPlanet() public méthode

public LoadPlanet ( ) : void
Résultat void

activateChunk() public méthode

Activates the chunk by pulling from the object pool and activating those objects within the chunk.
public activateChunk ( long key ) : void
key long All sample points are hashed into chunks by the key. So this key will give a list of objects within a chunk.
Résultat void

disableChunk() public méthode

Disables the chunk and send objects back into object pool.
public disableChunk ( long key ) : void
key long Key.
Résultat void

generateAll() public méthode

Generates objects at eaach sample point at once.
public generateAll ( ) : IEnumerator
Résultat IEnumerator

generateInitialObjects() public méthode

Generates the initial pool of objects to be used in chunk by chunk generation.
public generateInitialObjects ( ) : void
Résultat void

generateObjectsByName() public méthode

Generates the objects in the objectsByName pool. To be used during reloading sample points from save file.
public generateObjectsByName ( ) : void
Résultat void

generatePoisson() public méthode

Generates the poisson sampling points that can be used to determine where to place objects.
public generatePoisson ( float minDistance, int newPointsCount ) : List>.Dictionary
minDistance float Minimum distance.
newPointsCount int Number of new points that should be generated around an existing point.
Résultat List>.Dictionary

generateRandomPointAround() public méthode

Generates the random point around an existing point.
public generateRandomPointAround ( int triangleIndex, List triangles, List uvsToTriangles, float minDistance ) : ProceduralGenerationPoint,
triangleIndex int Triangle index.
triangles List Triangles.
uvsToTriangles List Uvs to triangles.
minDistance float Minimum distance.
Résultat ProceduralGenerationPoint,

getColorAtTriangle() public méthode

Gets the color at a location.
public getColorAtTriangle ( ProceduralGenerationPoint, point ) : Color
point ProceduralGenerationPoint, Point.
Résultat Color

getColorChance() public méthode

Gets the chance for an object to be created at a certain size based on the color of the point in heatmap.
public getColorChance ( Color c ) : Vector2
c Color A color from the heatmap, c.
Résultat Vector2

getDensity() public méthode

Gets the density value for a color. This is determined by how dark the color is, which is determined her by how close the average of the 3 RBG values. Brightest algorithm: brightness = sqrt( .241 R2 + .691 G2 + .068 B2 )
public getDensity ( Color c ) : float
c Color C.
Résultat float

getInterpolation() public méthode

Gets the point on the face of the triangle given a triangle represented by 3 location points.
public getInterpolation ( Vector3 triangle ) : Vector3
triangle Vector3 A location.
Résultat Vector3

getSize() public méthode

Gets the size that the object should be based on the heatmap.
public getSize ( Vector2 colorChances ) : float
colorChances Vector2 There are 2 color chances passed in. If the random number is under the first threshold, then a small object is generated, /// if it's under the second then a medium object is generated. Otherwise, a large object is generated.
Résultat float

inRange() public méthode

Is too close to another object. Calculated based upon isophotic distance
public inRange ( Vector2 pos1, Vector2 pos2, float minDist ) : bool
pos1 Vector2 Pos1.
pos2 Vector2 Pos2.
minDist float
Résultat bool

meshPointToUv() public méthode

Turns a Vector3 position on the mesh to a Vector2 uv point.
public meshPointToUv ( ProceduralGenerationPoint, point ) : Vector2
point ProceduralGenerationPoint, Point.
Résultat Vector2

overlappingPoint() public méthode

Checks the neighboring grid locations to see if there's an object that is too close to a certain point.
public overlappingPoint ( ProceduralGenerationPoint>.Dictionary grid, ProceduralGenerationPoint, point, float minDistance, float cellSize, int triangle ) : bool
grid ProceduralGenerationPoint>.Dictionary Grid.
point ProceduralGenerationPoint, Point.
minDistance float Minimum distance.
cellSize float Cell size.
triangle int Triangle.
Résultat bool

reconstructSamplePoints() public méthode

Reconstructs the sample points after save file load.
public reconstructSamplePoints ( string name ) : void
name string Name of planet.
Résultat void

serializeSamplePoints() public méthode

Sets up the sample points for serialization.
public serializeSamplePoints ( ) : void
Résultat void

toGrid() public méthode

Takes in a uv point and returns a grid location. Can be used for grids of different sizes, for example the main point grid which keeps track of where each point generated is on the mesh, or for the chunk grid which divides up the mesh into sections for generation. The value returned is an long representation of a vector2. The x value is in the lower decimal places, and the y value is in the higher decimal places. How far apart the two numbers are is determined by the gridOffset. For example, if the gridOffset is 1000, that is, there can be up to 999 x values, then if x is 30, and y is 89, the value returned will be 89030.
public toGrid ( Vector2 point, float minSize, long gridOffset ) : long
point Vector2 Point.
minSize float Minimum size.
gridOffset long Grid offset.
Résultat long

waitForLoad() public méthode

Waits for loading of the save file so that on continue, it will wait until the file has been loaded before the procedural generation will be set off.
public waitForLoad ( ) : IEnumerator
Résultat IEnumerator

Property Details

planetName public_oe property

public string planetName
Résultat string

serializedSamplePointsByPlanet public_oe static_oe property

public static Dictionary serializedSamplePointsByPlanet
Résultat serializedInformation>.Dictionary