public DynamicFlatLodGRingNodeTerrain(INewGRingListenersCreator listenersCreator,
                                       FlatLodCalculator flatLodCalculator, Ring1Node node)
 {
     _listenersCreator  = listenersCreator;
     _flatLodCalculator = flatLodCalculator;
     _node = node;
 }
        public bool IsAccepted(Ring1Node node)
        {
            var dst = Vector2.Distance(node.Ring1Position.Center, _center);

            //Debug.Log("Position: "+node.Ring1Position.Center+" distance "+dst+" size "+node.Ring1Position.Width);
            return(Vector2.Distance(node.Ring1Position.Center, _center) < _maxDistance);
        }
Beispiel #3
0
        public IAsyncGRingNodeListener CreateNewListener(Ring1Node node, FlatLod flatLod)
        {
            var inGamePosition = _coordsCalculator.CalculateGlobalObjectPosition(node.Ring1Position);

            GRingTerrainMeshProvider terrainMeshProvider = new GRingTerrainMeshProvider(
                _meshGenerator,
                flatLod,
                _terrainMeshProviderConfiguration
                );
            GRingGroundShapeProvider groundShapeProvider = new GRingGroundShapeProvider(
                _terrainShapeDb,
                flatLod,
                inGamePosition,
                _spotUpdater,
                _groundShapeProviderConfiguration);

            GRing1SurfaceProvider surfaceProvider = new GRing1SurfaceProvider(
                _stainTerrainServiceProxy,
                inGamePosition);

            GRingTripletProvider tripletProvider = new GRingTripletProvider(
                inGamePosition, Repositioner.Default, HeightDenormalizer.Default);

            return(new GRingNodeTerrain(
                       _orderGrabber,
                       _parentObject,
                       terrainMeshProvider,
                       groundShapeProvider,
                       surfaceProvider,
                       tripletProvider,
                       flatLod,
                       new GRingWeldingUpdater(_weldingPack)
                       ));
        }
Beispiel #4
0
        public FlatLod CalculateFlatLod(Ring1Node node, Vector3 cameraPosition)
        {
            var quadLod = node.QuadLodLevel;

            var supportedSet = _configuration.PrecisionsSets.FirstOrDefault(c => c.IsQuadLodSupported(quadLod));

            if (supportedSet == null)
            {
                return(new FlatLod(quadLod, quadLod));
            }
            else
            {
                var ringCenter = (_coordsCalculator.CalculateGlobalObjectPosition(node.Ring1Position).Center);
                var distance   = Vector2.Distance(ringCenter,
                                                  new Vector2(cameraPosition.x, cameraPosition.z));
                int minLod            = supportedSet.FlatLodPrecisionDistances.Values.Max();
                int appropiateFlatLod =
                    supportedSet.FlatLodPrecisionDistances.OrderByDescending(a => a.Key)
                    .Where(c => c.Key < distance)
                    .Select(c => c.Value)
                    .DefaultIfEmpty(minLod)
                    .First();
                return(new FlatLod(appropiateFlatLod, quadLod));
            }
        }
Beispiel #5
0
        public void CreatedNewNode(Ring1Node ring1Node)
        {
            Preconditions.Assert(!_ring1NodePositionsToId.ContainsKey(ring1Node.Ring1Position),
                                 "Terrain was not created for this node");
            var newId = _lastId++;

            _ring1NodePositionsToId[ring1Node.Ring1Position] = newId;
            _currentOrder.NewListenersGenerator[newId]       = () => _newListenersCreator.CreateNewListener(ring1Node);
        }
Beispiel #6
0
 public Ring1NodeTerrain(Ring1Node ring1Node,
                         Ring1VisibilityTextureChangeGrabber ring1VisibilityTextureChangeGrabber,
                         Ring1PaintingOrderGrabber orderGrabber,
                         GameObject parentObject)
 {
     _ring1VisibilityTextureChangeGrabber = ring1VisibilityTextureChangeGrabber;
     Ring1Node    = ring1Node;
     OrderGrabber = orderGrabber;
     ParentObject = parentObject;
 }
Beispiel #7
0
        public IAsyncGRingNodeListener CreateNewListener(Ring1Node node, FlatLod flatLod)
        {
            var inGamePosition = _coordsCalculator.CalculateGlobalObjectPosition(node.Ring1Position);

            GRingTripletProvider tripletProvider = new GRingTripletProvider(
                inGamePosition, Repositioner.Default, HeightDenormalizer.Default);

            return(new GDebugLodNodeTerrain(_orderGrabber, _parentObject, tripletProvider, flatLod,
                                            _meshGeneratorUtProxy));
        }
Beispiel #8
0
        public void DoNotDisplay(Ring1Node ring1Node)
        {
            Preconditions.Assert(_ring1NodePositionsToId.ContainsKey(ring1Node.Ring1Position),
                                 "There is no node of given position");
            var id = _ring1NodePositionsToId[ring1Node.Ring1Position];

            _currentOrder.AddAction(id, new PrioritisedRing1ListenerAction()
            {
                Action   = (node) => node.DoNotDisplayAsync(),
                Priority = Ring1ListenersActionPriority.Hiding_Priority
            });
        }
Beispiel #9
0
        public void Update(Ring1Node ring1Node, Vector3 cameraPosition)
        {
            Preconditions.Assert(_ring1NodePositionsToId.ContainsKey(ring1Node.Ring1Position),
                                 "There is no node of given position");
            var id = _ring1NodePositionsToId[ring1Node.Ring1Position];

            _currentOrder.AddAction(id, new PrioritisedRing1ListenerAction()
            {
                Action   = (node) => node.UpdateAsync(cameraPosition),
                Priority = Ring1ListenersActionPriority.Update_Priority
            });
        }
Beispiel #10
0
        public IAsyncGRingNodeListener CreateNewListener(Ring1Node node, FlatLod flatLod)
        {
            var inGamePosition = _coordsCalculator.CalculateGlobalObjectPosition(node.Ring1Position);

            GRingTripletProvider tripletProvider = new GRingTripletProvider(
                inGamePosition, Repositioner.Default, HeightDenormalizer.Default);

            GRingGroundShapeProvider groundShapeProvider = new GRingGroundShapeProvider(
                _terrainShapeDb,
                flatLod,
                inGamePosition,
                _gRingSpotUpdater,
                _groundShapeProviderConfiguration);

            return(new GDebugTerrainedLodNodeTerrain(
                       _orderGrabber, _parentObject, tripletProvider, flatLod, _meshGeneratorUtProxy, groundShapeProvider));
        }
Beispiel #11
0
 public Ring1NodeShaderHeightTerrain(
     Ring1Node ring1Node,
     Ring1VisibilityTextureChangeGrabber ring1VisibilityTextureChangeGrabber,
     Texture2D visibilityTexture,
     GameObject terrainParentObject,
     UnityCoordsCalculator coordsCalculator,
     Ring1PaintingOrderGrabber orderGrabber,
     TerrainShapeDbProxy terrainShapeDb,
     MeshGeneratorUTProxy meshGenerator,
     StainTerrainServiceProxy stainTerrainServiceProxy)
     : base(ring1Node, ring1VisibilityTextureChangeGrabber, orderGrabber, terrainParentObject)
 {
     _visibilityTexture        = visibilityTexture;
     _coordsCalculator         = coordsCalculator;
     _terrainShapeDb           = terrainShapeDb;
     _meshGenerator            = meshGenerator;
     _stainTerrainServiceProxy = stainTerrainServiceProxy;
 }
        private async Task <UniformsPack> CreateUniformsPack(Ring1Node ring1Node)
        {
            UniformsPack pack = new UniformsPack();


            var terrainOutput = await _terrainShapeDb.Query(new TerrainDescriptionQuery()
            {
                QueryArea = Ring1Node.Ring1Position,
                RequestedElementDetails = new List <TerrainDescriptionQueryElementDetail>()
                {
                    new TerrainDescriptionQueryElementDetail()
                    {
                        //PixelsPerMeter = 10, //todo
                        Resolution = TerrainCardinalResolution.FromRing1NodeLodLevel(Ring1Node.QuadLodLevel),
                        Type       = TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY
                    },
                    new TerrainDescriptionQueryElementDetail()
                    {
                        //PixelsPerMeter = 10, //todo
                        Resolution = TerrainCardinalResolution.FromRing1NodeLodLevel(Ring1Node.QuadLodLevel),
                        Type       = TerrainDescriptionElementTypeEnum.TESSALATION_REQ_ARRAY
                    },
                }
            });

            var uvPosition =
                _coordsCalculator.CalculateUvPosition(Ring1Node.Ring1Position); //_submapTextures.UvPosition;
            var heightmapTexture   = terrainOutput.GetElementOfType(TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY);
            var tessalationTexture =
                terrainOutput.GetElementOfType(TerrainDescriptionElementTypeEnum.TESSALATION_REQ_ARRAY);

            pack.SetUniform("_TerrainTextureUvPositions",
                            new Vector4(uvPosition.X, uvPosition.Y, uvPosition.Width, uvPosition.Height));
            pack.SetTexture("_HeightmapTex", heightmapTexture.TokenizedElement.DetailElement.Texture.Texture);
            pack.SetTexture("_TessalationTex", tessalationTexture.TokenizedElement.DetailElement.Texture.Texture);

            pack.SetTexture("_LodTexture", _visibilityTexture);
            pack.SetUniform("_MaxHeight", 100);
            pack.SetUniform("_LodTextureUvOffset",
                            _coordsCalculator.CalculateTextureUvLodOffset(ring1Node.Ring1Position));
            pack.SetUniform("_BaseTrianglesCount",
                            _coordsCalculator.CalculateGameObjectSize(ring1Node.Ring1Position).X - 1);
            return(pack);
        }
 public Ring1NodeDirectHeightTerrain(
     Ring1Node ring1Node,
     Ring1VisibilityTextureChangeGrabber ring1VisibilityTextureChangeGrabber,
     Texture2D visibilityTexture,
     GameObject terrainParentObject,
     UnityCoordsCalculator coordsCalculator,
     Ring1PaintingOrderGrabber orderGrabber,
     TerrainShapeDbProxy terrainShapeDb,
     HeightmapArray globalHeightmap,
     MeshGeneratorUTProxy meshGenerator
     )
     : base(ring1Node, ring1VisibilityTextureChangeGrabber, orderGrabber, terrainParentObject)
 {
     _visibilityTexture = visibilityTexture;
     _coordsCalculator  = coordsCalculator;
     _globalHeightmap   = globalHeightmap;
     _meshGenerator     = meshGenerator;
     _terrainShapeDb    = terrainShapeDb;
 }
        public IAsyncGRingNodeListener CreateNewListener(Ring1Node node, FlatLod lod)
        {
            var creatorsFilteredList = _creatorsList
                                       .Where(c => c.PositionLimiter == null || c.PositionLimiter.IsAccepted(node))
                                       .Where(c => c.MaximumLod.ScalarValue >= lod.ScalarValue)
                                       .OrderBy(c => c.MaximumLod.ScalarValue).Select(c => c.Creator).ToList();

            INewGRingListenersCreator creator = null;

            if (creatorsFilteredList.Any())
            {
                creator = creatorsFilteredList.First();
            }
            else
            {
                creator =
                    _creatorsList.Where(c => c.IsFallthroughCreator).Select(c => c.Creator).First();
            }

            return(creator.CreateNewListener(node, lod));
        }
 public IAsyncRing1NodeListener CreateNewListener(Ring1Node node)
 {
     return(new DynamicFlatLodGRingNodeTerrain(_subCreator, _flatLodCalculator, node));
 }
Beispiel #16
0
 public IAsyncRing1NodeListener CreateNewListener(Ring1Node node)
 {
     return(_newListenersCreatorFunc(node));
 }
 public IAsyncGRingNodeListener CreateNewListener(Ring1Node node, FlatLod lod)
 {
     return(new GCompositeRing2Node(_innerCreators.Select(c => c.CreateNewListener(node, lod)).ToList()));
 }
Beispiel #18
0
 public IAsyncGRingNodeListener CreateNewListener(Ring1Node node, FlatLod flatLod)
 {
     return(new GVoidNodeTerrain());
 }