public void Start()
        {
            TaskUtils.SetGlobalMultithreading(false);

            _debugGrassPlanterUnderTest = new DebugBushPlanterUnderTest();
            _debugGrassPlanterUnderTest.Start(ComputeShaderContainer);
            var grassGroupsPlanter = _debugGrassPlanterUnderTest.GrassGroupsPlanter;

            var generationArea = new MyRectangle(0, 0, 90, 90);

            var randomFigureGenerator = new RandomFieldFigureGeneratorUTProxy(
                new Ring2RandomFieldFigureGenerator(new TextureRenderer(),
                                                    new Ring2RandomFieldFigureGeneratorConfiguration()
            {
                PixelsPerUnit = new Vector2(1, 1)
            }));
            var randomFigure = randomFigureGenerator.GenerateRandomFieldFigureAsync(
                RandomFieldNature.FractalSimpleValueNoise3, 312,
                new MyRectangle(0, 0, 30, 30)).Result;

            var intensityFigureProvider = new IntensityFromRandomFiguresCompositionProvider(
                PoissonDiskSamplingDebugObject.CreateDebugRandomFieldFigure(),
                randomFigure, 0.3f);

            grassGroupsPlanter.AddGrassGroup(generationArea, GrassType.Debug1, intensityFigureProvider);

            _debugGrassPlanterUnderTest.FinalizeStart();
            CreateDebugIntensityTexture(intensityFigureProvider);
        }
        public static GRing2PatchesCreator CreateRing2PatchesCreator(UltraUpdatableContainer updatableContainer, Dictionary <int, float> intensityPatternPixelsPerUnit)
        {
            TextureConcieverUTProxy conciever = new TextureConcieverUTProxy();

            updatableContainer.Add(conciever);

            Ring2RandomFieldFigureGenerator figureGenerator = new Ring2RandomFieldFigureGenerator(new TextureRenderer(),
                                                                                                  new Ring2RandomFieldFigureGeneratorConfiguration()
            {
                PixelsPerUnit = new Vector2(1, 1)
            });
            var utFigureGenerator = new RandomFieldFigureGeneratorUTProxy(figureGenerator);

            updatableContainer.Add(utFigureGenerator);

            var randomFieldFigureRepository = new Ring2RandomFieldFigureRepository(utFigureGenerator,
                                                                                   new Ring2RandomFieldFigureRepositoryConfiguration(2, new Vector2(20, 20)));

            Quadtree <Ring2Region> regionsTree = Ring2TestUtils.CreateRegionsTreeWithPath3(randomFieldFigureRepository);

            return(new GRing2PatchesCreator(
                       new MonoliticRing2RegionsDatabase(regionsTree),
                       new GRing2RegionsToPatchTemplateConventer(),
                       new Ring2PatchTemplateCombiner(),
                       new Ring2PatchCreator(),
                       new Ring2IntensityPatternProvider(conciever),
                       new GRing2Deviser(),
                       new Ring2PatchesOverseerConfiguration()
            {
                IntensityPatternPixelsPerUnit = intensityPatternPixelsPerUnit
            }
                       ));
        }
        private GRing2PatchesCreator CreateRing2PatchesCreator()
        {
            var ring2ShaderRepository = Ring2PlateShaderRepository.Create();

            TextureConcieverUTProxy conciever = new TextureConcieverUTProxy();

            _updatableContainer.AddUpdatableElement(conciever);

            _ring2PatchesPainterUtProxy = new Ring2PatchesPainterUTProxy(
                new Ring2PatchesPainter(
                    new Ring2MultishaderMaterialRepository(ring2ShaderRepository, Ring2ShaderNames.ShaderNames)));
            _updatableContainer.AddUpdatableElement(_ring2PatchesPainterUtProxy);

            Ring2RandomFieldFigureGenerator figureGenerator = new Ring2RandomFieldFigureGenerator(new TextureRenderer(),
                                                                                                  new Ring2RandomFieldFigureGeneratorConfiguration()
            {
                PixelsPerUnit = new Vector2(2, 2)
            });
            var utFigureGenerator = new RandomFieldFigureGeneratorUTProxy(figureGenerator);

            _updatableContainer.AddUpdatableElement(utFigureGenerator);

            var randomFieldFigureRepository = new Ring2RandomFieldFigureRepository(utFigureGenerator,
                                                                                   new Ring2RandomFieldFigureRepositoryConfiguration(2, new Vector2(20, 20)));

            Quadtree <Ring2Region> regionsTree = Ring2TestUtils.CreateRegionsTreeWithPath3(randomFieldFigureRepository);

            return(new GRing2PatchesCreator(
                       new MonoliticRing2RegionsDatabase(regionsTree),
                       new GRing2RegionsToPatchTemplateConventer(),
                       new Ring2PatchTemplateCombiner(),
                       new Ring2PatchCreator(),
                       new Ring2IntensityPatternProvider(conciever),
                       new GRing2Deviser(),
                       new Ring2PatchesOverseerConfiguration()
            {
                IntensityPatternPixelsPerUnit = new Dictionary <int, float>()
                {
                    { 1, 1 }
                }
                //PatchSize = new Vector2(90, 90)
            }
                       ));
        }
Beispiel #4
0
        public void Start()
        {
            TaskUtils.SetGlobalMultithreading(false);
            var generationArea  = new MyRectangle(0, 0, 100, 100);
            var generationCount = 7;
            var exRadius        = 2;

            var msw = new MyStopWatch();

            var randomFigureGenerator = new RandomFieldFigureGeneratorUTProxy(
                new Ring2RandomFieldFigureGenerator(new TextureRenderer(),
                                                    new Ring2RandomFieldFigureGeneratorConfiguration()
            {
                PixelsPerUnit = new Vector2(1, 1)
            }));
            var randomFigure = randomFigureGenerator.GenerateRandomFieldFigureAsync(
                RandomFieldNature.FractalSimpleValueNoise3, 312,
                new MyRectangle(0, 0, 30, 30)).Result;

            //var intensityFigureProvider =  new IntensityFromRandomFigureProvider(randomFigure);
            //var intensityFigureProvider =  new IntensityFromRandomFigureProvider(CreateDebugRandomFieldFigure());
            var intensityFigureProvider = new IntensityFromRandomFiguresCompositionProvider(
                CreateDebugRandomFieldFigure(),
                randomFigure, 0.3f);

            msw.StartSegment("StartGeneration");

            var sampler         = new MultiIntensityPoissonDiskSampler();
            var generatedPoints = sampler.Generate(generationArea, generationCount, new MyRange(0.5f, 3),
                                                   new IntensityFromRandomFigureProvider(new IntensityFieldFigureWithUv()
            {
                FieldFigure = randomFigure,
                Uv          = new MyRectangle(0, 0, 1, 1)
            }), 100000);

            //var noCollision = new NoCollisionMultiIntensityPoissonDiskSampler();
            //var generatedPoints = noCollision.Generate(generationArea, generationCount, 2,80000, 6, intensityFigureProvider);


            //var classicPoisson = new PoissonDiskSampler();
            //var generatedPoints = classicPoisson.Generate(generationArea, generationCount, exRadius);


            //var simpleCollidable = new SimpleRandomSampler();
            //var generatedPoints = simpleCollidable.Generate(generationArea, 15000, 40000, 0.1f, false, intensityFigureProvider);


            Debug.Log($"T{generatedPoints.Count} generation took: " + msw.CollectResults());

            var root = new GameObject("RootPoints");

            foreach (var point in generatedPoints)
            {
                var cap = GameObject.CreatePrimitive(PrimitiveType.Capsule);
                cap.transform.position   = new Vector3(point.x, 0, point.y);
                cap.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
                cap.transform.SetParent(root.transform);
            }

            var newMaterial = new Material(Shader.Find("Standard"));

            newMaterial.SetTexture("_MainTex", Ring2RandomFieldFigureGenerator.DebugLastGeneratedTexture);
            DebugTextureObject.GetComponent <MeshRenderer>().material = newMaterial;
        }