Skip to content

Commit b2fbd02

Browse files
committed
fix a few weird angle inversions
1 parent b902e5b commit b2fbd02

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

DenizenModelsConverter/PackMaker.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,16 @@ public static void BuildPack(string rawModelPath, BBModel model, string item, st
133133
foreach (BBModel.Animation.Keyframe frame in animator.Keyframes)
134134
{
135135
JObject jFrame = new();
136+
if (frame.Channel == BBModel.Animation.Keyframe.ChannelType.POSITION)
137+
{
138+
// BlockBench inverts the X of animated positions for some reason???
139+
jFrame.Add("data", $"{-frame.DataPoint.X},{frame.DataPoint.Y},{frame.DataPoint.Z}");
140+
}
141+
else
142+
{
143+
jFrame.Add("data", $"{frame.DataPoint.X * PI180},{frame.DataPoint.Y * PI180},{frame.DataPoint.Z * PI180}");
144+
}
136145
jFrame.Add("channel", frame.Channel.ToString());
137-
jFrame.Add("data", frame.DataPoint.ToDenizenString());
138146
jFrame.Add("time", frame.Time);
139147
jFrame.Add("interpolation", frame.Interpolation.ToString());
140148
keyframes.Add(jFrame);
@@ -160,6 +168,8 @@ public static void BuildPack(string rawModelPath, BBModel model, string item, st
160168
Console.WriteLine("Exported full bbmodel.");
161169
}
162170

171+
public const double PI180 = Math.PI / 180.0;
172+
163173
public static void BuildPartsOrder(BBModel model, Guid? id, JArray output)
164174
{
165175
List<BBModel.Outliner> partsToAdd = new();

scripts/dmodels.dsc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ dmodels_spawn_model:
4444
- if !<server.has_flag[dmodels_data.model_<[model_name]>]>:
4545
- debug error "[DModels] cannot spawn model <[model_name]>, model not loaded"
4646
- stop
47-
- define location <[location].center>
47+
- define location <[location].center.with_yaw[180]>
4848
- spawn dmodel_part_stand <[location]> save:root
4949
- flag <entry[root].spawned_entity> dmodel_model_id:<[model_name]>
5050
- foreach <server.flag[dmodels_data.model_<[model_name]>]> key:id as:part:
@@ -53,9 +53,9 @@ dmodels_spawn_model:
5353
# 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,
5454
# but I think that's minecraft packet location imprecision at fault so it's possibly just 26?
5555
# Supposedly it's 25.6 according to external docs (16 * 1.6), but that also is wrong in my testing.
56-
- define offset <location[<[part.origin]>].div[25.6].rotate_around_y[<util.pi>]>
56+
- define offset <location[<[part.origin]>].div[25.6]>
5757
- define rots <[part.rotation].split[,].parse[to_radians]>
58-
- define pose <[rots].get[1].mul[-1]>,<[rots].get[2].mul[-1]>,<[rots].get[3]>
58+
- define pose <[rots].get[1].mul[-1]>,<[rots].get[2]>,<[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]>
6161
- flag <entry[spawned].spawned_entity> dmodel_def_offset:<[offset]>
@@ -151,7 +151,7 @@ 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 rel_offset <location[<[this_part.origin]>].rotate_around_y[<util.pi>].sub[<[parent_offset]>]>
154+
- define rel_offset <location[<[this_part.origin]>].sub[<[parent_offset]>]>
155155
- define rot_offset <[rel_offset].proc[dmodels_rot_proc].context[<[parent_rot]>]>
156156
- define pos_shift <[rot_offset].sub[<[rel_offset]>]>
157157
- define new_pos <[framedata.position].as_location.proc[dmodels_rot_proc].context[<[parent_rot]>].add[<[pos_shift]>].add[<[parent_pos]>]>
@@ -163,16 +163,16 @@ dmodels_move_to_frame:
163163
- 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]>"
164164
- foreach <[root_entity].flag[dmodel_anim_part.<[part_id]>]||<list>> as:ent:
165165
- teleport <[ent]> <[root_entity].location.add[<[ent].flag[dmodel_def_offset].add[<[new_pos].div[25.6]>]>]>
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]>
166+
- define radian_rot <[new_rot].xyz.split[,]>
167+
- define pose <[radian_rot].get[1].mul[-1]>,<[radian_rot].get[2]>,<[radian_rot].get[3]>
168168
- adjust <[ent]> armor_pose:[head=<[ent].flag[dmodel_def_pose].as_location.add[<[pose]>].xyz>]
169169

170170
dmodels_rot_proc:
171171
type: procedure
172172
debug: false
173173
definitions: loc|rot
174174
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>]>
175+
- determine <[loc].rotate_around_x[<[rot].x>].rotate_around_y[<[rot].y.mul[-1]>].rotate_around_z[<[rot].z>]>
176176

177177
dmodels_catmullrom_get_t:
178178
type: procedure

0 commit comments

Comments
 (0)