From 1cc4924c3bb74398d79973fa4bf578a10b22e45b Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 11 Aug 2024 13:59:37 -0400 Subject: [PATCH] more debug menus --- assets/Data/creatures/human.json | 4 +- .../menu/debug/ImGuiEntityMacros.java | 79 +++++++++++++++++++ 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/assets/Data/creatures/human.json b/assets/Data/creatures/human.json index e704b6b0..2b62465c 100644 --- a/assets/Data/creatures/human.json +++ b/assets/Data/creatures/human.json @@ -316,7 +316,7 @@ "priorityCategory": "MOVEMENT_MODIFIER", "boneGroups" : ["armLeft", "armRight", "handLeft", "handRight"] }, - "mainAudio" : { + "windUpAudio" : { "audioPath" : "Audio/weapons/swordUnsheath1.ogg" }, "defaults" : [ @@ -334,7 +334,7 @@ "priorityCategory": "MOVEMENT_MODIFIER", "boneGroups" : ["armLeft", "armRight", "handLeft", "handRight"] }, - "mainAudio" : { + "windUpAudio" : { "audioPath" : "Audio/weapons/swordUnsheath1.ogg" }, "defaults" : [ diff --git a/src/main/java/electrosphere/menu/debug/ImGuiEntityMacros.java b/src/main/java/electrosphere/menu/debug/ImGuiEntityMacros.java index 14f56afb..2569c8b0 100644 --- a/src/main/java/electrosphere/menu/debug/ImGuiEntityMacros.java +++ b/src/main/java/electrosphere/menu/debug/ImGuiEntityMacros.java @@ -6,7 +6,9 @@ import java.util.Set; import org.joml.Quaterniond; import org.joml.Vector3d; +import org.ode4j.ode.DBody; +import electrosphere.collision.PhysicsEntityUtils; import electrosphere.engine.Globals; import electrosphere.entity.Entity; import electrosphere.entity.EntityUtils; @@ -52,6 +54,7 @@ public class ImGuiEntityMacros { private static boolean showFirstPersonTab = false; //first person tab private static boolean showLinkedEntitiesTab = false;//show linked entities private static boolean showServerViewDirTab = false; //show server view dir + private static boolean showPhysicsTab = false; //show physics values /** * Creates the windows in this file @@ -123,6 +126,9 @@ public class ImGuiEntityMacros { if(ServerPlayerViewDirTree.hasTree(detailViewEntity) && ImGui.checkbox("Server View Dir", showServerViewDirTab)){ showServerViewDirTab = !showServerViewDirTab; } + if(PhysicsEntityUtils.getDBody(detailViewEntity) != null && ImGui.checkbox("Physics", showPhysicsTab)){ + showPhysicsTab = !showPhysicsTab; + } ImGui.treePop(); } ImGui.nextColumn(); @@ -131,6 +137,7 @@ public class ImGuiEntityMacros { drawFirstPersonView(); drawLinkedEntities(); drawServerViewDir(); + drawPhysicsDetails(); } }); clientEntityDetailWindow.setOpen(false); @@ -399,6 +406,23 @@ public class ImGuiEntityMacros { } } } + if(Globals.clientSceneWrapper.getScene().getEntityFromId(detailViewEntity.getId()) != null){ + //detailViewEntity is a client entity + //get server entity + int serverIdForClientEntity = Globals.clientSceneWrapper.mapClientToServerId(detailViewEntity.getId()); + Entity serverEntity = EntityLookupUtils.getEntityById(serverIdForClientEntity); + if(serverEntity != null && ImGui.button("Server Entity")){ + showEntity(serverEntity); + } + } else if(Globals.clientSceneWrapper.containsServerId(detailViewEntity.getId())){ + //detailViewEntity is a server entity + //get client entity + int clientId = Globals.clientSceneWrapper.mapServerToClientId(detailViewEntity.getId()); + Entity clientEntity = Globals.clientSceneWrapper.getScene().getEntityFromId(clientId); + if(clientEntity != null && ImGui.button("Client Entity")){ + showEntity(clientEntity); + } + } ImGui.unindent(); } } @@ -418,6 +442,61 @@ public class ImGuiEntityMacros { } } + /** + * Physics details + */ + protected static void drawPhysicsDetails(){ + if(showPhysicsTab && ImGui.collapsingHeader("Physics")){ + ImGui.indent(); + if(PhysicsEntityUtils.getDBody(detailViewEntity) != null){ + DBody physicsBody = PhysicsEntityUtils.getDBody(detailViewEntity); + if(physicsBody != null){ + ImGui.text("Position (Server): " + EntityUtils.getPosition(detailViewEntity)); + ImGui.text("Rotation (Server): " + EntityUtils.getRotation(detailViewEntity)); + ImGui.text("Velocity (Server): " + physicsBody.getLinearVel()); + ImGui.text("Force (Server): " + physicsBody.getForce()); + ImGui.text("Move Vector (Server): " + CreatureUtils.getFacingVector(detailViewEntity)); + ImGui.text("Velocity (Server): " + CreatureUtils.getVelocity(detailViewEntity)); + } + //synchronized data + if(Globals.clientSceneWrapper.getScene().getEntityFromId(detailViewEntity.getId()) != null){ + //detailViewEntity is a client entity + //get server entity + int serverIdForClientEntity = Globals.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()); + Entity serverEntity = EntityLookupUtils.getEntityById(serverIdForClientEntity); + DBody serverPhysicsBody = PhysicsEntityUtils.getDBody(serverEntity); + if(serverPhysicsBody != null){ + ImGui.newLine(); + ImGui.text("Linked server entity:"); + ImGui.text("Position (Server): " + EntityUtils.getPosition(serverEntity)); + ImGui.text("Rotation (Server): " + EntityUtils.getRotation(serverEntity)); + ImGui.text("Velocity (Server): " + serverPhysicsBody.getLinearVel()); + ImGui.text("Force (Server): " + serverPhysicsBody.getForce()); + ImGui.text("Move Vector (Server): " + CreatureUtils.getFacingVector(serverEntity)); + ImGui.text("Velocity (Server): " + CreatureUtils.getVelocity(serverEntity)); + } + } else if(Globals.clientSceneWrapper.containsServerId(detailViewEntity.getId())){ + //detailViewEntity is a server entity + //get client entity + int clientId = Globals.clientSceneWrapper.mapServerToClientId(detailViewEntity.getId()); + Entity clientEntity = Globals.clientSceneWrapper.getScene().getEntityFromId(clientId); + DBody clientPhysicsBody = PhysicsEntityUtils.getDBody(clientEntity); + if(clientPhysicsBody != null){ + ImGui.newLine(); + ImGui.text("Linked client entity:"); + ImGui.text("Position (Server): " + EntityUtils.getPosition(clientEntity)); + ImGui.text("Rotation (Server): " + EntityUtils.getRotation(clientEntity)); + ImGui.text("Velocity (Server): " + clientPhysicsBody.getLinearVel()); + ImGui.text("Force (Server): " + clientPhysicsBody.getForce()); + ImGui.text("Move Vector (Server): " + CreatureUtils.getFacingVector(clientEntity)); + ImGui.text("Velocity (Server): " + CreatureUtils.getVelocity(clientEntity)); + } + } + } + ImGui.unindent(); + } + } + /** * Gets the displayed name of an entity (ie creature type, foliage type, terrain, etc) * @param entity