Skip to content

Commit c7968fa

Browse files
committed
process initial outliner rotations
duplicate code hurts but cleanup later i guess ow
1 parent 6d85fbd commit c7968fa

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

DenizenModelsConverter/BBModelReader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ public static BBModel.Outliner ReadOutliner(BBModel model, JObject jOutliner, Di
263263
UUID = Guid.Parse((string)jOutliner.GetRequired("uuid")),
264264
// Ignore ik_enabled, ik_chain_length, export, isOpen, locked, visibility, autouv
265265
};
266+
if (jOutliner.ContainsKey("rotation"))
267+
{
268+
outline.Rotation = ParseDVecFromArr(jOutliner.GetRequired("rotation"));
269+
}
266270
foreach (JToken child in (JArray)jOutliner.GetRequired("children"))
267271
{
268272
AddOutlineChild(model, outline, child, names);

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This takes the form of two components:
1010
- External program, written in C#
1111
- Needs to be compiled via Visual Studio 2022
1212
- Only tested on Windows 11 currently, but theoretically works anywhere
13+
- Requires .NET 6 to run
1314
- takes the `.bbmodel` file and converts it into two output files
1415
- A resource pack for clients
1516
- A `.dmodel.yml` file for the Minecraft server to read

scripts/dmodels.dsc

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# 1: Create a model using blockbench - https://www.blockbench.net/
2424
# 1.1 Create as a 'Generic Model'
2525
# 1.2 Make basically anything you want
26-
# 1.3 Note that each block cannot have a coordinate value beyond 32 (Minecraft limitation)
26+
# 1.3 Note that each block cannot have a coordinate value beyond +/-16 (Minecraft limitation)
2727
# 1.4 Make sure pivot points are as correct as possible to minimize glitchiness from animations
2828
# (for example, if you have a bone pivot point in the center of a block, but the block's own pivot point is left at default 0,0,0, this can lead to the armor stand having to move and rotate at the same time, and lose sync when doing so)
2929
# 1.5 Animate freely, make sure the animation names are clear
@@ -106,19 +106,32 @@ dmodels_spawn_model:
106106
- define yaw_mod <[location].yaw.add[180].to_radians>
107107
- spawn dmodel_part_stand <[location]> save:root
108108
- flag <entry[root].spawned_entity> dmodel_model_id:<[model_name]>
109-
- foreach <server.flag[dmodels_data.model_<[model_name]>]> key:id as:part:
109+
- define parentage <map>
110+
- define model_data <server.flag[dmodels_data.model_<[model_name]>]>
111+
- foreach <[model_data]> key:id as:part:
112+
- define rots <[part.rotation].split[,].parse[to_radians]>
113+
- define pose <[rots].get[1].mul[-1]>,<[rots].get[2].mul[-1]>,<[rots].get[3]>
114+
- define parent_id <[part.parent]>
115+
- define parent_pos <location[<[parentage.<[parent_id]>.position]||0,0,0>]>
116+
- define parent_rot <location[<[parentage.<[parent_id]>.rotation]||0,0,0>]>
117+
- define parent_offset <location[<[parentage.<[parent_id]>.offset]||0,0,0>]>
118+
- define parent_raw_offset <[model_data.<[parent_id]>.origin]||0,0,0>
119+
- define rel_offset <location[<[part.origin]>].sub[<[parent_raw_offset]>]>
120+
- define rot_offset <[rel_offset].proc[dmodels_rot_proc].context[<[parent_rot]>]>
121+
- define new_pos <[rot_offset].as_location.add[<[parent_pos]>]>
122+
- define new_rot <[parent_rot].add[<[pose]>]>
123+
- define parentage.<[id]>.position <[new_pos]>
124+
- define parentage.<[id]>.rotation <[new_rot]>
125+
- define parentage.<[id]>.offset <[rot_offset].add[<[parent_offset]>]>
110126
- if !<[part.item].exists>:
111127
- foreach next
112-
# Idk wtf is with the scale here. It's somewhere in the range of 25 to 26. 25.45 seems closest in one of my tests,
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,
113129
# but I think that's minecraft packet location imprecision at fault so it's possibly just 26?
114130
# Supposedly it's 25.6 according to external docs (16 * 1.6), but that also is wrong in my testing.
115131
# 24.5 is closest in my testing thus far.
116-
- define offset <location[<[part.origin]>].div[24.5]>
117-
- define rots <[part.rotation].split[,].parse[to_radians]>
118-
- define pose <[rots].get[1].mul[-1]>,<[rots].get[2].mul[-1]>,<[rots].get[3]>
119-
- spawn dmodel_part_stand[equipment=[helmet=<[part.item]>];armor_pose=[head=<[pose]>]] <[center].add[<[offset].rotate_around_y[<[yaw_mod].mul[-1]>]>]> save:spawned
120-
- flag <entry[spawned].spawned_entity> dmodel_def_pose:<[pose]>
121-
- flag <entry[spawned].spawned_entity> dmodel_def_offset:<[offset]>
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
133+
- 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]>
122135
- flag <entry[spawned].spawned_entity> dmodel_root:<entry[root].spawned_entity>
123136
- flag <entry[root].spawned_entity> dmodel_parts:->:<entry[spawned].spawned_entity>
124137
- flag <entry[root].spawned_entity> dmodel_anim_part.<[id]>:->:<entry[spawned].spawned_entity>
@@ -240,9 +253,9 @@ dmodels_move_to_frame:
240253
- define rot_offset <[rel_offset].proc[dmodels_rot_proc].context[<[parent_rot]>]>
241254
- define new_pos <[framedata.position].as_location.proc[dmodels_rot_proc].context[<[parent_rot]>].add[<[rot_offset]>].add[<[parent_pos]>]>
242255
- define new_rot <[framedata.rotation].as_location.add[<[parent_rot]>]>
243-
- define parentage.<[part_id]>.position:<[new_pos]>
244-
- define parentage.<[part_id]>.rotation:<[new_rot]>
245-
- define parentage.<[part_id]>.offset:<[rot_offset].add[<[parent_offset]>]>
256+
- define parentage.<[part_id]>.position <[new_pos]>
257+
- define parentage.<[part_id]>.rotation <[new_rot]>
258+
- define parentage.<[part_id]>.offset <[rot_offset].add[<[parent_offset]>]>
246259
- foreach <[root_entity].flag[dmodel_anim_part.<[part_id]>]||<list>> as:ent:
247260
# Note: 24.5 is the offset multiplifer explained in the comments of dmodels_spawn_model
248261
- teleport <[ent]> <[center].add[<[new_pos].div[24.5].rotate_around_y[<[yaw_mod].mul[-1]>]>]>

0 commit comments

Comments
 (0)