/// ///////////////////////////////////////////////////////// /// Stretching /// ///////////////////////////////////////////////////////// // Set stretching static void SetStretching(RFShatter shatter, AxisType axis, float strength, FragType fragType) { // Get slab vector Vector3 stretchDir = DirectionAxis(axis); // Adjust for slabs if (fragType == FragType.Slabs) { Vector3 vector = new Vector3(); if (stretchDir.x <= 0) { vector.x = 1f; } if (stretchDir.x >= 1f) { vector.x = 0; } if (stretchDir.y <= 0) { vector.y = 1f; } if (stretchDir.y >= 1f) { vector.y = 0; } if (stretchDir.z <= 0) { vector.z = 1f; } if (stretchDir.z >= 1f) { vector.z = 0; } stretchDir = vector; } // Set stretch vector shatter.SetPoint3Parameter((int)RFShatter.FragmentParams.stretching, stretchDir * Mathf.Lerp(40f, 99f, strength)); }
// Set Custom Voronoi properties static void SetTet(RFShatter shatter, Bounds bounds, RFTets tets) { // Main shatter.SetFragmentParameter(RFShatter.FragmentParams.type, (int)RFShatter.FragmentType.tetra); shatter.SetFragmentParameter(RFShatter.FragmentParams.tetra_type, (int)tets.lattice); // Get max float max = bounds.size.x; if (bounds.size.y > max) { max = bounds.size.y; } if (bounds.size.z > max) { max = bounds.size.z; } if (max == 0) { max = 0.01f; } // Get density Vector3Int density = new Vector3Int( (int)Mathf.Ceil(bounds.size.x / max * tets.density), (int)Mathf.Ceil(bounds.size.y / max * tets.density), (int)Mathf.Ceil(bounds.size.z / max * tets.density)); // Limit if (density.x > 30) { density.x = 30; } else if (density.x < 1) { density.x = 1; } if (density.y > 30) { density.y = 30; } else if (density.y < 1) { density.y = 1; } if (density.z > 30) { density.z = 30; } else if (density.z < 1) { density.z = 1; } // Set density shatter.SetPoint3Parameter((int)RFShatter.FragmentParams.tetra2_density, density); shatter.SetPoint3Parameter((int)RFShatter.FragmentParams.tetra1_density, density); // Noise shatter.SetFragmentParameter(RFShatter.FragmentParams.tetra_noise, tets.noise); }