Created
August 21, 2015 17:32
-
-
Save predominant/ba8029f55414dc1d00e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void PlaneSplit1() { | |
Mesh mesh = this.GetMesh(); | |
Vector3[] vertices = mesh.vertices; | |
for (int pass = 0; pass < this.Passes; pass++) { | |
// Pick a random point in the Sphere | |
Vector3 splitVector = Random.insideUnitSphere; | |
for (int i = 0; i < mesh.vertices.Length; i++) { | |
// Get the DOT product of that random point | |
if (Vector3.Dot(splitVector, vertices[i].normalized - splitVector) > 0) { | |
// Move vertices out | |
vertices[i] *= (1 + this.Scale * 1.1f); | |
} else { | |
// Move vertices in | |
vertices[i] *= (1 - this.Scale); | |
} | |
} | |
} | |
mesh.vertices = vertices; | |
mesh.RecalculateNormals(); | |
mesh.RecalculateBounds(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment