public GrassEntitiesSet CreateGrassTuft() { //var tuftObj = new GameObject {name = "grassTuft"}; var elementsRange = RandomTuftGenerator.GetTuftElementsRange(); int elementsCount = RandomTuftGenerator.GetTuftCount(elementsRange); var anglesList = RandomTuftGenerator.GetRandomAngles(elementsCount, elementsRange.Max); float radiusFromCenter = 0.1f; List <GrassEntity> entities = new List <GrassEntity>(); foreach (var angle in anglesList) { float radiousRandomOffset = RandomTuftGenerator.GetPositionOffset(); var grassEntity = new GrassEntity { Position = new Vector3((radiusFromCenter + radiousRandomOffset) * (float)Math.Sin(angle), 0, (radiusFromCenter + radiousRandomOffset) * (float)Math.Cos(angle + 90)), Rotation = new Vector3(0, angle, 0), Scale = RandomGrassGenerator.GetScale(), }; entities.Add(grassEntity); } return(new GrassEntitiesSet(entities)); }
public override void SetSettings(GrassEntitiesSet aGrass) { var tuftHue = RandomGrassGenerator.GetHue(); var tuftValue = RandomGrassGenerator.GetValue(); var randomSaturation = RandomGrassGenerator.GetSaturation(); //todo use it MyRange basePlantBendingStiffness = RandomTuftGenerator.GetBasePlantBendingStiffness(); MyRange basePlantBendingValue = RandomTuftGenerator.GetBasePlantBendingValue(); ForeachEntity(aGrass, c => c.AddUniform(GrassShaderUniformName._PlantBendingStiffness, RandomTuftGenerator.GetPlantBendingStiffness(basePlantBendingStiffness))); ForeachEntity(aGrass, c => c.AddUniform(GrassShaderUniformName._InitialBendingValue, RandomTuftGenerator.GetPlantBendingValue(basePlantBendingValue))); ForeachEntity(aGrass, c => c.AddUniform(GrassShaderUniformName._Color, RandomGrassGenerator.GetGrassColor(tuftHue))); ForeachEntity(aGrass, c => c.AddUniform(GrassShaderUniformName._RandSeed, UnityEngine.Random.value)); }