示例#1
0
        private void CreateGrass2IntensityDb()
        {
            HabitatToGrassIntensityMapGenerator habitatToGrassIntensityMapGenerator =
                new HabitatToGrassIntensityMapGenerator(
                    _initializationFields.Retrive <ComputeShaderContainerGameObject>(),
                    _initializationFields.Retrive <UnityThreadComputeShaderExecutorObject>(),
                    _initializationFields.Retrive <CommonExecutorUTProxy>(),
                    _veConfiguration.HabitatToGrassIntensityMapGeneratorConfiguration);

            HabitatMapDbProxy habitatDbProxy = _initializationFields.Retrive <HabitatMapDbProxy>();

            var pathProximityTextureDbProxy = _initializationFields.Retrive <PathProximityTextureDbProxy>();

            var mapsGenerator = new Grass2IntensityMapGenerator(
                habitatToGrassIntensityMapGenerator,
                new HabitatTexturesGenerator(habitatDbProxy,
                                             _veConfiguration.HabitatTexturesGeneratorConfiguration,
                                             _initializationFields.Retrive <TextureConcieverUTProxy>()),
                _veConfiguration.Grass2IntensityMapGeneratorConfiguration,
                pathProximityTextureDbProxy);

            var db = new SpatialDb <List <Grass2TypeWithIntensity> >(mapsGenerator,
                                                                     _veConfiguration.Grass2IntensityDbConfiguration
                                                                     );

            var databaseProxy = new Grass2IntensityDbProxy(db);

            _ultraUpdatableContainer.AddOtherThreadProxy(databaseProxy);
            _ultraUpdatableContainer.AddOtherThreadProxy(habitatDbProxy);

            _initializationFields.SetField(databaseProxy);
        }
示例#2
0
        public HeightArrayDb(TerrainShapeDbProxy terrainShapeDb, CommonExecutorUTProxy commonExecutor)
        {
            TerrainTextureFormatTransformator transformator = new TerrainTextureFormatTransformator(commonExecutor);

            foreach (var resolution in TerrainCardinalResolution.AllResolutions)
            {
                SpatialDbConfiguration configuration = new SpatialDbConfiguration()
                {
                    QueryingCellSize =
                        VectorUtils.FillVector2(TerrainDescriptionConstants.DetailCellSizesPerResolution[resolution])
                };
                IStoredPartsGenerator <MySimpleArray <float> > partsGenerator =
                    new HeightArrayGenerator(terrainShapeDb, transformator, resolution);

                _resolutionDbs[resolution] = new SpatialDb <MySimpleArray <float> >(partsGenerator, configuration);
            }
        }
示例#3
0
        public void Start()
        {
            TaskUtils.SetGlobalMultithreading(false);

            var queryingArea = new MyRectangle(526 * 90, 582 * 90, 90, 90);


            HabitatToGrassIntensityMapGenerator habitatToGrassIntensityMapGenerator =
                new HabitatToGrassIntensityMapGenerator(ComputeShaderContainer,
                                                        new UnityThreadComputeShaderExecutorObject(), new CommonExecutorUTProxy(),
                                                        new HabitatToGrassIntensityMapGenerator.HabitatToGrassIntensityMapGeneratorConfiguration()
            {
                GrassTypeToSourceHabitats = new Dictionary <GrassType, List <HabitatType> >()
                {
                    { GrassType.Debug1, new List <HabitatType>()
                      {
                          HabitatType.Forest
                      } },
                    { GrassType.Debug2, new List <HabitatType>()
                      {
                          HabitatType.Meadow, HabitatType.Fell
                      } },
                },
                OutputPixelsPerUnit = 1
            });

            HabitatMapDbProxy habitatDbProxy = new HabitatMapDbProxy(new HabitatMapDb(
                                                                         new HabitatMapDb.HabitatMapDbInitializationInfo()
            {
                RootSerializationPath = @"C:\inz\habitating2\"
            }));

            var mapsGenerator = new Grass2IntensityMapGenerator(
                habitatToGrassIntensityMapGenerator,
                new HabitatTexturesGenerator(habitatDbProxy,
                                             new HabitatTexturesGenerator.HabitatTexturesGeneratorConfiguration()
            {
                HabitatMargin       = 5,
                HabitatSamplingUnit = 3
            }, new TextureConcieverUTProxy()),
                new Grass2IntensityMapGenerator.Grass2IntensityMapGeneratorConfiguration()
            {
                HabitatSamplingUnit = 3
            }, null);

            var db = new SpatialDb <List <Grass2TypeWithIntensity> >(mapsGenerator,
                                                                     new SpatialDbConfiguration()
            {
                QueryingCellSize = new Vector2(90, 90)
            });

            var retrivedMap = db.ProvidePartsAt(queryingArea).Result.CoordedPart.Part;

            Debug.Log("Ret: " + retrivedMap.Count);

            retrivedMap.Select(c => new Grass2TypeWithIntensity()
            {
                GrassType       = c.GrassType,
                IntensityFigure = c.IntensityFigure
            }).Select((c, i) =>
            {
                HabitatToGrassIntensityMapGeneratorDebugObject.CreateDebugObject(c, i);
                return(0);
            }).ToList();
        }
 public Grass2IntensityDbProxy(SpatialDb <List <Grass2TypeWithIntensity> > grassIntensityDb) : base(
         "Grass2IntensityDbProxyThread", false)
 {
     _grassIntensityDb = grassIntensityDb;
 }