Guest User

Untitled

a guest
May 24th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. // Tree Wind Sway Recalculator (Central)
  2. // Recalculates vertex colors based on the proximity to center.
  3. // Allows limiting sway with an adjustable multiplier.
  4.  
  5. var sway = 0.2f; // Sway multiplier 0.0 (none) to 1.0 (max)
  6.  
  7. var bias = 1.6f; // "Contrast" between center and outer parts,
  8. // increasing this will make the middle more static,
  9. // and the outside move more.
  10.  
  11.  
  12. var asset = ToolsModifierControl.toolController.m_editPrefabInfo as TreeInfo;
  13. Vector3[] vertices = asset.m_mesh.vertices; Color[] colors = new Color[vertices.Length];
  14. for (int i = 0; i < vertices.Length; i++)
  15. colors[i] = new Color(0f, 0f, 0f, Mathf.Clamp((Mathf.Pow(Mathf.Sqrt(vertices[i].x * vertices[i].x + vertices[i].z * vertices[i].z), bias) / Mathf.Pow(bias, bias) * (sway/Mathf.Pow(bias, bias))), 0.0f, 1.0f));
  16. asset.m_mesh.colors = colors;
Add Comment
Please, Sign In to add comment