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) )); }
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)); } }
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)); }
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)); }
protected override async Task <UInt32> CreateTerrainAsync() { var ring1Position = Ring1Node.Ring1Position; var xOffset = _globalHeightmap.Width * ring1Position.X; var yOffset = _globalHeightmap.Height * ring1Position.Y; var width = _globalHeightmap.Width * ring1Position.Width; var height = _globalHeightmap.Height * ring1Position.Height; var subArray = slicer.GetSubarrayWithEmptyMarginsSafe(_globalHeightmap.HeightmapAsArray, (int)xOffset, (int)yOffset, (int)width, (int)height); Point2D newGameObjectSize = new Point2D(33, 33); var simplifiedMap = simplyfyer.SimplyfyHeightmap(new HeightmapArray(subArray), newGameObjectSize.X - 1, newGameObjectSize.Y - 1); var mesh = await _meshGenerator.AddOrder( () => PlaneGenerator.CreatePlaneMesh(1, 1, simplifiedMap.HeightmapAsArray)); UniformsPack pack = await CreateUniformsPack(Ring1Node); var inGamePosition = _coordsCalculator.CalculateGlobalObjectPosition(Ring1Node.Ring1Position); var triplet = new MyTransformTriplet(new Vector3(inGamePosition.X, 0, inGamePosition.Y), Vector3.zero, new Vector3(inGamePosition.Width, 1, inGamePosition.Height)); var creationTemplate = new Ring1GroundPieceCreationTemplate() { Name = "Ring1 terrain object " + inGamePosition.ToString(), ParentGameObject = ParentObject, PieceMesh = mesh, ShaderName = "Custom/Terrain/Ring1DirectHeight", TransformTriplet = triplet, Uniforms = pack }; var objectId = OrderGrabber.AddCreationOrder(creationTemplate); return(objectId); }