Skip to content

Commit

Permalink
Merge pull request #75 from namreeb/fixed_wmo_rotation
Browse files Browse the repository at this point in the history
Fixed wmo rotation
  • Loading branch information
namreeb authored Jul 26, 2024
2 parents c494bbc + 2d279e5 commit fc04d2a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions MapViewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,11 @@ LRESULT CALLBACK GuiWindowProc(HWND hWnd, UINT message, WPARAM wParam,
if (gNavMesh->FindPath(gStart, hit, path, false))
gRenderer->AddPath(path);
else
{
MessageBox(nullptr, "FindPath failed", "Path Find",
0);
return TRUE;
}

auto const& prev_hop = path[path.size() - 2];
float height;
Expand Down
11 changes: 8 additions & 3 deletions parser/Wmo/WmoPlacement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,28 @@ struct WmoPlacement
{
auto constexpr mid = 32.f * MeshSettings::AdtSize;

// rotation around x (north/south)
auto const rotX = math::Convert::ToRadians(Orientation.Z);

// rotation around y (east/west)
auto const rotY = math::Convert::ToRadians(Orientation.X);

// rotation around z (vertical)
auto const rotZ = math::Convert::ToRadians(Orientation.Y + 180.f);

// 0xFFFFFFFF is the unique id used for a global WMO (a map which has no
// ADTs but instead spawns a single WMO)
auto const translationMatrix =
const math::Matrix translationMatrix =
UniqueId == 0xFFFFFFFF ?
math::Matrix::CreateTranslationMatrix(
{BasePosition.Z, BasePosition.X, BasePosition.Y}) :
math::Matrix::CreateTranslationMatrix({mid - BasePosition.Z,
mid - BasePosition.X,
BasePosition.Y});

matrix = translationMatrix * math::Matrix::CreateRotationX(rotX) *
matrix = translationMatrix * math::Matrix::CreateRotationZ(rotZ) *
math::Matrix::CreateRotationY(rotY) *
math::Matrix::CreateRotationZ(rotZ);
math::Matrix::CreateRotationX(rotX);
}
};
#pragma pack(pop)
Expand Down

0 comments on commit fc04d2a

Please sign in to comment.