Ring1Root CreateRootNode_TODO_DELETE(Ring1SubmapTextures submapTextures) { var terrainParentGameObject = new GameObject("TerrainParent"); var unityCoordsCalculator = new UnityCoordsCalculator(new Vector2(256, 256)); var nodeListener = new Ring1NodeObjects( (node) => new List <IRing1NodeListener>() { //todo //new Ring1NodeShaderHeightTerrain(node, _ring1LodData, terrainParentGameObject, submapTextures, // unityCoordsCalculator, null) //todo this null // new Ring1NodeDirectHeightTerrain(node, _ring1LodData, terrainParentGameObject, submapTextures, unityCoordsCalculator, heightmapArray) } ); _visibilityResolver = new Ring1VisibilityResolver(new Ring1BoundsCalculator(unityCoordsCalculator)); _visibilityResolver.SetFovDataOverride(true); _nodeSplitController = new NodeSplitController( maximumLodLevel: MyConstants.MAXIMUM_LOD_LEVEL, minimumLodLevel: 0, precisionDistances: new Dictionary <float, int> { { 50, 3 }, { 100, 2 }, { 200, 1 } }, coordsCalculator: unityCoordsCalculator ); return(new Ring1Root( new Ring1Node( _nodeSplitController, nodeListener, _visibilityResolver, new MyRectangle(0, 0, 0.5f, 0.5f), 1, Ring1NodePositionEnum.DOWN_LEFT), new Ring1Node( _nodeSplitController, nodeListener, _visibilityResolver, new MyRectangle(0.5f, 0, 0.5f, 0.5f), 1, Ring1NodePositionEnum.DOWN_RIGHT), new Ring1Node( _nodeSplitController, nodeListener, _visibilityResolver, new MyRectangle(0, 0.5f, 0.5f, 0.5f), 1, Ring1NodePositionEnum.TOP_LEFT), new Ring1Node( _nodeSplitController, nodeListener, _visibilityResolver, new MyRectangle(0.5f, 0.5f, 0.5f, 0.5f), 1, Ring1NodePositionEnum.TOP_RIGHT), nodeListener )); }
CreateHeightmap_TODO_DELETE( HeightmapArray heightmapArray) //input heightmap has 256x256 map, spans 5,7x5,7km p22.3m real life terrain { var tessalationRequirementTextureGenerator = new TessalationRequirementTextureGenerator(); var tessalationReqTexture = tessalationRequirementTextureGenerator.GenerateTessalationRequirementTexture(heightmapArray, 64); var heightmapBundle = SavingFileManager.LoadHeightmapBundlesFromFiles("heightmapBundle", 4, 2048); var submapTextures = new Ring1SubmapTextures(heightmapBundle, tessalationReqTexture); _rootNode = CreateRootNode_TODO_DELETE(submapTextures); _rootNode.UpdateLod(); }
// Use this for initialization void Start() { _updatableContainer = new UpdatableContainer(); TaskUtils.SetGlobalMultithreading(true); int minSubmapWidth = 256; //(int)Math.Floor((double)filePixelWidth/subTerrainCount)-1 ; var ring1Array = SavingFileManager.LoadFromFile("map.dat", 2048, 2048); ring1Array = BasicHeightmapModifier.Multiply(1000, ring1Array); _ring1Tree = new Ring1Tree(); ////////////////// var tessalationRequirementTextureGenerator = new TessalationRequirementTextureGenerator(); var tessalationReqTexture = tessalationRequirementTextureGenerator.GenerateTessalationRequirementTexture(ring1Array, 64); var heightmapBundle = SavingFileManager.LoadHeightmapBundlesFromFiles("heightmapBundle", 4, 2048); var submapTextures = new Ring1SubmapTextures(heightmapBundle, tessalationReqTexture); /// /// VISIBILITY TEXTURE var visibilityTextureSideLength = 16; var visibilityTexture = new Texture2D(visibilityTextureSideLength, visibilityTextureSideLength, TextureFormat.RFloat, false); visibilityTexture.filterMode = FilterMode.Point; var visibilityTextureProcessorProxy = new Ring1VisibilityTextureProcessorUTProxy(new Ring1VisibilityTextureProcessor(visibilityTexture)); _updatableContainer.AddUpdatableElement(visibilityTextureProcessorProxy); var visibilityTextureChangeGrabber = new Ring1VisibilityTextureChangeGrabber(); var terrainParentGameObject = new GameObject("TerrainParent"); var unityCoordsCalculator = new UnityCoordsCalculator(new Vector2(256, 256)); var orderGrabber = new Ring1PaintingOrderGrabber(); var painterProxy = new RingTerrainPainterUTProxy(new RingTerrainPainter()); _updatableContainer.AddUpdatableElement(painterProxy); painterProxy.Update(); var mainRespondingProxy = new Ring1NodeEventMainRespondingProxy(new Ring1NodeEventMainResponder()); _otherThreadActionPairs.Add(new OtherThreadProxyAndActionPair() { Proxy = mainRespondingProxy, EveryPostAction = () => { var delta = visibilityTextureChangeGrabber.RetriveVisibilityChanges(); if (delta.AnyChange) { var visibilityTextureChagnes = visibilityTextureChangeGrabber.RetriveVisibilityChanges(); visibilityTextureProcessorProxy.AddOrder(visibilityTextureChagnes); } if (orderGrabber.IsAnyOrder) { painterProxy.AddOrder(orderGrabber.RetriveOrderAndClear()); } } }); var commonExecutor = new CommonExecutorUTProxy(); _updatableContainer.AddUpdatableElement(commonExecutor); TerrainShapeDbProxy terrainShapeDbProxy = new TerrainShapeDbProxy( FETerrainShapeDbInitialization.CreateTerrainShapeDb(null /*todo here*/, commonExecutor, new TerrainDetailAlignmentCalculator(240), false, false, false, null)); _otherThreadActionPairs.Add(new OtherThreadProxyAndActionPair() { Proxy = terrainShapeDbProxy }); var meshGeneratorProxy = new MeshGeneratorUTProxy(new MeshGeneratorService()); _updatableContainer.AddUpdatableElement(meshGeneratorProxy); //var eventCollector = new Ring1NodeEventCollector((node) => // new Ring1NodeDirectHeightTerrain( // node, // visibilityTextureChangeGrabber, // visibilityTexture, // terrainParentGameObject, // unityCoordsCalculator, // orderGrabber, // terrainShapeDbProxy, // ring1Array, // meshGeneratorProxy)); var eventCollector = new Ring1NodeEventCollector(new FromLambdaListenersCreator((node) => new Ring1ListenerToGRingListener( new Ring1NodeShaderHeightTerrain( node, visibilityTextureChangeGrabber, visibilityTexture, terrainParentGameObject, unityCoordsCalculator, orderGrabber, terrainShapeDbProxy, meshGeneratorProxy, null)))); //todo if you want this to work var ring1Proxy = new Ring1TreeProxy(_ring1Tree); _otherThreadActionPairs.Add(new OtherThreadProxyAndActionPair() { Proxy = ring1Proxy, EveryPostAction = () => { if (eventCollector.Any) { mainRespondingProxy.AddOrder(eventCollector.RetriveOrderAndClear()); } } }); StartThreading(); ring1Proxy.CreateHeightmap( new Ring1Tree.RootNodeCreationParameters() { UnityCoordsCalculator = unityCoordsCalculator, NodeListener = eventCollector, PrecisionDistances = Ring1TestDefaults.PrecisionDistances, InitialCameraPosition = Vector3.zero, }); }