Created
May 17, 2018 18:35
-
-
Save ronyx69/318eab7a17c9d6a38d123eba0cefaab7 to your computer and use it in GitHub Desktop.
Allows limiting wind sway effect for trees with an adjustable multiplier.
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
// Tree Wind Sway Recalculator | |
// Recalculates vertex colors based on the height. | |
// Allows limiting sway with an adjustable multiplier. | |
var sway = 0.69f; // Sway multiplier 0.0 (none) to 1.0 (max) | |
var asset = ToolsModifierControl.toolController.m_editPrefabInfo as TreeInfo; | |
Vector3[] vertices = asset.m_mesh.vertices; Color[] colors = new Color[vertices.Length]; | |
for (int i = 0; i < vertices.Length; i++) | |
colors[i] = new Color(0f, 0f, 0f, Mathf.Clamp(vertices[i].y/asset.m_mesh.bounds.max.y, 0.0f, 1.0f)*sway); | |
asset.m_mesh.colors = colors; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment