void Start() { IcosphereGenerator icosphereGen = GetComponent <IcosphereGenerator>(); GeneralMethods met = GetComponent <GeneralMethods>(); Mesh mesh = icosphereGen.CreateIcosphere(true); mesh.vertices = met.Randomize(mesh.vertices, maxRandomDistance); float r = Random.Range(0.0F, 1.0F); float yScale; if (r < shortBushChance) { // round bush yScale = Random.Range(0.8F, 1.0F); } else { // tall bush yScale = Random.Range(1.8F, 2.2F); } mesh.vertices = met.ApplyTransformation(mesh.vertices, met.Translate(0.0F, 0.5F * yScale * bushScale, 0.0F) * met.Scale(bushScale, bushScale * yScale, bushScale)); mesh = met.ConvertToFlat(mesh); GetComponent <MeshFilter>().mesh = mesh; GetComponent <Renderer>().material.color = bushColor; GetComponent <Renderer>().material.SetFloat("_Glossiness", 0.0F); }
private void Render() { IcosphereGenerator.GenerateSphere(resolution, mesh, color); _sphereRendered = true; //transform.localScale = new Vector3 (vdwRadius, vdwRadius, vdwRadius); //sphereTransform.localScale = new Vector3 (vdwToSphereRatio, vdwToSphereRatio, vdwToSphereRatio); }
void Start() { IcosphereGenerator icosphereGen = GetComponent <IcosphereGenerator>(); GeneralMethods met = GetComponent <GeneralMethods>(); Mesh mesh; float r = Random.Range(0.0F, 1.0F); if (r < smallRockChance) { // small rock mesh = icosphereGen.CreateIcosphere(false); mesh.vertices = met.Randomize(mesh.vertices, maxRandomDistance); mesh.vertices = met.ApplyTransformation(mesh.vertices, met.Scale(smallRockScale, smallRockScale, smallRockScale)); } else { // big rock mesh = icosphereGen.CreateIcosphere(true); mesh.vertices = met.Randomize(mesh.vertices, maxRandomDistance); mesh.vertices = met.ApplyTransformation(mesh.vertices, met.Scale(bigRockScale, bigRockScale, bigRockScale)); } for (int i = 0; i < 3; i++) { r = Random.Range(0.0F, 1.0F); if (r < randomScaleChance) { float scale = Random.Range(1.0F, maxRandomScale); Matrix4x4 mat; switch (i) { case 1: mat = met.Scale(scale, 1.0F, 1.0F); break; case 2: mat = met.Scale(1.0F, scale, 1.0F); break; default: mat = met.Scale(1.0F, 1.0F, scale); break; } mesh.vertices = met.ApplyTransformation(mesh.vertices, mat); } } mesh = met.ConvertToFlat(mesh); GetComponent <MeshFilter>().mesh = mesh; GetComponent <Renderer>().material.color = rockColor; GetComponent <Renderer>().material.SetFloat("_Glossiness", 0.0F); }
void Start() { icosphereGen = GetComponent <IcosphereGenerator>(); met = GetComponent <GeneralMethods>(); Mesh mesh = GenerateTree(iterationCount); mesh = met.ConvertToFlat(mesh); GetComponent <MeshFilter>().mesh = mesh; Shader standard = Shader.Find("Standard"); Material trunkMaterial = new Material(standard); Material leavesMaterial = new Material(standard); trunkMaterial.color = trunkColor; leavesMaterial.color = leavesColor; trunkMaterial.SetFloat("_Glossiness", 0.0F); leavesMaterial.SetFloat("_Glossiness", 0.0F); GetComponent <Renderer>().materials = new Material[] { trunkMaterial, leavesMaterial }; }
public void Render() { IcosphereGenerator.GenerateSphere(resolution, mesh, color); }