C# 클래스 ProceduralGenerationOnMesh, gmap377_leathGloves_inc

Generates a poisson distribution on the mesh.
상속: MonoBehaviour
파일 보기 프로젝트 열기: bi3mer/gmap377_leathGloves_inc

공개 프로퍼티들

프로퍼티 타입 설명
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