CLIENT: add orientation to npc spawn

master
Martin Gerhardy 2016-08-05 20:30:33 +02:00
parent a44fb68851
commit 91f677f049
5 changed files with 8 additions and 7 deletions

2
.gitignore vendored
View File

@ -1,4 +1,6 @@
*.pyc
/build
/.project
/.cproject
/.settings
/Makefile.local

View File

@ -69,7 +69,6 @@ void Client::onMouseMotion(int32_t x, int32_t y, int32_t relX, int32_t relY) {
void Client::onEvent(const network::DisconnectEvent& event) {
removeState(CLIENT_CONNECTING);
core_assert(!hasState(CLIENT_CONNECTING));
ui::Window* main = new frontend::LoginWindow(this);
new frontend::DisconnectWindow(main);
}
@ -295,10 +294,10 @@ void Client::entityUpdate(frontend::ClientEntityId id, const glm::vec3& pos, flo
entity->lerpPosition(pos, orientation);
}
void Client::npcSpawn(frontend::ClientEntityId id, network::messages::NpcType type, const glm::vec3& pos) {
void Client::npcSpawn(frontend::ClientEntityId id, network::messages::NpcType type, float orientation, const glm::vec3& pos) {
Log::info("NPC %li spawned at pos %f:%f:%f (type %i)", id, pos.x, pos.y, pos.z, type);
const std::string& meshName = "mesh/chr_skelett2_bake.FBX"; // core::string::toLower(network::messages::EnumNameNpcType(type));
_worldRenderer.addEntity(std::make_shared<frontend::ClientEntity>(id, type, pos, 0.0f, _meshPool->getMesh(meshName)));
_worldRenderer.addEntity(std::make_shared<frontend::ClientEntity>(id, type, pos, orientation, _meshPool->getMesh(meshName)));
}
void Client::entityRemove(frontend::ClientEntityId id) {

View File

@ -103,7 +103,7 @@ public:
void authFailed();
void signup(const std::string& email, const std::string& password);
void lostPassword(const std::string& email);
void npcSpawn(frontend::ClientEntityId id, network::messages::NpcType type, const glm::vec3& pos);
void npcSpawn(frontend::ClientEntityId id, network::messages::NpcType type, float orientation, const glm::vec3& pos);
void entityUpdate(frontend::ClientEntityId id, const glm::vec3& pos, float orientation);
void entityRemove(frontend::ClientEntityId id);
void disconnect();

View File

@ -14,6 +14,6 @@ CLIENTPROTOHANDLERIMPL(EntityUpdate) {
if (pos == nullptr) {
return;
}
const glm::vec3 userPos(pos->x(), pos->y(), pos->z());
client->entityUpdate(message->id(), userPos, message->rotation());
const glm::vec3 entityPos(pos->x(), pos->y(), pos->z());
client->entityUpdate(message->id(), entityPos, message->rotation());
}

View File

@ -11,5 +11,5 @@
*/
CLIENTPROTOHANDLERIMPL(NpcSpawn) {
const network::messages::Vec3 *pos = message->pos();
client->npcSpawn(message->id(), message->type(), glm::vec3(pos->x(), pos->y(), pos->z()));
client->npcSpawn(message->id(), message->type(), message->rotation(), glm::vec3(pos->x(), pos->y(), pos->z()));
}