public void Start() { InitializeWelding(); /// /// 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)); _ultraUpdatableContainer.Add(visibilityTextureProcessorProxy); var visibilityTextureChangeGrabber = new Ring1VisibilityTextureChangeGrabber(); var terrainParentGameObject = new GameObject("TerrainParent"); terrainParentGameObject.transform.localPosition = new Vector3(0, 0, 0); var globalSideLength = _gRingConfiguration.Ring1GlobalSideLength; var globalSize = new Vector2(globalSideLength, globalSideLength); var unityCoordsCalculator = new UnityCoordsCalculator(globalSize); var orderGrabber = new Ring1PaintingOrderGrabber(); var painterProxy = new RingTerrainPainterUTProxy(new RingTerrainPainter(_gRingConfiguration.MakeTerrainVisible)); _ultraUpdatableContainer.Add(painterProxy); painterProxy.Update(); var mainRespondingProxy = new Ring1NodeEventMainRespondingProxy(new Ring1NodeEventMainResponder()); _ultraUpdatableContainer.AddOtherThreadProxy(new OtherThreadProxyWithPerPostAction() { OtherThreadProxy = mainRespondingProxy, PerPostAction = () => { var delta = visibilityTextureChangeGrabber.RetriveVisibilityChanges(); if (delta.AnyChange) { var visibilityTextureChagnes = visibilityTextureChangeGrabber.RetriveVisibilityChanges(); visibilityTextureProcessorProxy.AddOrder(visibilityTextureChagnes); } if (orderGrabber.IsAnyOrder) { painterProxy.AddOrder(orderGrabber.RetriveOrderAndClear()); } } }); var stainTerrainResourceCreatorUtProxy = new StainTerrainResourceCreatorUTProxy(new StainTerrainResourceCreator()); _ultraUpdatableContainer.Add(stainTerrainResourceCreatorUtProxy); var stainTerrainServiceProxy = new StainTerrainServiceProxy( new StainTerrainService( new FromFileStainTerrainResourceGenerator(_configuration.StainTerrainServicePath, _gameInitializationFields.Retrive <CommonExecutorUTProxy>()), //new ComputationStainTerrainResourceGenerator( // new StainTerrainResourceComposer( // _stainTerrainResourceCreatorUtProxy // ), // new StainTerrainArrayMelder(), // new DummyStainTerrainArrayFromBiomesGenerator( // new DebugBiomeContainerGenerator().GenerateBiomesContainer(new BiomesContainerConfiguration()), // new StainTerrainArrayFromBiomesGeneratorConfiguration() // )), _gRingConfiguration.Ring1GenerationArea)); _ultraUpdatableContainer.AddOtherThreadProxy(stainTerrainServiceProxy); var ring1Tree = new Ring1Tree(_gRingConfiguration.Ring1TreeConfiguration); var ring1TreeProxy = new Ring1TreeProxy(ring1Tree); _gameInitializationFields.Retrive <LateAssignBox <Ring1TreeProxy> >().Set(ring1TreeProxy); _ultraUpdatableContainer.AddOtherThreadProxy(ring1TreeProxy); var terrainShapeDbInitialization = new FETerrainShapeDbInitialization(_ultraUpdatableContainer, _gameInitializationFields, _configuration, new FilePathsConfiguration()); terrainShapeDbInitialization.Start(); var gRing0NodeTerrainCreator = new GRing0NodeTerrainCreator( orderGrabber, terrainParentGameObject, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), unityCoordsCalculator, _gameInitializationFields.Retrive <GRingSpotUpdater>(), _gameInitializationFields.Retrive <HeightArrayWeldingPack>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gRingConfiguration.TerrainMeshProviderConfiguration); var gRing1NodeTerrainCreator = new GRing1NodeTerrainCreator( orderGrabber, terrainParentGameObject, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), stainTerrainServiceProxy, unityCoordsCalculator, _gameInitializationFields.Retrive <GRingSpotUpdater>(), _gameInitializationFields.Retrive <HeightArrayWeldingPack>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gRingConfiguration.TerrainMeshProviderConfiguration); var gRing2PatchesCreatorProxy = _gameInitializationFields.Retrive <GRing2PatchesCreatorProxy>(); var gRing2NodeTerrainCreator = new GRing2NodeTerrainCreator( orderGrabber, terrainParentGameObject, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), unityCoordsCalculator, gRing2PatchesCreatorProxy, _gameInitializationFields.Retrive <GRingSpotUpdater>(), _gameInitializationFields.Retrive <HeightArrayWeldingPack>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gRingConfiguration.TerrainMeshProviderConfiguration); var gDebugNodeTerrainCreator = new GDebugLodNodeTerrainCreator( orderGrabber, terrainParentGameObject, unityCoordsCalculator, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>() ); var gDebugTerrainedNodeTerrainCreator = new GDebugTerrainedLodNodeTerrainCreator( orderGrabber, terrainParentGameObject, unityCoordsCalculator, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gameInitializationFields.Retrive <GRingSpotUpdater>() ); var gStampedRing2NodeTerrainCreator = new GStampedRing2NodeTerrainCreator( orderGrabber, terrainParentGameObject, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), unityCoordsCalculator, gRing2PatchesCreatorProxy, _gameInitializationFields.Retrive <Ring2PatchStamplingOverseerFinalizer>(), _gameInitializationFields.Retrive <GRingSpotUpdater>(), _gameInitializationFields.Retrive <HeightArrayWeldingPack>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gRingConfiguration.TerrainMeshProviderConfiguration); var gCompositeRing2NodeTerrainCreator = new GCompositeRing2NodeTerrainCreator( orderGrabber, terrainParentGameObject, _gameInitializationFields.Retrive <MeshGeneratorUTProxy>(), _gameInitializationFields.Retrive <ITerrainShapeDb>(), unityCoordsCalculator, gRing2PatchesCreatorProxy, _gameInitializationFields.Retrive <GRingSpotUpdater>(), _gameInitializationFields.Retrive <HeightArrayWeldingPack>(), _gameInitializationFields.Retrive <Ring2PatchStamplingOverseerFinalizer>(), _gRingConfiguration.GroundShapeProviderConfiguration, _gRingConfiguration.TerrainMeshProviderConfiguration); //var gCompositeRing2NodeTerrainCreator = new GCompositeRing2NodeTerrainCreator( // new List<INewGRingListenersCreator>() // { // gRing2NodeTerrainCreator, // gStampedRing2NodeTerrainCreator, // }); var subCreator = new SupremeGRingNodeTerrainCreator(new List <NewListenersCreatorWithLimitation>() { //new NewListenersCreatorWithLimitation() //{ // Creator = gDebugTerrainedNodeTerrainCreator, // MaximumLod = new FlatLod(14), // //PositionLimiter = new NewListenersCreatorPositionLimiter(new Vector2(0.5f, 0.6f), 0.025f) //}, //new NewListenersCreatorWithLimitation() //{ // Creator = gRing0NodeTerrainCreator, // MaximumLod = new FlatLod(5), //}, new NewListenersCreatorWithLimitation() { Creator = new GVoidNodeTerrainCreator(), MaximumLod = new FlatLod(5), //IsFallthroughCreator = true }, new NewListenersCreatorWithLimitation() { Creator = gRing1NodeTerrainCreator, MaximumLod = new FlatLod(10) }, new NewListenersCreatorWithLimitation() { Creator = gRing2NodeTerrainCreator, MaximumLod = new FlatLod(14) }, new NewListenersCreatorWithLimitation() { Creator = gStampedRing2NodeTerrainCreator, MaximumLod = new FlatLod(13) }, new NewListenersCreatorWithLimitation() { Creator = gCompositeRing2NodeTerrainCreator, MaximumLod = new FlatLod(14) } //new NewListenersCreatorWithLimitation() //{ // Creator = gDebugNodeTerrainCreator, // MaximumLod = new FlatLod(11) //}, }); var eventCollector = new Ring1NodeEventCollector( new DynamicFlatLodGRingNodeTerrainCreator(subCreator, new FlatLodCalculator(unityCoordsCalculator, _gRingConfiguration.FlatLodConfiguration))); _ultraUpdatableContainer.AddOtherThreadProxy( new OtherThreadProxyWithPerPostAction() { OtherThreadProxy = ring1TreeProxy, PerPostAction = () => { if (eventCollector.Any) { mainRespondingProxy.AddOrder(eventCollector.RetriveOrderAndClear()); } } } ); var repositioner = _gameInitializationFields.Retrive <Repositioner>(); _ultraUpdatableContainer.AddUpdatableElement(new FieldBasedUltraUpdatable() { UpdateCameraField = (camera) => { if (_configuration.UpdateRingTree) { ring1TreeProxy.UpdateCamera(FovData.FromCamera(camera, repositioner)); } } }); _ultraUpdatableContainer.AddUpdatableElement(new FieldBasedUltraUpdatable() { StartCameraField = (camera) => { ring1TreeProxy.CreateHeightmap( new Ring1Tree.RootNodeCreationParameters() { InitialCameraPosition = repositioner.InvMove(camera.Position), NodeListener = eventCollector, PrecisionDistances = _gRingConfiguration.QuadLodPrecisionDistances, UnityCoordsCalculator = unityCoordsCalculator }); } }); }
// Use this for initialization void Start() { string bilFilePath = @"C:\n49_e019_1arc_v3.bil"; HeightmapFile heightmapFile = new HeightmapFile(); const int filePixelWidth = 3601; //heightmapFile.LoadFile(bilFilePath, 3601); //heightmapFile.MirrorReflectHeightDataInXAxis(); MyTotalHeightmap totalHeightmap = new MyTotalHeightmap(); //const int subTerrainCount = 14; int minSubmapWidth = 256; //(int)Math.Floor((double)filePixelWidth/subTerrainCount)-1 ; List <SubmapPreparmentOrder> preparmentOrders = new List <SubmapPreparmentOrder> { newPreparmentOrder(0, 0, 4, 4, minSubmapWidth, 6, 0), newPreparmentOrder(0, 4, 4, 6, minSubmapWidth, 7, 0), newPreparmentOrder(4, 0, 6, 4, minSubmapWidth, 5, 0), newPreparmentOrder(0, 10, 4, 4, minSubmapWidth, 4, 0), newPreparmentOrder(4, 4, 2, 2, minSubmapWidth, 2 + 4, 0), newPreparmentOrder(4, 6, 2, 2, minSubmapWidth, 2 + 4, 0), newPreparmentOrder(4, 8, 2, 2, minSubmapWidth, 2 + 4, 0), newPreparmentOrder(6, 4, 2, 2, minSubmapWidth, 2 + 4, 0), newPreparmentOrder(6, 8, 2, 2, minSubmapWidth, 3, 0), newPreparmentOrder(8, 4, 2, 2, minSubmapWidth, 2 + 4, 0), newPreparmentOrder(8, 6, 2, 2, minSubmapWidth, 2 + 4, 0), //newPreparmentOrder(8,8,2,2,minSubmapWidth, 2+4, 1), was lithe this newPreparmentOrder(8, 8, 1, 1, minSubmapWidth, 3, 0), newPreparmentOrder(9, 8, 1, 1, minSubmapWidth, 3, 0), newPreparmentOrder(9, 8, 1, 1, minSubmapWidth, 3, 0), newPreparmentOrder(9, 9, 1, 1, minSubmapWidth, 0, 1), newPreparmentOrder(6, 6, 2, 2, minSubmapWidth, 2 + 4, 0), newPreparmentOrder(10, 4, 4, 6, minSubmapWidth, 3 + 2, 0), newPreparmentOrder(10, 10, 4, 4, minSubmapWidth, 4 + 1, 0), newPreparmentOrder(4, 10, 6, 4, minSubmapWidth, 3 + 4, 0), newPreparmentOrder(10, 0, 4, 4, minSubmapWidth, 3 + 4, 0), }; SubmapPreparer submapPreparer = new SubmapPreparer(); //var submaps = submapPreparer.PrepareSubmaps(heightmapFile.GlobalHeightArray, preparmentOrders); //totalHeightmap.LoadHeightmap(submaps.Ring0Submaps); Ring1HeightArrayCreator creator = new Ring1HeightArrayCreator(); //var ring1Array = creator.CreateRing1HeightmapArray(submaps.Ring1Submaps[0].Heightmap); //SavingFileManager.SaveToFile("map.dat", ring1Array); var ring1Array = SavingFileManager.LoadFromFile("map.dat", 2048, 2048); //ring1Array = BasicHeightmapModifier.AddConstant(-0.5f, ring1Array); ring1Array = BasicHeightmapModifier.Multiply(1000, ring1Array); _ring1Tree = new Ring1Tree(); var tempHeightmapInfo = new GlobalHeightmapInfo(2000, 1000, 80000, 80000); //_ring1Tree.CreateHeightmap(ring1Array, heightmapFile.GlobalHeightmapInfo); _ring1Tree.CreateHeightmap_TODO_DELETE(ring1Array); }
public Ring1TreeProxy(Ring1Tree tree) : base("Ring1TreeProxyThread", false) { _tree = tree; }