private void bakeRegionMesh(Region reg) { GameObject regionGO = reg.gameObject; List <Building> buildings = reg.getBuildings(); #region Add CUs to CombineList List <CombineInstance> currentCiList = new List <CombineInstance>(); foreach (Building building in buildings) { CombineInstance ci = new CombineInstance(); CompilationUnit cu = building.GetComponent <Building>().getCU(); long loc = cu.getLoc(); int modelIdx = Helperfunctions.mapLOCtoLevel(loc); if (cu.implementsServiceComponent()) { ci.mesh = SILod1Prefabs[modelIdx].GetComponent <MeshFilter>().sharedMesh; } else if (cu.declaresService()) { ci.mesh = SDLod1Prefabs[modelIdx].GetComponent <MeshFilter>().sharedMesh; } else { ci.mesh = CULod1Prefabs[modelIdx].GetComponent <MeshFilter>().sharedMesh; } ci.subMeshIndex = 0; ci.transform = regionGO.transform.worldToLocalMatrix * building.transform.localToWorldMatrix; currentCiList.Add(ci); } #endregion #region Add country area to FinalCombineList CombineInstance ciCountry = new CombineInstance(); ciCountry.mesh = reg.getRegionArea().GetComponent <MeshFilter>().sharedMesh; ciCountry.subMeshIndex = 0; ciCountry.transform = Matrix4x4.identity; currentCiList.Add(ciCountry); #endregion #region Replace Country Mesh and Materials with baked one MeshRenderer bakedMR = regionGO.AddComponent <MeshRenderer>(); bakedMR.sharedMaterial = holomaterial; MeshFilter bakedMF = regionGO.AddComponent <MeshFilter>(); bakedMF.mesh = new Mesh(); bakedMF.sharedMesh.CombineMeshes(currentCiList.ToArray(), true, true); #endregion }
//writes into cellMap and endCandidates private bool expandCountries(List <CompilationUnit> cuList, List <VFace> cellMap, Dictionary <int, VFace> endCandidates, VFace startingCell, float b) { Dictionary <int, VFace> candidates = new Dictionary <int, VFace>(); candidates.Add(startingCell.ID, startingCell); for (int i = 1; i < cuList.Count * expansionFactor + 1; i++) { if (candidates.Count == 0) { cellMap.Clear(); endCandidates.Clear(); return(false); } //Select cell from candidates KeyValuePair <int, VFace> selectedCell = selectFromCandidates(candidates, b); //Mark cell in islandVoronoi selectedCell.Value.mark = i; //Add cell to package dictionary cellMap.Add(selectedCell.Value); //Remove cell from future candidates list candidates.Remove(selectedCell.Key); //Add viable candidates around cell foreach (VHEdge edge in selectedCell.Value.EnumerateEdges()) { VFace nCell = edge.twin.face; //If cell is OK, not occupied and not already in candidateList, add to candidate list if (Helperfunctions.checkCell(nCell, -GlobalVar.voronoiCellScalefactor * 0.4f, GlobalVar.voronoiCellScalefactor * 0.4f, -GlobalVar.voronoiCellScalefactor * 0.4f, GlobalVar.voronoiCellScalefactor * 0.4f) && nCell.mark == 0 && !candidates.ContainsKey(nCell.ID)) { candidates.Add(nCell.ID, nCell); } } } //transfer candidates into endCandidates Dict foreach (KeyValuePair <int, VFace> kvp in candidates) { endCandidates.Add(kvp.Key, kvp.Value); } return(true); }
/* * private void populateIslandCoastDistance(CartographicIsland island, int hf) * { * //Init land height to Inf * List<List<VFace>> fragCellList = island.getPackageCells(); * foreach (List<VFace> cellMap in fragCellList) * foreach (VFace face in cellMap) * face.coastDistance = int.MaxValue; * * * //Enqueue the coast region first * Queue<VFace> cellQueue = new Queue<VFace>(); * foreach (VFace face in island.getCoastlineCells()) * { * face.coastDistance = 0; * cellQueue.Enqueue(face); * } * * while (cellQueue.Count > 0) * { * VFace v = cellQueue.Dequeue(); * foreach (VHEdge edge in v.EnumerateEdges()) * { * VFace adjFace = edge.twin.face; * int newDistance = v.coastDistance + hf; * if (newDistance < adjFace.coastDistance) * { * adjFace.coastDistance = newDistance; * cellQueue.Enqueue(adjFace); * } * } * } * } */ /* * private void computeIslandHeight(CartographicIsland island, float hf) * { * //Init land height to Inf * List<List<VFace>> fragCellList = island.getPackageCells(); * foreach(List<VFace> cellMap in fragCellList) * foreach (VFace face in cellMap) * foreach (VHEdge edge in face.EnumerateEdges()) * edge.Origin.Z = Mathf.Infinity; * * //Enqueue the coast region first * Queue<VVertex> vertexQueue = new Queue<VVertex>(); * foreach (VFace face in island.getCoastlineCells()) * { * foreach (VHEdge edge in face.EnumerateEdges()) * vertexQueue.Enqueue(edge.Origin); * } * * while (vertexQueue.Count > 0) * { * VVertex v = vertexQueue.Dequeue(); * foreach (VHEdge edge in v.EnumerateEdges()) * { * VVertex adjVert = edge.Next.Origin; * float newElevation = (float)v.Z + hf; * if (newElevation < adjVert.Z) * { * adjVert.Z = newElevation; * vertexQueue.Enqueue(adjVert); * } * } * } * * } */ //Expands the coastlineCells outwards by hp.length cells and applies the height profile hp during expansion private void shapeCoastArea(Dictionary <int, VFace> coastline, float[] hp) { Dictionary <int, VFace> newestCoastline = new Dictionary <int, VFace>(coastline); for (int i = 0; i < hp.Length; i++) { //Expand cells newestCoastline.Clear(); foreach (KeyValuePair <int, VFace> kvp in coastline) { foreach (VHEdge edge in kvp.Value.EnumerateEdges()) { VFace nCell = edge.twin.face; if (Helperfunctions.checkCell(nCell, -GlobalVar.voronoiCellScalefactor * 0.4f, GlobalVar.voronoiCellScalefactor * 0.4f, -GlobalVar.voronoiCellScalefactor * 0.4f, GlobalVar.voronoiCellScalefactor * 0.4f) && nCell.mark == 0 && !coastline.ContainsKey(nCell.ID) && !newestCoastline.ContainsKey(nCell.ID)) { newestCoastline.Add(nCell.ID, nCell); } } } //Adjust height and Add to coastline foreach (KeyValuePair <int, VFace> kvp in newestCoastline) { coastline.Add(kvp.Key, kvp.Value); foreach (VHEdge edge in kvp.Value.EnumerateEdges()) { edge.Origin.Z += hp[i]; } } } //Remove the last expansion from the coastline, due to artifacts foreach (KeyValuePair <int, VFace> kvp in newestCoastline) { coastline.Remove(kvp.Key); } }
static void Main(string[] args) { using var file = new FileStream("Input.txt", FileMode.Open); using var reader = new StreamReader(file); // Reading Opcode var codelines = reader.ReadLine(); var computer = new IntCode(codelines); var output = new Queue <long>(); var input = new Queue <long>(); // question 1 input.Enqueue(1); computer.RunSoftware(output, input); Helperfunctions.PrintQueue(output); // question 2 input.Enqueue(2); computer.Initialize(); computer.RunSoftware(output, input); Helperfunctions.PrintQueue(output); Console.WriteLine("De vraag is opgelost"); }
private IslandGO constructIslandGO(CartographicIsland island, Vector3 pos) { int rngSeed = island.getName().GetHashCode() + 200; RNG = new System.Random(rngSeed); GameObject islandGO = new GameObject(island.getName()); IslandGO islandGOComponent = islandGO.AddComponent <IslandGO>(); islandGOComponent.setIslandStructure(island); island.setIslandGO(islandGO); #region create countries List <List <TnetMesh> > tmeshList = island.getPackageMeshes(); List <List <VFace> > islandCells = island.getPackageCells(); List <Package> packageList = island.getPackages(); float maximumBuildingBoundSize = 0; int counter = 0; foreach (List <TnetMesh> tmesh in tmeshList) { Package pckg = packageList[counter]; GameObject region = new GameObject(pckg.getName()); Region regionComponent = region.AddComponent <Region>(); regionComponent.setParentIsland(islandGOComponent); region.transform.SetParent(islandGO.transform); islandGOComponent.addRegion(regionComponent); #region RegionArea GameObject regionArea = new GameObject("Region area"); regionArea.transform.SetParent(region.transform); MeshFilter mFilter = regionArea.AddComponent <MeshFilter>(); MeshRenderer mRender = regionArea.AddComponent <MeshRenderer>(); mRender.sharedMaterial = combinedHoloMaterial; regionComponent.setRegionArea(regionArea); regionComponent.setPackage(pckg); #endregion List <VFace> packageCells = islandCells[counter]; CombineInstance[] combineCellMeshes = new CombineInstance[tmesh.Count]; int cc = 0; #region Combine package cell meshes foreach (TnetMesh tm in tmesh) { Mesh m = Helperfunctions.convertTriangleNETMesh(tm); combineCellMeshes[cc].mesh = m; cc++; } mFilter.mesh = new Mesh(); mFilter.mesh.CombineMeshes(combineCellMeshes, true, false); float rndU = (float)RNG.NextDouble(); float rndV = (float)RNG.NextDouble() * 0.4f; Vector2 rndUV = new Vector2(rndU, rndV); setUVsToSingularCoord(rndUV, mFilter); #endregion cc = 0; #region Create CUs foreach (CompilationUnit cu in pckg.getCompilationUnits()) { float x = (float)packageCells[cc].generator.X; float y = (float)packageCells[cc].generator.Z; float z = (float)packageCells[cc].generator.Y; int heightLevel = Helperfunctions.mapLOCtoLevel(cu.getLoc()); GameObject building; if (cu.implementsServiceComponent()) { building = GameObject.Instantiate(SIPrefabs[heightLevel], region.transform); building.AddComponent <ServiceLayerGO>(); } else if (cu.declaresService()) { building = GameObject.Instantiate(SDPrefabs[heightLevel], region.transform); building.AddComponent <ServiceLayerGO>(); } else { building = GameObject.Instantiate(CUPrefabs[heightLevel], region.transform); } building.name = cu.getName(); Vector3 randomRotation = new Vector3(0f, UnityEngine.Random.Range(-180, 180), 0f); building.transform.localEulerAngles = randomRotation; Building buildingComponent = building.AddComponent <Building>(); buildingComponent.setCU(cu); cu.setGameObject(building); building.transform.position = new Vector3(x, y, z); building.transform.localScale = new Vector3(GlobalVar.cuScale, GlobalVar.cuScale, GlobalVar.cuScale); regionComponent.addBuilding(buildingComponent); ////////////////////////// #region BuildingCollider building.layer = LayerMask.NameToLayer("InteractionSystemLayer"); CapsuleCollider capsuleCol = building.AddComponent <CapsuleCollider>(); capsuleCol.isTrigger = true; #endregion float currentBuildingExtent = capsuleCol.bounds.size.magnitude; if (currentBuildingExtent > maximumBuildingBoundSize) { maximumBuildingBoundSize = currentBuildingExtent; } ////////////////////////// cc++; } #endregion counter++; } #endregion #region Combine CU meshes /* * GameObject combinedCUs = new GameObject("Combined CUs"); * MeshFilter mFilterCU = combinedCUs.AddComponent<MeshFilter>(); * MeshRenderer mRenderCU = combinedCUs.AddComponent<MeshRenderer>(); * mRenderCU.material = defaultMaterial; * mFilterCU.mesh = new Mesh(); * mFilterCU.mesh.CombineMeshes(combineCuMeshes, true, true); * combinedCUs.transform.SetParent(islandGO.transform); */ #endregion #region create coastline GameObject coastline = new GameObject("Coastline"); islandGOComponent.setCoast(coastline); coastline.transform.SetParent(islandGO.transform); MeshFilter coastMFilter = coastline.AddComponent <MeshFilter>(); MeshRenderer coastMRender = coastline.AddComponent <MeshRenderer>(); coastMRender.sharedMaterial = combinedHoloMaterial; List <TnetMesh> tmeshCoastList = island.getCoastlineMeshes(); CombineInstance[] combineCoastInstance = new CombineInstance[tmeshCoastList.Count]; counter = 0; foreach (TnetMesh tmesh in tmeshCoastList) { Mesh m = Helperfunctions.convertTriangleNETMesh(tmesh); combineCoastInstance[counter].mesh = m; counter++; } coastMFilter.mesh = new Mesh(); coastMFilter.mesh.CombineMeshes(combineCoastInstance, true, false); setUVsToSingularCoord(new Vector2(0f, 0.7f), coastMFilter); #endregion #region init docks //get graph vertex associated with the island GraphVertex vert = island.getDependencyVertex(); if (vert != null) { //Relative dock position Vector3 dockDirection = new Vector3(UnityEngine.Random.value, 0, UnityEngine.Random.value); dockDirection.Normalize(); dockDirection *= island.getRadius(); //Import Dock Vector3 dockPosition = island.getWeightedCenter() + dockDirection; dockPosition.y -= Mathf.Abs(GlobalVar.islandHeightProfile[GlobalVar.islandHeightProfile.Length - 1]) * GlobalVar.islandAboveOcean; GameObject importD = Instantiate(importDockPrefab, dockPosition, Quaternion.identity); importD.layer = LayerMask.NameToLayer("InteractionSystemLayer"); importD.name = island.getName() + " import dock"; importD.transform.localScale = new Vector3(1, 1, 1); importD.transform.SetParent(islandGO.transform); islandGOComponent.setImportDock(importD); //setUVsToSingularCoord(new Vector2(0.7f, 0.1f), importD.GetComponent<MeshFilter>()); //Export Dock GameObject exportD = Instantiate(exportDockPrefab, dockPosition, Quaternion.identity); exportD.layer = LayerMask.NameToLayer("InteractionSystemLayer"); exportD.name = island.getName() + " export dock"; exportD.transform.localScale = new Vector3(1, 1, 1); exportD.transform.SetParent(islandGO.transform); islandGOComponent.setExportDock(exportD); //setUVsToSingularCoord(new Vector2(0.1f, 0.1f), exportD.GetComponent<MeshFilter>()); } #endregion islandGO.transform.position = pos; islandGO.transform.SetParent(VisualizationContainer.transform); #region rise Islands above ocean float newIslandHeight = Mathf.Abs(GlobalVar.islandHeightProfile[GlobalVar.islandHeightProfile.Length - 1]) * GlobalVar.islandAboveOcean; Vector3 newIslandPos = islandGO.transform.localPosition; newIslandPos.y = newIslandHeight; islandGO.transform.localPosition = newIslandPos; #endregion #region Create colliders #region CountryCollider List <Region> regions = islandGOComponent.getRegions(); foreach (Region region in regions) { GameObject countryGO = region.gameObject; countryGO.layer = LayerMask.NameToLayer("InteractionSystemLayer"); MeshCollider cColliderCountry = countryGO.AddComponent <MeshCollider>(); MeshFilter mFilter = region.getRegionArea().GetComponent <MeshFilter>(); cColliderCountry.sharedMesh = mFilter.sharedMesh; cColliderCountry.convex = true; cColliderCountry.isTrigger = true; } #endregion #region IslandCollider islandGO.layer = LayerMask.NameToLayer("InteractionSystemLayer"); CapsuleCollider cColliderIsland = islandGO.AddComponent <CapsuleCollider>(); float b = island.getRadius(); cColliderIsland.radius = b; float newColliderHeight = islandGOComponent.getCoast().GetComponent <MeshFilter>().sharedMesh.bounds.size.y; cColliderIsland.height = newColliderHeight; Vector3 newCenter = island.getWeightedCenter(); newCenter.y = -islandGOComponent.getCoast().GetComponent <MeshFilter>().sharedMesh.bounds.size.y + (newColliderHeight * 0.5f); cColliderIsland.center = newCenter; cColliderIsland.isTrigger = true; #endregion #endregion return(islandGOComponent); }
private void constructDockGO(IslandGO island) { CartographicIsland islandStructure = island.getIslandStructure(); //Get graph vertex associated with the island BidirectionalGraph <GraphVertex, GraphEdge> depGraph = islandStructure.getBundle().getParentProject().getDependencyGraph(); GraphVertex vert = islandStructure.getDependencyVertex(); if (vert != null) { float importSize = GlobalVar.minDockSize; float exportSize = GlobalVar.minDockSize; //Outgoing edges -Bundle depends on... IEnumerable <GraphEdge> outEdges; depGraph.TryGetOutEdges(vert, out outEdges); List <GraphEdge> edgeList = outEdges.ToList(); importSize = Helperfunctions.mapDependencycountToSize(edgeList.Count); //Import Dock GameObject importD = island.getImportDock(); importD.transform.localScale = new Vector3(importSize, importSize, importSize); //Link dependencies DependencyDock dockComponent = importD.GetComponent <DependencyDock>(); dockComponent.setDockType(DockType.ImportDock); foreach (GraphEdge e in edgeList) { GameObject ed = e.Target.getIsland().getIslandGO().GetComponent <IslandGO>().getExportDock(); dockComponent.addDockConnection(ed.GetComponent <DependencyDock>(), e.getWeight()); } #region determine optimal Position for ImportDock List <GameObject> doNotCollideList = new List <GameObject>(); doNotCollideList.Add(island.getCoast()); bool foundLocation = findSuitablePosition2D(importD, doNotCollideList, island.gameObject, 500); if (!foundLocation) { Debug.Log("Could not find suitable location for " + importD.name); } #endregion //Ingoing edges -Other Bundles depends on this one... depGraph.TryGetInEdges(vert, out outEdges); edgeList = outEdges.ToList(); exportSize = Helperfunctions.mapDependencycountToSize(edgeList.Count); //Export Dock GameObject exportD = island.getExportDock(); float eDockWidth = exportD.GetComponent <MeshFilter>().sharedMesh.bounds.size.x *exportSize; float iDockWidth = importD.GetComponent <MeshFilter>().sharedMesh.bounds.size.x *importSize; //exportD.transform.position = importD.transform.position + Vector3.left * (iDockWidth + eDockWidth) * 0.5f; exportD.transform.localScale = new Vector3(exportSize, exportSize, exportSize); //Link dependencies dockComponent = exportD.GetComponent <DependencyDock>(); dockComponent.setDockType(DockType.ExportDock); foreach (GraphEdge e in edgeList) { GameObject id = e.Source.getIsland().getIslandGO().GetComponent <IslandGO>().getImportDock(); dockComponent.addDockConnection(id.GetComponent <DependencyDock>(), e.getWeight()); } #region determine optimal Position for ExportDock doNotCollideList.Clear(); doNotCollideList.Add(island.getCoast()); foundLocation = findSuitablePosition2D(exportD, doNotCollideList, importD, 500); if (!foundLocation) { Debug.Log("Could not find suitable location for " + exportD.name); } #endregion #region extend Island collider based on new Docksizes island.GetComponent <CapsuleCollider>().radius += Mathf.Max(importSize, exportSize) * Mathf.Sqrt(2f); #endregion } }
private CartographicIsland constructIslandFromBundle(Bundle b) { int rngSeed = b.getName().GetHashCode() + 200; RNG = new System.Random(rngSeed); #region VoronoiPlane TriangleNet.Configuration conf = new TriangleNet.Configuration(); List <Vertex> vertices = Helperfunctions.createPointsOnPlane(GlobalVar.voronoiCellScalefactor, GlobalVar.voronoiCellScalefactor, 50, 50, 1.0f, RNG); BoundedVoronoi voronoi = Helperfunctions.createRelaxedVoronoi(vertices, 1); #endregion #region initFirstCell VFace firstCell = Helperfunctions.closestCell(0, 0, voronoi); Dictionary <int, VFace> startingCandidates = new Dictionary <int, VFace>(); startingCandidates.Add(firstCell.ID, firstCell); #endregion List <Package> packages = b.getPackages(); CartographicIsland island = new CartographicIsland(b); island.setVoronoi(voronoi); #region sort package list packages.Sort((x, y) => x.getCompilationUnits().Count.CompareTo(y.getCompilationUnits().Count)); packages.Reverse(); #endregion //Compute maximal compilation unit count in bundle float maxCUCountInIsland = 0; foreach (Package package in packages) { long cuCount = package.getCuCount(); if (cuCount > maxCUCountInIsland) { maxCUCountInIsland = cuCount; } } #region construct regions foreach (Package package in packages) { float cohesionMult = (float)package.getCuCount() / maxCUCountInIsland; cohesionMult *= maxCohesion; cohesionMult = Mathf.Max(minCohesion, cohesionMult); Dictionary <int, VFace> newCandidates = constructRegionFromPackage(package, island, startingCandidates, cohesionMult); updateAndFuseCandidates(startingCandidates, newCandidates); } #endregion #region Shape island coast //Advance startingCandidates X cells outwards and ajdust the height of all vertices shapeCoastArea(startingCandidates, GlobalVar.islandHeightProfile); #endregion #region WeightedCenter & set coast List <VFace> coastlineList = new List <VFace>(); Vector3 weightedCenter = Vector3.zero; foreach (KeyValuePair <int, VFace> kvp in startingCandidates) { coastlineList.Add(kvp.Value); float x = (float)kvp.Value.generator.X; float z = (float)kvp.Value.generator.Y; Vector3 tilePos = new Vector3(x, 0, z); weightedCenter += tilePos; } weightedCenter /= startingCandidates.Count; island.setWeightedCenter(weightedCenter); island.setCoastlineCells(coastlineList); #endregion #region conservative Radius List <float> radii = new List <float>(); foreach (KeyValuePair <int, VFace> kvp in startingCandidates) { float x = (float)kvp.Value.generator.X - island.getWeightedCenter().x; float z = (float)kvp.Value.generator.Y - island.getWeightedCenter().z; float radius = Mathf.Sqrt(x * x + z * z); radii.Add(radius); } float maxRadius = Helperfunctions.computeMax(radii); island.setRadius(maxRadius); #endregion #region TnetMeshesConstruction foreach (List <VFace> cellMap in island.getPackageCells()) { island.addPackageMesh(constructTnetMeshFromCellmap(cellMap)); } island.setCoastlineMesh(constructTnetMeshFromCellmap(coastlineList)); #endregion #region link dependency vertex //Find graph vertex associated with the island BidirectionalGraph <GraphVertex, GraphEdge> depGraph = b.getParentProject().getDependencyGraph(); List <GraphVertex> allVertices = depGraph.Vertices.ToList(); GraphVertex vert = allVertices.Find(v => string.Equals(v.getName(), b.getName())); if (vert != null) { //Link GraphVertex-Island vert.setIsland(island); island.setDependencyVertex(vert); } #endregion return(island); }
private void bakeIslandMesh(IslandGO islandGOComponent) { GameObject islandGO = islandGOComponent.gameObject; List <CombineInstance> currentCiList = new List <CombineInstance>(); foreach (Region region in islandGOComponent.getRegions()) { foreach (Building b in region.getBuildings()) { CombineInstance ci = new CombineInstance(); CompilationUnit cu = b.getCU(); long loc = cu.getLoc(); int modelIdx = Helperfunctions.mapLOCtoLevel(loc); if (cu.implementsServiceComponent()) { ci.mesh = SILod2Prefabs[modelIdx].GetComponent <MeshFilter>().sharedMesh; } else if (cu.declaresService()) { ci.mesh = SDLod2Prefabs[modelIdx].GetComponent <MeshFilter>().sharedMesh; } else { ci.mesh = CULod2Prefabs[modelIdx].GetComponent <MeshFilter>().sharedMesh; } ci.subMeshIndex = 0; ci.transform = islandGO.transform.worldToLocalMatrix * b.gameObject.transform.localToWorldMatrix; currentCiList.Add(ci); } CombineInstance ciCountry = new CombineInstance(); ciCountry.mesh = region.getRegionArea().GetComponent <MeshFilter>().sharedMesh; ciCountry.subMeshIndex = 0; ciCountry.transform = Matrix4x4.identity; currentCiList.Add(ciCountry); } #region Add coast to FinalCombineList CombineInstance ciCoast = new CombineInstance(); ciCoast.mesh = islandGOComponent.getCoast().GetComponent <MeshFilter>().sharedMesh; ciCoast.subMeshIndex = 0; ciCoast.transform = Matrix4x4.identity; currentCiList.Add(ciCoast); #endregion #region Add docks to FinalCombineList GameObject expDock = islandGOComponent.getExportDock(); GameObject impDock = islandGOComponent.getImportDock(); CombineInstance eDockCI = new CombineInstance(); eDockCI.mesh = eDockLod1Prefab.GetComponent <MeshFilter>().sharedMesh; eDockCI.subMeshIndex = 0; eDockCI.transform = islandGOComponent.transform.worldToLocalMatrix * expDock.transform.localToWorldMatrix; CombineInstance iDockCI = new CombineInstance(); iDockCI.mesh = iDockLod1Prefab.GetComponent <MeshFilter>().sharedMesh; iDockCI.subMeshIndex = 0; iDockCI.transform = islandGOComponent.transform.worldToLocalMatrix * impDock.transform.localToWorldMatrix; currentCiList.Add(eDockCI); currentCiList.Add(iDockCI); #endregion #region Replace Island Mesh and Materials with baked one MeshRenderer bakedMR = islandGO.AddComponent <MeshRenderer>(); bakedMR.sharedMaterial = holomaterial; MeshFilter bakedMF = islandGO.AddComponent <MeshFilter>(); bakedMF.mesh = new Mesh(); bakedMF.sharedMesh.CombineMeshes(currentCiList.ToArray(), true, true); #endregion }