本文整理汇总了C++中Entity::GetEntityRotation方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::GetEntityRotation方法的具体用法?C++ Entity::GetEntityRotation怎么用?C++ Entity::GetEntityRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entity
的用法示例。
在下文中一共展示了Entity::GetEntityRotation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendRotationPacket
void ServerGame::sendRotationPacket(int class_id, int obj_id) {
const unsigned int packet_size = sizeof(Packet);
char packet_data[packet_size];
Entity* ent = (Entity*)(EntitySpawner::instance()->GetEntity(class_id, obj_id));
// If this is not a player and the player is dead, don't update
if (class_id == ClassId::PLAYER)
{
if (!((Player*)ent)->IsAlive())
return;
}
Packet packet;
packet.hdr.sender_id = SERVER_ID;
packet.hdr.packet_type = V_ROTATION_EVENT;
packet.dat.game_data_id = POS_OBJ;
PosInfo p;
p.cid = (ClassId) class_id;
p.oid = obj_id;
// why do we switch w and y and multiply by negative, we don't know but it fixes it
btQuaternion q = ent->GetEntityRotation();
btVector3 v = ent->GetEntityPosition();
p.x = v.getX();
p.y = v.getY();
p.z = v.getZ();
p.rotw = q.getW();
p.rotx = q.getX();
p.roty = q.getY();
p.rotz = q.getZ();
p.serialize(packet.dat.buf);
packet.serialize(packet_data);
network->sendToAll(packet_data, packet_size);
}