public TerrainDetailProvider CreateTerrainDetailProvider(TerrainDetailGenerator generator)
        {
            var provider =
                new TerrainDetailProvider(generator, null, new TerrainDetailAlignmentCalculator(240));

            return(provider);
        }
Пример #2
0
        private TerrainDetailProvider CreateTerrainDetailProvider(List <RankedTerrainFeatureApplier> featureAppliers)
        {
            TerrainDetailGeneratorConfiguration generatorConfiguration = new TerrainDetailGeneratorConfiguration()
            {
                TerrainDetailImageSideDisjointResolution = 240
            };
            TextureWithCoords fullFundationData = new TextureWithCoords(new TextureWithSize()
            {
                Texture = MainTexture,
                Size    = new IntVector2(MainTexture.width, MainTexture.height)
            }, new MyRectangle(0, 0, 3601 * 24, 3601 * 24));

            TerrainDetailGenerator generator =
                new TerrainDetailGenerator(generatorConfiguration, _utTextureRendererProxy, fullFundationData,
                                           featureAppliers, new CommonExecutorUTProxy());

            var provider = new TerrainDetailProvider(generator, null, new TerrainDetailAlignmentCalculator(240));

            generator.SetBaseTerrainDetailProvider(BaseTerrainDetailProvider.CreateFrom(provider));
            return(provider);
        }
        public void Start()
        {
            TaskUtils.SetGlobalMultithreading(true);
            _computeShaderExecutorObject = new UnityThreadComputeShaderExecutorObject();
            _commonExecutorUtProxy       = new CommonExecutorUTProxy();
            _utTextureRendererProxy      = new UTTextureRendererProxy(new TextureRendererService(
                                                                          new MultistepTextureRenderer(ContainerGameObject), new TextureRendererServiceConfiguration()
            {
                StepSize = new Vector2(500, 500)
            }));

            var rgbaMainTexture = SavingFileManager.LoadPngTextureFromFile(@"C:\inz\cont\n49_e019_1arc_v3.png", 3600,
                                                                           3600,
                                                                           TextureFormat.ARGB32, true, false);


            TerrainTextureFormatTransformator transformator =
                new TerrainTextureFormatTransformator(_commonExecutorUtProxy);

            transformator.EncodedHeightTextureToPlainAsync(new TextureWithSize()
            {
                Size    = new IntVector2(3600, 3600),
                Texture = rgbaMainTexture
            }).ContinueWith(x =>
            {
                var mainTexture = x.Result;
                TerrainDetailGenerator generator = CreateTerrainDetailGenerator(new TextureWithSize()
                {
                    Size    = new IntVector2(3600, 3600),
                    Texture = mainTexture
                });
                TerrainDetailProvider terrainDetailProvider = CreateTerrainDetailProvider(generator);
                var db = FETerrainShapeDbInitialization.CreateTerrainShapeDb(terrainDetailProvider, _commonExecutorUtProxy,
                                                                             new TerrainDetailAlignmentCalculator(240), false, false, false, null);


                MyRectangle queryArea = null;
                if (_terrainResolution == TerrainCardinalResolution.MIN_RESOLUTION)
                {
                    queryArea = new MyRectangle(0, 0, 24 * 240, 24 * 240);
                }
                else if (_terrainResolution == TerrainCardinalResolution.MID_RESOLUTION)
                {
                    queryArea = new MyRectangle(3 * 240, 3 * 240, 3 * 240, 3 * 240);
                }
                else
                {
                    queryArea =
                        new MyRectangle(5 * 0.375f * 240, 5 * 0.375f * 240, 0.375f * 240, 0.375f * 240);
                }


                var outputOfGeneration = db.QueryAsync(new TerrainDescriptionQuery()
                {
                    QueryArea = queryArea,
                    RequestedElementDetails = new List <TerrainDescriptionQueryElementDetail>()
                    {
                        new TerrainDescriptionQueryElementDetail()
                        {
                            Resolution = _terrainResolution.LowerResolution,
                            Type       = TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY
                        },
                        new TerrainDescriptionQueryElementDetail()
                        {
                            Resolution = _terrainResolution,
                            Type       = TerrainDescriptionElementTypeEnum.NORMAL_ARRAY
                        },
                    }
                });

                outputOfGeneration.ContinueWith(c =>
                {
                    GeneratedTerrainElements elem = new GeneratedTerrainElements();
                    elem.HeightElement            = c.Result.GetElementOfType(TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY);
                    elem.NormalElement            = c.Result.GetElementOfType(TerrainDescriptionElementTypeEnum.NORMAL_ARRAY);
                    _generatedElements.Add(elem);
                }).ContinueWith(q =>
                {
                    Debug.Log("Error: Executing task");
                    Debug.Log("Error descr is " + q.Exception);
                }, TaskContinuationOptions.OnlyOnFaulted
                                );
            });
        }
Пример #4
0
 public FromTerrainProviderBaseTerrainDetailProvider(TerrainDetailProvider provider)
 {
     _provider = provider;
 }
Пример #5
0
 public static BaseTerrainDetailProvider CreateFrom(TerrainDetailProvider provider)
 {
     return(new FromTerrainProviderBaseTerrainDetailProvider(provider));
 }