Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Tree Wind Sway Recalculator (Central)
- // Recalculates vertex colors based on the proximity to center.
- // Allows limiting sway with an adjustable multiplier.
- var sway = 0.2f; // Sway multiplier 0.0 (none) to 1.0 (max)
- var bias = 1.6f; // "Contrast" between center and outer parts,
- // increasing this will make the middle more static,
- // and the outside move more.
- 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((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));
- asset.m_mesh.colors = colors;
Add Comment
Please, Sign In to add comment