From 94b692d610aa5a2fa4f6b3f9a3c8b37c2c176b64 Mon Sep 17 00:00:00 2001 From: Lukadcf <156549307+Lukadcf@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:31:14 +0200 Subject: [PATCH 1/9] Added pitch param to setGlobalRotation --- .../worldseed/multipart/GenericModelImpl.java | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/worldseed/multipart/GenericModelImpl.java b/src/main/java/net/worldseed/multipart/GenericModelImpl.java index ad71c9a1..31ea76c6 100644 --- a/src/main/java/net/worldseed/multipart/GenericModelImpl.java +++ b/src/main/java/net/worldseed/multipart/GenericModelImpl.java @@ -53,8 +53,12 @@ public abstract class GenericModelImpl implements GenericModel { protected Instance instance; private Pos position; private double globalRotation; + private double pitch; + + protected record ModelBoneInfo(String name, Point pivot, Point rotation, JsonArray cubes, GenericModel model, + float scale) { + } - protected record ModelBoneInfo(String name, Point pivot, Point rotation, JsonArray cubes, GenericModel model, float scale) {} protected final Map, Function> boneSuppliers = new LinkedHashMap<>(); Function defaultBoneSupplier = (info) -> new ModelBonePartDisplay(info.pivot, info.name, info.rotation, info.model, info.scale); @@ -80,11 +84,21 @@ public double getGlobalRotation() { return globalRotation; } - public void setGlobalRotation(double rotation) { - this.globalRotation = rotation; + @Override + public double getPitch(){ + return pitch; + } + + public void setGlobalRotation(double yaw) { + setGlobalRotation(yaw, 0.0f); + } + + public void setGlobalRotation(double yaw, double pitch) { + this.globalRotation = yaw; + this.pitch = pitch; this.viewableBones.forEach(part -> { - part.setGlobalRotation(rotation); + part.setGlobalRotation(yaw, pitch); }); } @@ -485,4 +499,4 @@ public Entity getNametag(String name) { if (this.parts.get(name) instanceof ModelBoneNametag nametagBone) return nametagBone.getNametag(); return null; } -} \ No newline at end of file +} From fc7824ea24f5e1d413e9d7c970525e7f1724e0a8 Mon Sep 17 00:00:00 2001 From: Lukadcf <156549307+Lukadcf@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:35:46 +0200 Subject: [PATCH 2/9] Added pitch param to setGlobalRotation --- .../java/net/worldseed/multipart/model_bones/ModelBone.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/worldseed/multipart/model_bones/ModelBone.java b/src/main/java/net/worldseed/multipart/model_bones/ModelBone.java index 18071c53..6e5b8261 100644 --- a/src/main/java/net/worldseed/multipart/model_bones/ModelBone.java +++ b/src/main/java/net/worldseed/multipart/model_bones/ModelBone.java @@ -81,11 +81,11 @@ public interface ModelBone { void detachModel(GenericModel model); - void setGlobalRotation(double rotation); + void setGlobalRotation(double yaw, double pitch); default void teleport(Point position) {} default @NotNull Collection getChildren() { return List.of(); }; -} \ No newline at end of file +} From cdd44992ff2026c1f0850a90449622987ffdb48b Mon Sep 17 00:00:00 2001 From: Lukadcf <156549307+Lukadcf@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:37:06 +0200 Subject: [PATCH 3/9] Same thing --- .../net/worldseed/multipart/GenericModel.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/net/worldseed/multipart/GenericModel.java b/src/main/java/net/worldseed/multipart/GenericModel.java index 41e0dff6..69575996 100644 --- a/src/main/java/net/worldseed/multipart/GenericModel.java +++ b/src/main/java/net/worldseed/multipart/GenericModel.java @@ -36,6 +36,13 @@ public interface GenericModel extends Viewable, EventHandler, Shape */ Point getPivot(); + /** + * Get the rotation of the model on the X axis + * + * @return the pitch + */ + double getPitch(); + /** * Get the rotation of the model on the Y axis * @@ -50,6 +57,14 @@ public interface GenericModel extends Viewable, EventHandler, Shape */ void setGlobalRotation(double rotation); + /** + * Set the rotation of the model on the Y and X axis + * + * @param yaw new global rotation + * @param pitch new pitch + */ + void setGlobalRotation(double yaw, double pitch); + /** * Get the postion offset for drawing the model * @@ -140,6 +155,8 @@ public interface GenericModel extends Viewable, EventHandler, Shape @Nullable BoneEntity generateRoot(); void bindNametag(String name, Entity nametag); + void unbindNametag(String name); + @Nullable Entity getNametag(String name); } From 24b25dcb3586e4d8bca44e0bf28604b00322434e Mon Sep 17 00:00:00 2001 From: Lukadcf <156549307+Lukadcf@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:39:24 +0200 Subject: [PATCH 4/9] Same thing again --- .../net/worldseed/multipart/model_bones/misc/ModelBoneVFX.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneVFX.java b/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneVFX.java index d3d02fe4..9f515d86 100644 --- a/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneVFX.java +++ b/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneVFX.java @@ -40,7 +40,7 @@ public void detachModel(GenericModel model) { } @Override - public void setGlobalRotation(double rotation) { + public void setGlobalRotation(double yaw, double pitch) { } From 1b9114d3ea934e712cd6400e5327f0a5ca10609e Mon Sep 17 00:00:00 2001 From: Lukadcf <156549307+Lukadcf@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:40:06 +0200 Subject: [PATCH 5/9] And again --- .../worldseed/multipart/model_bones/misc/ModelBoneSeat.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneSeat.java b/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneSeat.java index 4e47442d..245b5676 100644 --- a/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneSeat.java +++ b/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneSeat.java @@ -83,7 +83,7 @@ public void detachModel(GenericModel model) { } @Override - public void setGlobalRotation(double rotation) { + public void setGlobalRotation(double yaw, double pitch) { } @@ -159,4 +159,4 @@ public void removePassenger(Entity entity) { public Set getPassengers() { return this.stand.getPassengers(); } -} \ No newline at end of file +} From a2caab872700cd057f04c0e10f8dcd19182aba71 Mon Sep 17 00:00:00 2001 From: Lukadcf <156549307+Lukadcf@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:41:11 +0200 Subject: [PATCH 6/9] Again again again --- .../worldseed/multipart/model_bones/misc/ModelBoneNametag.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneNametag.java b/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneNametag.java index 13bb8a98..e5c51a5b 100644 --- a/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneNametag.java +++ b/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneNametag.java @@ -61,7 +61,7 @@ public void detachModel(GenericModel model) { } @Override - public void setGlobalRotation(double rotation) { + public void setGlobalRotation(double yaw, double pitch) { } @Override From 7450a4149052c322cd6507444b1b7feef9469d1a Mon Sep 17 00:00:00 2001 From: Lukadcf <156549307+Lukadcf@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:41:45 +0200 Subject: [PATCH 7/9] Same thing again again --- .../worldseed/multipart/model_bones/misc/ModelBoneHitbox.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneHitbox.java b/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneHitbox.java index 361590dc..24961ab1 100644 --- a/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneHitbox.java +++ b/src/main/java/net/worldseed/multipart/model_bones/misc/ModelBoneHitbox.java @@ -131,7 +131,7 @@ public void detachModel(GenericModel model) { } @Override - public void setGlobalRotation(double rotation) { + public void setGlobalRotation(double yaw, double pitch) { } public void generateStands(JsonArray cubes, Point pivotPos, String name, Point boneRotation, GenericModel genericModel) { From 1e0bc1bec317e70dfb7c40bf3fd33f6ccf11531c Mon Sep 17 00:00:00 2001 From: Lukadcf <156549307+Lukadcf@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:42:26 +0200 Subject: [PATCH 8/9] Same thing again again again --- src/main/java/net/worldseed/gestures/ModelBoneEmote.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/worldseed/gestures/ModelBoneEmote.java b/src/main/java/net/worldseed/gestures/ModelBoneEmote.java index c5d199fa..26b38865 100644 --- a/src/main/java/net/worldseed/gestures/ModelBoneEmote.java +++ b/src/main/java/net/worldseed/gestures/ModelBoneEmote.java @@ -50,7 +50,7 @@ public ModelBoneEmote(Point pivot, String name, Point rotation, GenericModel mod }); } - switch(this.name) { + switch (this.name) { case "Head" -> { this.diff = this.pivot.add(0, 0, 0); } @@ -207,6 +207,6 @@ public void detachModel(GenericModel model) { } @Override - public void setGlobalRotation(double rotation) { + public void setGlobalRotation(double yaw, double pitch) { } } From b70455ce650bc062f538e662ed9ada81a8b10d9e Mon Sep 17 00:00:00 2001 From: Lukadcf <156549307+Lukadcf@users.noreply.github.com> Date: Tue, 22 Oct 2024 22:47:07 +0200 Subject: [PATCH 9/9] Added pitch param to setGlobalRotation and... Put the yaw and pitch from params into the stand.setView so people can rotate singular bones if they want. (It used this.getGlobalRotation before) Also normalized the pitch but without +180 because it would reverse from how pitch normally works. --- .../model_bones/display_entity/ModelBonePartDisplay.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/worldseed/multipart/model_bones/display_entity/ModelBonePartDisplay.java b/src/main/java/net/worldseed/multipart/model_bones/display_entity/ModelBonePartDisplay.java index a637d9b3..43952e64 100644 --- a/src/main/java/net/worldseed/multipart/model_bones/display_entity/ModelBonePartDisplay.java +++ b/src/main/java/net/worldseed/multipart/model_bones/display_entity/ModelBonePartDisplay.java @@ -137,10 +137,11 @@ public void detachModel(GenericModel model) { } @Override - public void setGlobalRotation(double rotation) { + public void setGlobalRotation(double yaw, double pitch) { if (this.stand != null) { - var correctLocation = (180 + this.model.getGlobalRotation() + 360) % 360; - this.stand.setView((float) correctLocation, 0); + var correctYaw = (180 + yaw + 360) % 360; + var correctPitch = (pitch + 360) % 360; + this.stand.setView((float) correctYaw, (float) correctPitch); } } @@ -249,4 +250,4 @@ public void setState(String state) { public Point getPosition() { return calculatePositionInternal().add(model.getPosition()); } -} \ No newline at end of file +}