diff --git a/src/main/java/electrosphere/client/ui/menu/debug/ImGuiClientServices.java b/src/main/java/electrosphere/client/ui/menu/debug/ImGuiClientServices.java new file mode 100644 index 00000000..aa1d79b7 --- /dev/null +++ b/src/main/java/electrosphere/client/ui/menu/debug/ImGuiClientServices.java @@ -0,0 +1,94 @@ +package electrosphere.client.ui.menu.debug; + +import org.joml.Vector3i; + +import electrosphere.client.entity.camera.CameraEntityUtils; +import electrosphere.client.terrain.cache.ChunkData; +import electrosphere.client.terrain.cells.DrawCell; +import electrosphere.client.terrain.foliage.FoliageCell; +import electrosphere.engine.Globals; +import electrosphere.logger.LoggerInterface; +import electrosphere.renderer.ui.imgui.ImGuiWindow; +import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback; +import imgui.ImGui; + +/** + * Debug ui for draw cells + */ +public class ImGuiClientServices { + + /** + * Window for viewing chunk status on server and client + */ + protected static ImGuiWindow clientServicesWindow; + + /** + * Creates the windows in this file + */ + protected static void createClientServicesWindows(){ + ImGuiClientServices.createClientServicesWindow(); + } + + /** + * Client scene entity view + */ + protected static void createClientServicesWindow(){ + clientServicesWindow = new ImGuiWindow("Draw Cells"); + clientServicesWindow.setCallback(new ImGuiWindowCallback() { + @Override + public void exec() { + + if(ImGui.collapsingHeader("Draw Cells")){ + if(ImGui.button("Debug DrawCell at camera position")){ + Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera)); + DrawCell cell = Globals.clientDrawCellManager.getDrawCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z); + LoggerInterface.loggerEngine.WARNING("" + cell); + + LoggerInterface.loggerEngine.WARNING("Chunk topology:"); + ChunkData data = Globals.clientTerrainManager.getChunkDataAtWorldPoint(cameraWorldPos, 1); + if(data != null){ + for(int x = 0; x < ChunkData.CHUNK_DATA_SIZE; x++){ + String line = ""; + for(int z = 0; z < ChunkData.CHUNK_DATA_SIZE; z++){ + int height = 0; + for(int y = 0; y < ChunkData.CHUNK_DATA_SIZE; y++){ + if(data.getType(x, y, z) != 0){ + height = y; + } + } + line = line + String.format("%2d ",height); + } + LoggerInterface.loggerEngine.WARNING(line); + } + LoggerInterface.loggerEngine.WARNING("\n"); + } else { + LoggerInterface.loggerEngine.WARNING("Chunk not in cache! " + cameraWorldPos); + } + } + if(ImGui.button("Print debug info for FoliageCell at camera position")){ + Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera)); + FoliageCell cell = Globals.foliageCellManager.getFoliageCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z); + LoggerInterface.loggerEngine.WARNING("" + cell); + } + if(ImGui.button("Debug FoliageCell evaluation at camera position")){ + Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera)); + FoliageCell cell = Globals.foliageCellManager.getFoliageCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z); + cell.setTripDebug(true); + } + if(ImGui.button("Request terrain at camera position")){ + Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera)); + Globals.clientTerrainManager.requestChunk(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z, 0); + } + } + + + if(ImGui.collapsingHeader("Interaction Engine")){ + + } + } + }); + clientServicesWindow.setOpen(false); + Globals.renderingEngine.getImGuiPipeline().addImGuiWindow(clientServicesWindow); + } + +} diff --git a/src/main/java/electrosphere/client/ui/menu/debug/ImGuiDrawCell.java b/src/main/java/electrosphere/client/ui/menu/debug/ImGuiDrawCell.java deleted file mode 100644 index 12ad8ed2..00000000 --- a/src/main/java/electrosphere/client/ui/menu/debug/ImGuiDrawCell.java +++ /dev/null @@ -1,86 +0,0 @@ -package electrosphere.client.ui.menu.debug; - -import org.joml.Vector3i; - -import electrosphere.client.entity.camera.CameraEntityUtils; -import electrosphere.client.terrain.cache.ChunkData; -import electrosphere.client.terrain.cells.DrawCell; -import electrosphere.client.terrain.foliage.FoliageCell; -import electrosphere.engine.Globals; -import electrosphere.logger.LoggerInterface; -import electrosphere.renderer.ui.imgui.ImGuiWindow; -import electrosphere.renderer.ui.imgui.ImGuiWindow.ImGuiWindowCallback; -import imgui.ImGui; - -/** - * Debug ui for draw cells - */ -public class ImGuiDrawCell { - - /** - * Window for viewing chunk status on server and client - */ - protected static ImGuiWindow drawCellWindow; - - /** - * Creates the windows in this file - */ - protected static void createDrawCellWindows(){ - ImGuiDrawCell.createDrawCellWindow(); - } - - /** - * Client scene entity view - */ - protected static void createDrawCellWindow(){ - drawCellWindow = new ImGuiWindow("Draw Cells"); - drawCellWindow.setCallback(new ImGuiWindowCallback() { - @Override - public void exec() { - if(ImGui.button("Debug DrawCell at camera position")){ - Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera)); - DrawCell cell = Globals.clientDrawCellManager.getDrawCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z); - LoggerInterface.loggerEngine.WARNING("" + cell); - - LoggerInterface.loggerEngine.WARNING("Chunk topology:"); - ChunkData data = Globals.clientTerrainManager.getChunkDataAtWorldPoint(cameraWorldPos, 1); - if(data != null){ - for(int x = 0; x < ChunkData.CHUNK_DATA_SIZE; x++){ - String line = ""; - for(int z = 0; z < ChunkData.CHUNK_DATA_SIZE; z++){ - int height = 0; - for(int y = 0; y < ChunkData.CHUNK_DATA_SIZE; y++){ - if(data.getType(x, y, z) != 0){ - height = y; - } - } - line = line + String.format("%2d ",height); - } - LoggerInterface.loggerEngine.WARNING(line); - } - LoggerInterface.loggerEngine.WARNING("\n"); - } else { - LoggerInterface.loggerEngine.WARNING("Chunk not in cache! " + cameraWorldPos); - } - } - if(ImGui.button("Print debug info for FoliageCell at camera position")){ - Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera)); - FoliageCell cell = Globals.foliageCellManager.getFoliageCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z); - LoggerInterface.loggerEngine.WARNING("" + cell); - } - if(ImGui.button("Debug FoliageCell evaluation at camera position")){ - Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera)); - FoliageCell cell = Globals.foliageCellManager.getFoliageCell(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z); - cell.setTripDebug(true); - } - if(ImGui.button("Request terrain at camera position")){ - Vector3i cameraWorldPos = Globals.clientWorldData.convertRealToWorldSpace(CameraEntityUtils.getCameraCenter(Globals.playerCamera)); - Globals.clientTerrainManager.requestChunk(cameraWorldPos.x, cameraWorldPos.y, cameraWorldPos.z, 0); - } - } - }); - drawCellWindow.setOpen(false); - Globals.renderingEngine.getImGuiPipeline().addImGuiWindow(drawCellWindow); - } - -} diff --git a/src/main/java/electrosphere/client/ui/menu/debug/ImGuiWindowMacros.java b/src/main/java/electrosphere/client/ui/menu/debug/ImGuiWindowMacros.java index 6def08f6..528f4635 100644 --- a/src/main/java/electrosphere/client/ui/menu/debug/ImGuiWindowMacros.java +++ b/src/main/java/electrosphere/client/ui/menu/debug/ImGuiWindowMacros.java @@ -53,7 +53,7 @@ public class ImGuiWindowMacros { ImGuiGriddedManager.createGriddedManagerWindows(); ImGuiMemory.createMemoryWindows(); ImGuiEditorWindows.initEditorWindows(); - ImGuiDrawCell.createDrawCellWindows(); + ImGuiClientServices.createClientServicesWindows(); } /** @@ -182,7 +182,7 @@ public class ImGuiWindowMacros { ImGuiNetworkMonitor.netMonitorWindow.setOpen(true); } if(ImGui.button("Client Draw Cell Utils")){ - ImGuiDrawCell.drawCellWindow.setOpen(true); + ImGuiClientServices.clientServicesWindow.setOpen(true); } //close button if(ImGui.button("Close")){