Prepare for orienation sync

This commit is contained in:
Pascal Serrarens 2024-03-15 17:36:34 +01:00
parent 04b0f01fb4
commit 577df7dc1a
2 changed files with 19 additions and 0 deletions

View File

@ -22,6 +22,24 @@ void NetworkSync::SendQuaternion(unsigned char *data, const int startIndex,
SendAngle(data, ix, angles.z);
}
void NetworkSync::SendQuat32(unsigned char *data, int startIndex,
const Quaternion q) {
unsigned char qx = (char)(q.x * 127 + 128);
unsigned char qy = (char)(q.y * 127 + 128);
unsigned char qz = (char)(q.z * 127 + 128);
unsigned char qw = (char)(q.w * 255);
if (q.w < 0) {
qx = -qx;
qy = -qy;
qz = -qz;
qw = -qw;
}
data[startIndex++] = qx;
data[startIndex++] = qy;
data[startIndex++] = qz;
data[startIndex++] = qw;
}
void NetworkSync::SendAngle(unsigned char *data, const int startIndex,
float angle) {
AngleUsing<unsigned char> packedAngle = AngleUsing<unsigned char>(angle);

View File

@ -56,6 +56,7 @@ protected:
void SendVector3(unsigned char *data, const int startIndex, const Vector3 v);
void SendQuaternion(unsigned char *data, const int startIndex,
const Quaternion q);
void SendQuat32(unsigned char *data, int startIndex, const Quaternion q);
};
} // namespace RoboidControl