Skip to content

Commit b902e5b

Browse files
committed
one of the anim tests works now
1 parent cc8e68c commit b902e5b

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

scripts/dmodels.dsc

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ dmodels_spawn_model:
5050
- foreach <server.flag[dmodels_data.model_<[model_name]>]> key:id as:part:
5151
- if !<[part.item].exists>:
5252
- foreach next
53-
- define rots <[part.rotation].split[,].parse[to_radians]>
5453
# 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,
5554
# but I think that's minecraft packet location imprecision at fault so it's possibly just 26?
5655
# Supposedly it's 25.6 according to external docs (16 * 1.6), but that also is wrong in my testing.
5756
- define offset <location[<[part.origin]>].div[25.6].rotate_around_y[<util.pi>]>
57+
- define rots <[part.rotation].split[,].parse[to_radians]>
5858
- define pose <[rots].get[1].mul[-1]>,<[rots].get[2].mul[-1]>,<[rots].get[3]>
5959
- spawn dmodel_part_stand[equipment=[helmet=<[part.item]>];armor_pose=[head=<[pose]>]] <[location].add[<[offset]>]> save:spawned
6060
- flag <entry[spawned].spawned_entity> dmodel_def_pose:<[pose]>
@@ -151,19 +151,28 @@ dmodels_move_to_frame:
151151
- define parent_pos <location[<[parentage.<[parent_id]>.position]||0,0,0>]>
152152
- define parent_rot <location[<[parentage.<[parent_id]>.rotation]||0,0,0>]>
153153
- define parent_offset <location[<[parentage.<[parent_id]>.offset]||0,0,0>]>
154-
#- define parent_part <[model_data.<[parent_id]>]||<map>>
155-
- define rel_offset <location[<[this_part.origin]>].sub[<[parent_offset]>]>
156-
- define rot_offset <[rel_offset].rotate_around_x[<[parent_rot].x.to_radians>].rotate_around_y[<[parent_rot].y.to_radians>].rotate_around_z[<[parent_rot].z.to_radians>]>
154+
- define rel_offset <location[<[this_part.origin]>].rotate_around_y[<util.pi>].sub[<[parent_offset]>]>
155+
- define rot_offset <[rel_offset].proc[dmodels_rot_proc].context[<[parent_rot]>]>
157156
- define pos_shift <[rot_offset].sub[<[rel_offset]>]>
158-
- define new_pos <[framedata.position].as_location.add[<[pos_shift]>].add[<[parent_pos]>]>
157+
- define new_pos <[framedata.position].as_location.proc[dmodels_rot_proc].context[<[parent_rot]>].add[<[pos_shift]>].add[<[parent_pos]>]>
159158
- define new_rot <[framedata.rotation].as_location.add[<[parent_rot]>]>
160159
- define parentage.<[part_id]>.position:<[new_pos]>
161160
- define parentage.<[part_id]>.rotation:<[new_rot]>
162-
- define parentage.<[part_id]>.offset:<[rot_offset]>
161+
- define parentage.<[part_id]>.offset:<[rot_offset].add[<[parent_offset]>]>
162+
- if <[part_id].starts_with[823a7148]>:
163+
- debug log "[DB] rel <[rel_offset].round_to[2]> rot <[rot_offset].round_to[2]> par <[parent_offset].round_to[2]> fram <[framedata.position].as_location.round_to[2]> shift <[pos_shift].round_to[2]>"
163164
- foreach <[root_entity].flag[dmodel_anim_part.<[part_id]>]||<list>> as:ent:
164165
- teleport <[ent]> <[root_entity].location.add[<[ent].flag[dmodel_def_offset].add[<[new_pos].div[25.6]>]>]>
165-
- define radian_rot <[new_rot].xyz.split[,].parse[to_radians].separated_by[,]>
166-
- adjust <[ent]> armor_pose:[head=<[ent].flag[dmodel_def_pose].as_location.add[<[radian_rot]>].xyz>]
166+
- define radian_rot <[new_rot].xyz.split[,].parse[to_radians]>
167+
- define pose <[radian_rot].get[1].mul[-1]>,<[radian_rot].get[2].mul[-1]>,<[radian_rot].get[3]>
168+
- adjust <[ent]> armor_pose:[head=<[ent].flag[dmodel_def_pose].as_location.add[<[pose]>].xyz>]
169+
170+
dmodels_rot_proc:
171+
type: procedure
172+
debug: false
173+
definitions: loc|rot
174+
script:
175+
- determine <[loc].rotate_around_x[<[rot].x.to_radians>].rotate_around_y[<[rot].y.to_radians>].rotate_around_z[<[rot].z.to_radians>]>
167176

168177
dmodels_catmullrom_get_t:
169178
type: procedure

0 commit comments

Comments
 (0)