Skip to content

Commit 0805637

Browse files
committed
scaling fix
1 parent 2d035ee commit 0805637

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

DenizenModelsConverter/MinecraftModelMaker.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public static string CreateModelFor(BBModel model, BBModel.Outliner outline)
3535
any = true;
3636
JObject jElement = new();
3737
jElement.Add("name", element.Name);
38-
jElement.Add("from", DVecToArray(element.From - outline.Origin));
39-
jElement.Add("to", DVecToArray(element.To - outline.Origin));
38+
jElement.Add("from", DVecToArray((element.From - outline.Origin) * SCALE_FACTOR));
39+
jElement.Add("to", DVecToArray((element.To - outline.Origin) * SCALE_FACTOR));
4040
JObject rotation = new();
41-
rotation.Add("origin", DVecToArray(element.Origin - outline.Origin));
41+
rotation.Add("origin", DVecToArray((element.Origin - outline.Origin) * SCALE_FACTOR));
4242
if (element.Rotation.X != 0)
4343
{
4444
rotation.Add("angle", element.Rotation.X);
@@ -72,12 +72,12 @@ public static string CreateModelFor(BBModel model, BBModel.Outliner outline)
7272
return null;
7373
}
7474
group.Add("name", outline.Name);
75-
group.Add("origin", DVecToArray(outline.Origin));
75+
group.Add("origin", DVecToArray(outline.Origin * SCALE_FACTOR));
7676
group.Add("color", 0);
7777
group.Add("children", childrenList);
7878
groups.Add(group);
79-
head.Add("translation", new JArray(8 * Program.SCALE, 3.75 * Program.SCALE, 8 * Program.SCALE));
80-
head.Add("scale", new JArray(Program.SCALE, Program.SCALE, Program.SCALE));
79+
head.Add("translation", new JArray(32, 25, 32));
80+
head.Add("scale", new JArray(4, 4, 4));
8181
display.Add("head", head);
8282
jout.Add("textures", textures);
8383
jout.Add("elements", elements);
@@ -86,6 +86,9 @@ public static string CreateModelFor(BBModel model, BBModel.Outliner outline)
8686
return jout.ToString();
8787
}
8888

89+
/// <summary>2.285 is the scale to be 'normal' size (16 BlockBench pixels = 1 minecraft block), but 4.0 is the scale objects are applied at, so this factor corrects for that.</summary>
90+
public const double SCALE_FACTOR = 2.285 / 4.0;
91+
8992
public static JObject FaceToJObj(BBModel.Element.Face face, BBModel model)
9093
{
9194
float relativeU = 16f / model.ResolutionX;

DenizenModelsConverter/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ public static class Program
1313
{
1414
public static AsciiMatcher PATH_CHARS = new(AsciiMatcher.LowercaseLetters + AsciiMatcher.Digits + "_/");
1515

16-
public const double SCALE = 1.5f;
17-
1816
public static bool Verbose = false;
1917

2018
public static void Debug(string text)

scripts/dmodels.dsc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,9 @@ dmodels_spawn_model:
125125
- define parentage.<[id]>.offset <[rot_offset].add[<[parent_offset]>]>
126126
- if !<[part.item].exists>:
127127
- foreach next
128-
# Idk wtf is with the .div[...] scale below. It's somewhere in the range of 25 to 26. 25.45 seems closest in one of my tests,
129-
# but I think that's minecraft packet location imprecision at fault so it's possibly just 26?
130-
# Supposedly it's 25.6 according to external docs (16 * 1.6), but that also is wrong in my testing.
131-
# 24.5 is closest in my testing thus far.
132-
- spawn dmodel_part_stand[equipment=[helmet=<[part.item]>];armor_pose=[head=<[new_rot].xyz>]] <[center].add[<[new_pos].div[24.5].rotate_around_y[<[yaw_mod].mul[-1]>]>]> save:spawned
128+
- spawn dmodel_part_stand[equipment=[helmet=<[part.item]>];armor_pose=[head=<[new_rot].xyz>]] <[center].add[<[new_pos].div[16].rotate_around_y[<[yaw_mod].mul[-1]>]>]> save:spawned
133129
- flag <entry[spawned].spawned_entity> dmodel_def_pose:<[new_rot].xyz>
134-
- flag <entry[spawned].spawned_entity> dmodel_def_offset:<[new_pos].div[24.5]>
130+
- flag <entry[spawned].spawned_entity> dmodel_def_offset:<[new_pos].div[16]>
135131
- flag <entry[spawned].spawned_entity> dmodel_root:<entry[root].spawned_entity>
136132
- flag <entry[root].spawned_entity> dmodel_parts:->:<entry[spawned].spawned_entity>
137133
- flag <entry[root].spawned_entity> dmodel_anim_part.<[id]>:->:<entry[spawned].spawned_entity>
@@ -257,8 +253,7 @@ dmodels_move_to_frame:
257253
- define parentage.<[part_id]>.rotation <[new_rot]>
258254
- define parentage.<[part_id]>.offset <[rot_offset].add[<[parent_offset]>]>
259255
- foreach <[root_entity].flag[dmodel_anim_part.<[part_id]>]||<list>> as:ent:
260-
# Note: 24.5 is the offset multiplifer explained in the comments of dmodels_spawn_model
261-
- teleport <[ent]> <[center].add[<[new_pos].div[24.5].rotate_around_y[<[yaw_mod].mul[-1]>]>]>
256+
- teleport <[ent]> <[center].add[<[new_pos].div[16].rotate_around_y[<[yaw_mod].mul[-1]>]>]>
262257
- define radian_rot <[new_rot].add[<[pose]>].xyz.split[,]>
263258
- define pose <[radian_rot].get[1]>,<[radian_rot].get[2]>,<[radian_rot].get[3]>
264259
- adjust <[ent]> armor_pose:[head=<[pose]>]

0 commit comments

Comments
 (0)