Skip to content

Commit

Permalink
[PlayerBox] Now handling player rotation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jun 4, 2020
1 parent 9f01a53 commit 589118e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ This list is non exhaustive.
- Custom GUI creation
- Special blocks (workbench, furnace)
- Block metadata
- Player model display (currently without rotation nor animation)
- Player model display (without animation)
- Dimensions (like the Nether or the Ender in Minecraft) ([#80](https://github.com/Unarelith/OpenMiner/pull/80))
- World loading/saving (using `/save <name>` and `/load <name>` commands, see [#26](https://github.com/Unarelith/OpenMiner/issues/26))
- Texture pack system (partially implemented, see [#34](https://github.com/Unarelith/OpenMiner/issues/34))
Expand Down
1 change: 1 addition & 0 deletions source/client/graphics/PlayerBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ void PlayerBox::draw(gk::RenderTarget &target, gk::RenderStates states) const {
// Subtract the camera position - see comment in ClientWorld::draw()
gk::Vector3d cameraPosition = m_camera.getDPosition();
states.transform.translate(m_x - cameraPosition.x, m_y - cameraPosition.y, m_z - cameraPosition.z);
states.transform.rotate(m_viewAngleH, gk::Vector3{0, 0, 1});

states.transform *= getTransform();
states.texture = &m_texture;
Expand Down
13 changes: 13 additions & 0 deletions source/client/network/ClientCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,19 @@ void ClientCommandHandler::setupCallbacks() {
}
});

m_client.setCommandCallback(Network::Command::PlayerRotUpdate, [this](Network::Packet &packet) {
float yaw, pitch;
u16 clientId;
packet >> clientId;
packet >> yaw >> pitch;

if (clientId != m_client.id()) {
auto it = m_playerBoxes.find(clientId);
if (it != m_playerBoxes.end())
it->second.Player::setRotation(yaw, pitch);
}
});

m_client.setCommandCallback(Network::Command::PlayerSpawn, [this](Network::Packet &packet) {
u16 clientId;
gk::Vector3d pos;
Expand Down

0 comments on commit 589118e

Please sign in to comment.