1
0
mirror of https://github.com/GeyserMC/Rainbow.git synced 2025-12-19 14:59:16 +00:00

Some 3D model mapping fixes

This commit is contained in:
Eclipse
2025-07-28 13:03:03 +00:00
parent 219bda16e4
commit 7a0c58828f

View File

@@ -19,9 +19,9 @@ public class GeometryMapper {
public static BedrockGeometryContext mapGeometry(String identifier, String boneName, ResolvedModel model, ResourceLocation texture) { public static BedrockGeometryContext mapGeometry(String identifier, String boneName, ResolvedModel model, ResourceLocation texture) {
BedrockGeometry.Builder builder = BedrockGeometry.builder(identifier); BedrockGeometry.Builder builder = BedrockGeometry.builder(identifier);
// Blockbench seems to always use these values // Blockbench seems to always use these values TODO that's wrong
builder.withVisibleBoundsWidth(2.0F); builder.withVisibleBoundsWidth(4.0F);
builder.withVisibleBoundsHeight(2.5F); builder.withVisibleBoundsHeight(4.0F);
builder.withVisibleBoundsOffset(new Vector3f(0.0F, 0.75F, 0.0F)); builder.withVisibleBoundsOffset(new Vector3f(0.0F, 0.75F, 0.0F));
// TODO proper texture size // TODO proper texture size
@@ -35,6 +35,7 @@ public class GeometryMapper {
SimpleUnbakedGeometry geometry = (SimpleUnbakedGeometry) model.getTopGeometry(); SimpleUnbakedGeometry geometry = (SimpleUnbakedGeometry) model.getTopGeometry();
for (BlockElement element : geometry.elements()) { for (BlockElement element : geometry.elements()) {
// TODO the origin here is wrong, some models seem to be mirrored weirdly in blockbench
BedrockGeometry.Cube cube = mapBlockElement(element).build(); BedrockGeometry.Cube cube = mapBlockElement(element).build();
bone.withCube(cube); bone.withCube(cube);
min.min(cube.origin()); min.min(cube.origin());
@@ -81,7 +82,8 @@ public class GeometryMapper {
BlockElementRotation rotation = element.rotation(); BlockElementRotation rotation = element.rotation();
if (rotation != null) { if (rotation != null) {
builder.withPivot(rotation.origin().sub(CENTRE_OFFSET, new Vector3f())); // MC multiplies model origin by 0.0625 when loading rotation origin
builder.withPivot(rotation.origin().div(0.0625F, new Vector3f()).sub(CENTRE_OFFSET));
Vector3f bedrockRotation = switch (rotation.axis()) { Vector3f bedrockRotation = switch (rotation.axis()) {
case X -> new Vector3f(rotation.angle(), 0.0F, 0.0F); case X -> new Vector3f(rotation.angle(), 0.0F, 0.0F);