diff --git a/assets/Models/engine/waypoint.glb b/assets/Models/engine/waypoint.glb new file mode 100644 index 00000000..667309ca Binary files /dev/null and b/assets/Models/engine/waypoint.glb differ diff --git a/buildNumber.properties b/buildNumber.properties index 4a46a5b5..da30554b 100644 --- a/buildNumber.properties +++ b/buildNumber.properties @@ -1,3 +1,3 @@ #maven.buildNumber.plugin properties file -#Wed May 28 21:00:17 EDT 2025 -buildNumber=643 +#Fri May 30 13:38:53 EDT 2025 +buildNumber=644 diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 1fc5e839..4523ff4f 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -2075,6 +2075,7 @@ Sprinting/physics work Reorganizing macro classes Start work on macro pathfinding storage Town constructs nav graph of road nodes +Render pathing nodes (still needs some work) diff --git a/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java b/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java index 3c65af21..ca4e3843 100644 --- a/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java +++ b/src/main/java/electrosphere/engine/assetmanager/AssetDataStrings.java @@ -103,4 +103,9 @@ public class AssetDataStrings { public static final String INTERACT_SFX_BLOCK_PICKUP = "Audio/interact/Grab Cloth High A.wav"; public static final String INTERACT_SFX_BLOCK_PLACE = "Audio/interact/High Five A.wav"; + /** + * Debug geometry of the engine + */ + public static final String MODEL_WAYPOINT = "Models/engine/waypoint.glb"; + } diff --git a/src/main/java/electrosphere/entity/DrawableUtils.java b/src/main/java/electrosphere/entity/DrawableUtils.java index 5c650b11..51580287 100644 --- a/src/main/java/electrosphere/entity/DrawableUtils.java +++ b/src/main/java/electrosphere/entity/DrawableUtils.java @@ -125,4 +125,21 @@ public class DrawableUtils { Globals.clientState.clientScene.registerEntityToTag(entity, EntityTags.DRAW_CAST_SHADOW); } + /** + * Makes an entity drawable with a model at a given path + * @param entity The entity + * @param path The path to the model + */ + public static void makeEntityDrawable(Entity entity, String path){ + entity.putData(EntityDataStrings.DATA_STRING_ACTOR, ActorUtils.createActorFromModelPath(path)); + entity.putData(EntityDataStrings.DATA_STRING_POSITION, new Vector3d(0,0,0)); + entity.putData(EntityDataStrings.DATA_STRING_ROTATION, new Quaterniond().identity()); + entity.putData(EntityDataStrings.DATA_STRING_SCALE, new Vector3f(1,1,1)); + entity.putData(EntityDataStrings.DATA_STRING_DRAW, true); + entity.putData(EntityDataStrings.DRAW_SOLID_PASS, true); + Globals.clientState.clientScene.registerEntityToTag(entity, EntityTags.DRAWABLE); + Globals.clientState.clientScene.registerEntityToTag(entity, EntityTags.DRAW_VOLUMETIC_SOLIDS_PASS); + Globals.clientState.clientScene.registerEntityToTag(entity, EntityTags.DRAW_CAST_SHADOW); + } + } diff --git a/src/main/java/electrosphere/renderer/pipelines/debug/DebugContentPipeline.java b/src/main/java/electrosphere/renderer/pipelines/debug/DebugContentPipeline.java index e4ad8df9..ebb86c25 100644 --- a/src/main/java/electrosphere/renderer/pipelines/debug/DebugContentPipeline.java +++ b/src/main/java/electrosphere/renderer/pipelines/debug/DebugContentPipeline.java @@ -7,7 +7,7 @@ import org.joml.AABBd; import org.joml.Matrix4d; import org.joml.Quaterniond; import org.joml.Vector3d; -import org.lwjgl.opengl.GL40; +import org.lwjgl.opengl.GL45; import org.ode4j.ode.DAABBC; import org.ode4j.ode.DCapsule; import org.ode4j.ode.DGeom; @@ -51,6 +51,7 @@ import electrosphere.server.datacell.utils.EntityLookupUtils; import electrosphere.server.macro.MacroData; import electrosphere.server.macro.civilization.road.Road; import electrosphere.server.macro.region.MacroRegion; +import electrosphere.server.macro.spatial.path.MacroPathNode; import electrosphere.server.macro.structure.VirtualStructure; import electrosphere.util.math.SpatialMathUtils; import electrosphere.util.math.region.RegionPrism; @@ -68,6 +69,11 @@ public class DebugContentPipeline implements RenderPipeline { */ private List farmPlotEntities = new LinkedList(); + /** + * Renderables for macro nav graph entities + */ + private List macroNavEntities = new LinkedList(); + @Override public void render(OpenGLState openGLState, RenderPipelineState renderPipelineState) { Globals.profiler.beginCpuSample("DebugContentPipeline.render"); @@ -75,8 +81,8 @@ public class DebugContentPipeline implements RenderPipeline { //bind screen fbo RenderingEngine.screenFramebuffer.bind(openGLState); openGLState.glDepthTest(true); - openGLState.glDepthFunc(GL40.GL_LESS); - GL40.glDepthMask(true); + openGLState.glDepthFunc(GL45.GL_LESS); + GL45.glDepthMask(true); openGLState.glViewport(Globals.gameConfigCurrent.getSettings().getRenderResolutionX(), Globals.gameConfigCurrent.getSettings().getRenderResolutionY()); /// @@ -242,6 +248,41 @@ public class DebugContentPipeline implements RenderPipeline { } } } + if(this.macroNavEntities.isEmpty()){ + MacroData macroData = Globals.serverState.realmManager.first().getMacroData(); + List pathNodes = macroData.getPathCache().getNodes(); + if(pathNodes.size() > 0){ + for(MacroPathNode pathNode : pathNodes){ + Entity pathDebugEnt = EntityCreationUtils.createClientSpatialEntity(); + DrawableUtils.makeEntityDrawable(pathDebugEnt, AssetDataStrings.MODEL_WAYPOINT); + EntityUtils.getPosition(pathDebugEnt).set(pathNode.getPosition()); + EntityUtils.getScale(pathDebugEnt).set(1); + this.macroNavEntities.add(pathDebugEnt); + //draw paths between nodes + List neighbors = pathNode.getNeighborNodes(macroData.getPathCache()); + for(MacroPathNode neighbor : neighbors){ + if(neighbor.getId() < pathNode.getId()){ + + } + } + } + } + } else { + //render connections between points + MacroData macroData = Globals.serverState.realmManager.first().getMacroData(); + List pathNodes = macroData.getPathCache().getNodes(); + if(pathNodes.size() > 0){ + for(MacroPathNode pathNode : pathNodes){ + //draw paths between nodes + List neighbors = pathNode.getNeighborNodes(macroData.getPathCache()); + for(MacroPathNode neighbor : neighbors){ + if(neighbor.getId() < pathNode.getId()){ + DebugContentPipeline.renderTube(openGLState, renderPipelineState, modelTransformMatrix, pathNode.getPosition(), neighbor.getPosition(), 1, AssetDataStrings.TEXTURE_YELLOW_TRANSPARENT); + } + } + } + } + } } else { if(!this.farmPlotEntities.isEmpty()){ for(Entity entity : this.farmPlotEntities){ @@ -249,6 +290,12 @@ public class DebugContentPipeline implements RenderPipeline { } this.farmPlotEntities.clear(); } + if(!this.macroNavEntities.isEmpty()){ + for(Entity entity : this.macroNavEntities){ + ClientEntityUtils.destroyEntity(entity); + } + this.macroNavEntities.clear(); + } } // diff --git a/src/main/java/electrosphere/server/macro/spatial/path/MacroPathNode.java b/src/main/java/electrosphere/server/macro/spatial/path/MacroPathNode.java index 495053b5..4c7c69a2 100644 --- a/src/main/java/electrosphere/server/macro/spatial/path/MacroPathNode.java +++ b/src/main/java/electrosphere/server/macro/spatial/path/MacroPathNode.java @@ -199,7 +199,7 @@ public class MacroPathNode { * @return The list of node ids */ public List getNeighborNodes(MacroPathCache cache) { - return this.neighborNodes.stream().map((Long id) -> cache.getNodeById(objectId)).collect(Collectors.toList()); + return this.neighborNodes.stream().map((Long neighborId) -> cache.getNodeById(neighborId)).collect(Collectors.toList()); } /**