private void OnDrawGizmos() { if (!isEnabled) { return; } //Generate the random sites List <Vector2> randomSites = new List <Vector2>(); //Generate random numbers with a seed Random.InitState(seed); int max = mapRadius; int min = -mapRadius; for (int i = 0; i < numberOfPoints; i++) { int randomX = Random.Range(min, max); int randomZ = Random.Range(min, max); randomSites.Add(new Vector2(randomX, randomZ)); } //Points outside of the screen for voronoi which has some cells that are infinite float bigSize = mapRadius * 5f; //Star shape which will give a better result when a cell is infinite large //When using other shapes, some of the infinite cells misses triangles randomSites.Add(new Vector2(0f, bigSize)); randomSites.Add(new Vector2(0f, -bigSize)); randomSites.Add(new Vector2(bigSize, 0f)); randomSites.Add(new Vector2(-bigSize, 0f)); //Generate the voronoi diagram var(vertices, triangles) = Delaunay.GenerateTriangulation(randomSites); var cells = Delaunay.GenerateVoronoiCells((vertices, triangles)); //Display the voronoi diagram LevelDataTester.DrawShapes(cells.Values.ToArray(), Vector3.zero); if (showDelaunayDiagam) { LevelDataTester.DrawShapes(triangles.Values.ToArray(), Vector3.forward, true); } //Display the sites Gizmos.color = Color.white; for (int i = 0; i < randomSites.Count; i++) { float radius = 0.2f; Gizmos.DrawSphere(randomSites[i], radius); } }
public override void OnInspectorGUI() { /// Just info about the chunk EditorGUILayout.LabelField("Chunk Info:", "-----"); EditorGUI.BeginDisabledGroup(true); TestChunkCursor cursor = target as TestChunkCursor; EditorGUILayout.Vector3Field("Chunk ID", Chunk.IDFromWorldLocation(cursor.transform.position)); EditorGUI.EndDisabledGroup(); chunkHistoryItemsToGet = LevelDataTester.InspectorDrawChunkHistoryGUIButton(Chunk.IDFromWorldLocation(cursor.transform.position), chunkHistoryItemsToGet); DrawDefaultInspector(); }
public override void OnInspectorGUI() { EditorGUILayout.LabelField("Focus Info:", "-----"); // Just info about the chunk EditorGUI.BeginDisabledGroup(true); FocusManager focus = target as FocusManager; EditorGUILayout.Toggle("Is Active", focus.isActive); EditorGUILayout.Vector3Field("Chunk ID", focus.currentChunkID.vec3); EditorGUILayout.Vector3Field("World Voxel Location", focus.worldLocation * World.BlockSize); EditorGUI.EndDisabledGroup(); chunkHistoryItemsToGet = LevelDataTester.InspectorDrawChunkHistoryGUIButton(focus.currentChunkID, chunkHistoryItemsToGet); }
public override void OnInspectorGUI() { /// Just info about the chunk EditorGUILayout.LabelField("Chunk Info:", "-----"); EditorGUI.BeginDisabledGroup(true); ChunkController chunkController = target as ChunkController; EditorGUILayout.Vector3Field("Current Controlled Chunk ID", chunkController.chunkLocation.vec3); EditorGUILayout.Toggle("Is Active", chunkController.isActive); EditorGUILayout.Toggle("Is Meshed", chunkController.isMeshed); EditorGUI.EndDisabledGroup(); if (GUILayout.Button("Print Chunk Controller Edit History Log")) { LevelDataTester.PrintChunkControllerRecords( int.Parse(chunkController.gameObject.name.Split('#')[1]), chunkController.terrainManager ); } chunkHistoryItemsToGet = LevelDataTester.InspectorDrawChunkHistoryGUIButton(chunkController.chunkLocation, chunkHistoryItemsToGet); DrawDefaultInspector(); }