C# Класс ProceduralGenerationOnMesh, gmap377_leathGloves_inc

Generates a poisson distribution on the mesh.
Наследование: MonoBehaviour
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
planetName string
serializedSamplePointsByPlanet serializedInformation>.Dictionary

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
Start ( ) : void
Update ( ) : void

Описание методов

InstantiateBasedOnPlayerLocation() публичный Метод

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
Результат void

LoadPlanet() публичный Метод

public LoadPlanet ( ) : void
Результат void

activateChunk() публичный Метод

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.
Результат void

disableChunk() публичный Метод

Disables the chunk and send objects back into object pool.
public disableChunk ( long key ) : void
key long Key.
Результат void

generateAll() публичный Метод

Generates objects at eaach sample point at once.
public generateAll ( ) : IEnumerator
Результат IEnumerator

generateInitialObjects() публичный Метод

Generates the initial pool of objects to be used in chunk by chunk generation.
public generateInitialObjects ( ) : void
Результат void

generateObjectsByName() публичный Метод

Generates the objects in the objectsByName pool. To be used during reloading sample points from save file.
public generateObjectsByName ( ) : void
Результат void

generatePoisson() публичный Метод

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.
Результат List>.Dictionary

generateRandomPointAround() публичный Метод

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.
Результат ProceduralGenerationPoint,

getColorAtTriangle() публичный Метод

Gets the color at a location.
public getColorAtTriangle ( ProceduralGenerationPoint, point ) : Color
point ProceduralGenerationPoint, Point.
Результат Color

getColorChance() публичный Метод

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.
Результат Vector2

getDensity() публичный Метод

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.
Результат float

getInterpolation() публичный Метод

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.
Результат Vector3

getSize() публичный Метод

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.
Результат float

inRange() публичный Метод

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
Результат bool

meshPointToUv() публичный Метод

Turns a Vector3 position on the mesh to a Vector2 uv point.
public meshPointToUv ( ProceduralGenerationPoint, point ) : Vector2
point ProceduralGenerationPoint, Point.
Результат Vector2

overlappingPoint() публичный Метод

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.
Результат bool

reconstructSamplePoints() публичный Метод

Reconstructs the sample points after save file load.
public reconstructSamplePoints ( string name ) : void
name string Name of planet.
Результат void

serializeSamplePoints() публичный Метод

Sets up the sample points for serialization.
public serializeSamplePoints ( ) : void
Результат void

toGrid() публичный Метод

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.
Результат long

waitForLoad() публичный Метод

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
Результат IEnumerator

Описание свойств

planetName публичное свойство

public string planetName
Результат string

serializedSamplePointsByPlanet публичное статическое свойство

public static Dictionary serializedSamplePointsByPlanet
Результат serializedInformation>.Dictionary