Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Commit

Permalink
fix fsb rotation (pretty much)
Browse files Browse the repository at this point in the history
  • Loading branch information
supsm committed Jun 21, 2022
1 parent 85e9753 commit 965e8af
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ To access build artifacts, head to the [compile](https://github.com/supsm/MCPPPP
`MCPPPP-windows.exe`, `MCPPPP-mac.tar.gz`, and `MCPPPP-linux` will contain a gui.
`MCPPPP-windows-cli`, `MCPPPP-mac-cli.tar.gz`, and `MCPPPP-linux-cli` do not contain a gui. There is additional information below (Section **CLI**)

If a folder already contains the output directories (such as `assets/fabricskyboxes`), it will be skipped. If you want to re-convert this pack, delete the directory. MCPPPP will try to be as least invasive as possible, and will only modify these folders.
If a folder already contains the output directories (such as `assets/fabricskyboxes`), it will be skipped. If you want to re-convert this pack, delete the directory. MCPPPP will try to be as least invasive as possible, and will only modify these folders (as well as `pack.mcmeta`, which there will be a backup of).
More detailed instructions below
<details>
<summary>Output Directories</summary>
Expand Down
40 changes: 36 additions & 4 deletions src/fsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,16 @@ namespace fsb
state.info_raw.colortype = LCT_RGBA;
state.info_raw.bitdepth = 8;
source = name;
bool reverse_speed = false;

nlohmann::json j =
{
{"schemaVersion", 2},
{"type", "square-textured"},
{"conditions",
{
{"worlds", {(overworldsky ? "minecraft:overworld" : "minecraft:the_end")}}
{"worlds", {(overworldsky ? "minecraft:overworld" : "minecraft:the_end")}},
{"weather", {"clear"}}
} },
{"blend", {{"type", "add"}}},
{"decorations",
Expand All @@ -168,9 +171,9 @@ namespace fsb
{
{"rotation",
{
{"axis", {0.0, -180.0, 0.0}},
{"axis", {90.0, 0.0, 0.0}}, // fsb uses {z, y, x} (kinda, see more explaination in `else if (option == "axis")`)
{"static", {0.0, 0.0, 0.0}},
{"rotationSpeed", -1.0} // TODO: find a rotation speed
{"rotationSpeed", 1.0}
}}
} }
};
Expand Down Expand Up @@ -242,7 +245,28 @@ namespace fsb
axis >> x >> y >> z;
try
{
j["properties"]["rotation"]["axis"] = { stod(x) * 180, stod(y) * 180, stod(z) * 180 };
// fsb rotation is... kinda weird
// first number is z axis, 90 = +z cw, -90 = -z cw
// second number is y axis, 90 and -90 are both +y cw
// third number is x axis, 90 = +x ccw, -90 = -x ccw (or 90 = -x cw, -90 = +x cw)
double x_rotation = stod(x) * 90;
double y_rotation = stod(y) * 90;
double z_rotation = stod(z) * 90;

// flip everything if y axis rotation is negative
if (y_rotation < 0)
{
x_rotation = -x_rotation;
z_rotation = -z_rotation;
reverse_speed = true;
}
else
{
reverse_speed = false;
}

// reverse x axis rotation
j["properties"]["rotation"]["axis"] = { z_rotation, y_rotation, -x_rotation };
}
catch (const std::invalid_argument& e)
{
Expand Down Expand Up @@ -309,9 +333,17 @@ namespace fsb
}
else if (startfadeout == -1)
{
// fill in missing startfadeout
j["properties"]["fade"]["startFadeOut"] = (endfadeout - endfadein + startfadein + 24000) % 24000;
}

// reverse rotation direction if necessary
if (reverse_speed)
{
j["properties"]["rotation"]["rotationSpeed"] = -j["properties"]["rotation"]["rotationSpeed"].get<double>();
}


if (source.starts_with(u8"./"))
{
source.erase(source.begin(), source.begin() + 2);
Expand Down

0 comments on commit 965e8af

Please sign in to comment.