Skip to content

Commit

Permalink
Fix confetti rotations being fucked
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor4t committed Nov 21, 2024
1 parent 9f495ba commit 9cd39c5
Showing 1 changed file with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float ti

for (int k = 0; k < 4; ++k) {
Vector3f Vec3f2 = Vec3fs[k];
Vec3f2.rotate(new Quaternionf(rotationX, rotationY, rotationZ, 1));
Vec3f2.rotate(eulerToQuaternion(rotationX, rotationY, rotationZ));
Vec3f2.normalize(siZe);
Vec3f2.add(x, y, z);
}
Expand All @@ -87,7 +87,7 @@ public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float ti

for (int k = 0; k < 4; ++k) {
Vector3f Vec3f2 = Vec3fs[k];
Vec3f2.rotate(new Quaternionf(rotationX, rotationY, rotationZ, 1));
Vec3f2.rotate(eulerToQuaternion(rotationX, rotationY, rotationZ));
Vec3f2.normalize(siZe);
Vec3f2.add(x, y + this.groundOffset, z);
}
Expand All @@ -109,6 +109,25 @@ public void buildGeometry(VertexConsumer vertexConsumer, Camera camera, float ti
vertexConsumer.vertex(Vec3fs[1].x(), Vec3fs[1].y(), Vec3fs[1].z()).texture(minU, maxV).color(red, green, blue, alpha).light(light);
}

public Quaternionf eulerToQuaternion(float x, float y, float z) {
x *= ((float) Math.PI / 180F);
y *= ((float) Math.PI / 180F);
z *= ((float) Math.PI / 180F);

float f = MathHelper.sin(0.5F * x);
float g = MathHelper.cos(0.5F * x);
float h = MathHelper.sin(0.5F * y);
float i = MathHelper.cos(0.5F * y);
float j = MathHelper.sin(0.5F * z);
float k = MathHelper.cos(0.5F * z);
x = f * i * k + g * h * j;
y = g * h * k - f * i * j;
z = f * h * k + g * i * j;
float w = g * i * k - f * h * j;

return new Quaternionf(x, y, z, w);
}

@Override
public void tick() {
this.prevPosX = this.x;
Expand Down

0 comments on commit 9cd39c5

Please sign in to comment.