From 3c432a5c9ebb2467b55ad6bd110f90318ab2f613 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Fri, 19 Jan 2024 20:45:23 -0600 Subject: [PATCH] load mesh data and structure meshes --- src/engine/collisionEngine/Mesh.java | 14 ++-- src/engine/devcmd/cmds/ColliderCmd.java | 79 +++++++++++++++++++++++ src/engine/gameManager/DevCmdManager.java | 1 + 3 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 src/engine/devcmd/cmds/ColliderCmd.java diff --git a/src/engine/collisionEngine/Mesh.java b/src/engine/collisionEngine/Mesh.java index 5942d52d..03fad64b 100644 --- a/src/engine/collisionEngine/Mesh.java +++ b/src/engine/collisionEngine/Mesh.java @@ -15,13 +15,13 @@ public class Mesh { public int parentUUID; public MeshData meshData; private int meshID; - private Rectangle2D.Float bounds; - private ArrayList triangles; - private Vector3f mesh_loc; - private Vector3f mesh_ref; - private Vector3f mesh_end; - private float mesh_maxY; - private float mesh_minY; + public Rectangle2D.Float bounds; + public ArrayList triangles; + public Vector3f mesh_loc; + public Vector3f mesh_ref; + public Vector3f mesh_end; + public float mesh_maxY; + public float mesh_minY; public Mesh(MeshData data, int parentUUID){ this.meshData = data; diff --git a/src/engine/devcmd/cmds/ColliderCmd.java b/src/engine/devcmd/cmds/ColliderCmd.java new file mode 100644 index 00000000..0a4568f3 --- /dev/null +++ b/src/engine/devcmd/cmds/ColliderCmd.java @@ -0,0 +1,79 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.devcmd.cmds; + +import engine.Enum; +import engine.Enum.BuildingGroup; +import engine.Enum.GameObjectType; +import engine.Enum.TargetColor; +import engine.collisionEngine.Mesh; +import engine.devcmd.AbstractDevCmd; +import engine.gameManager.BuildingManager; +import engine.gameManager.SessionManager; +import engine.math.Vector3fImmutable; +import engine.objects.*; +import engine.util.StringUtils; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; + + +/** + * @author + */ +public class ColliderCmd extends AbstractDevCmd { + + public ColliderCmd() { + super("collider"); + } + + @Override + protected void _doCmd(PlayerCharacter pc, String[] words, + AbstractGameObject target) { + // Arg Count Check + if (words.length != 1) { + this.sendUsage(pc); + return; + } + if (pc == null) { + return; + } + + String newline = "\r\n "; + String output = "----------Collider Information----------" + newline; + if(target.getObjectType().equals(GameObjectType.Building) == false) + throwbackInfo(pc, "You Must Select A Building"); + + Building building = (Building)target; + output += "Mesh Count: " + ((Building) target).buildingMeshes.size() + newline; + for(Mesh mesh : building.buildingMeshes){ + output += "------------------------------" + newline; + output += "Mesh ID: " + mesh.meshData.meshID + newline; + output += "Mesh Tri Count: " + mesh.triangles.size() + newline; + output += "Mesh Bounds: " + mesh.bounds + newline; + output += "Mesh Min/Max: " + mesh.mesh_minY + " / " + mesh.mesh_maxY + newline; + output += "Location Inside: " + mesh.bounds.contains(pc.loc.x,pc.loc.z * -1) + newline; + output += "------------------------------" + newline; + } + throwbackInfo(pc, output); + } + + @Override + protected String _getHelpString() { + return "Gets information on an Object."; + } + + @Override + protected String _getUsageString() { + return "' /info targetID'"; + } + +} diff --git a/src/engine/gameManager/DevCmdManager.java b/src/engine/gameManager/DevCmdManager.java index 52c730b6..85224ecd 100644 --- a/src/engine/gameManager/DevCmdManager.java +++ b/src/engine/gameManager/DevCmdManager.java @@ -58,6 +58,7 @@ public enum DevCmdManager { DevCmdManager.registerDevCmd(new PrintResistsCmd()); DevCmdManager.registerDevCmd(new PrintLocationCmd()); DevCmdManager.registerDevCmd(new InfoCmd()); + DevCmdManager.registerDevCmd(new ColliderCmd()); DevCmdManager.registerDevCmd(new aiInfoCmd()); DevCmdManager.registerDevCmd(new SimulateBootyCmd()); DevCmdManager.registerDevCmd(new GetHeightCmd());