mirror of
https://github.com/lubosz/overte.git
synced 2025-04-27 17:35:26 +02:00
trying to get somewhere....
This commit is contained in:
parent
da8270d50b
commit
1fd37b51a2
4 changed files with 54 additions and 20 deletions
|
@ -176,6 +176,8 @@ function formatTime(time) {
|
||||||
var SEC_PER_MIN = 60;
|
var SEC_PER_MIN = 60;
|
||||||
var MSEC_PER_SEC = 1000;
|
var MSEC_PER_SEC = 1000;
|
||||||
|
|
||||||
|
time = time * (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR);
|
||||||
|
|
||||||
var hours = Math.floor(time / (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR));
|
var hours = Math.floor(time / (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR));
|
||||||
time -= hours * (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR);
|
time -= hours * (MSEC_PER_SEC * SEC_PER_MIN * MIN_PER_HOUR);
|
||||||
|
|
||||||
|
|
|
@ -608,7 +608,7 @@ float MyAvatar::recorderElapsed() {
|
||||||
if (!_recorder) {
|
if (!_recorder) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return (float)_recorder->position() / MSECS_PER_SECOND;
|
return (float)_recorder->position();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMetaObject::Connection _audioClientRecorderConnection;
|
QMetaObject::Connection _audioClientRecorderConnection;
|
||||||
|
|
|
@ -804,12 +804,12 @@ float AvatarData::playerElapsed() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
qint64 result;
|
float result;
|
||||||
QMetaObject::invokeMethod(this, "playerElapsed", Qt::BlockingQueuedConnection,
|
QMetaObject::invokeMethod(this, "playerElapsed", Qt::BlockingQueuedConnection,
|
||||||
Q_RETURN_ARG(qint64, result));
|
Q_RETURN_ARG(float, result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return (float)_player->position() / MSECS_PER_SECOND;
|
return (float)_player->position();
|
||||||
}
|
}
|
||||||
|
|
||||||
float AvatarData::playerLength() {
|
float AvatarData::playerLength() {
|
||||||
|
@ -817,12 +817,12 @@ float AvatarData::playerLength() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
qint64 result;
|
float result;
|
||||||
QMetaObject::invokeMethod(this, "playerLength", Qt::BlockingQueuedConnection,
|
QMetaObject::invokeMethod(this, "playerLength", Qt::BlockingQueuedConnection,
|
||||||
Q_RETURN_ARG(qint64, result));
|
Q_RETURN_ARG(float, result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return _player->length() / MSECS_PER_SECOND;
|
return _player->length();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::loadRecording(const QString& filename) {
|
void AvatarData::loadRecording(const QString& filename) {
|
||||||
|
@ -870,7 +870,7 @@ void AvatarData::setPlayerTime(float time) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_player->seek(time * MSECS_PER_SECOND);
|
_player->seek(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarData::setPlayFromCurrentLocation(bool playFromCurrentLocation) {
|
void AvatarData::setPlayFromCurrentLocation(bool playFromCurrentLocation) {
|
||||||
|
@ -1532,7 +1532,7 @@ Transform AvatarData::getTransform() const {
|
||||||
|
|
||||||
static const QString JSON_AVATAR_BASIS = QStringLiteral("basisTransform");
|
static const QString JSON_AVATAR_BASIS = QStringLiteral("basisTransform");
|
||||||
static const QString JSON_AVATAR_RELATIVE = QStringLiteral("relativeTransform");
|
static const QString JSON_AVATAR_RELATIVE = QStringLiteral("relativeTransform");
|
||||||
static const QString JSON_AVATAR_JOINT_ROTATIONS = QStringLiteral("jointRotations");
|
static const QString JSON_AVATAR_JOINT_ARRAY = QStringLiteral("jointArray");
|
||||||
static const QString JSON_AVATAR_HEAD = QStringLiteral("head");
|
static const QString JSON_AVATAR_HEAD = QStringLiteral("head");
|
||||||
static const QString JSON_AVATAR_HEAD_ROTATION = QStringLiteral("rotation");
|
static const QString JSON_AVATAR_HEAD_ROTATION = QStringLiteral("rotation");
|
||||||
static const QString JSON_AVATAR_HEAD_BLENDSHAPE_COEFFICIENTS = QStringLiteral("blendShapes");
|
static const QString JSON_AVATAR_HEAD_BLENDSHAPE_COEFFICIENTS = QStringLiteral("blendShapes");
|
||||||
|
@ -1544,6 +1544,24 @@ static const QString JSON_AVATAR_BODY_MODEL = QStringLiteral("bodyModel");
|
||||||
static const QString JSON_AVATAR_DISPLAY_NAME = QStringLiteral("displayName");
|
static const QString JSON_AVATAR_DISPLAY_NAME = QStringLiteral("displayName");
|
||||||
static const QString JSON_AVATAR_ATTACHEMENTS = QStringLiteral("attachments");
|
static const QString JSON_AVATAR_ATTACHEMENTS = QStringLiteral("attachments");
|
||||||
|
|
||||||
|
QJsonValue toJsonValue(const JointData& joint) {
|
||||||
|
QJsonArray result;
|
||||||
|
result.push_back(toJsonValue(joint.rotation));
|
||||||
|
result.push_back(toJsonValue(joint.translation));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
JointData jointDataFromJsonValue(const QJsonValue& json) {
|
||||||
|
JointData result;
|
||||||
|
if (json.isArray()) {
|
||||||
|
QJsonArray array = json.toArray();
|
||||||
|
result.rotation = quatFromJsonValue(array[0]);
|
||||||
|
result.rotationSet = true;
|
||||||
|
result.translation = vec3FromJsonValue(array[1]);
|
||||||
|
result.translationSet = false;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Every frame will store both a basis for the recording and a relative transform
|
// Every frame will store both a basis for the recording and a relative transform
|
||||||
// This allows the application to decide whether playback should be relative to an avatar's
|
// This allows the application to decide whether playback should be relative to an avatar's
|
||||||
|
@ -1575,13 +1593,16 @@ QByteArray avatarStateToFrame(const AvatarData* _avatar) {
|
||||||
root[JSON_AVATAR_RELATIVE] = Transform::toJson(relativeTransform);
|
root[JSON_AVATAR_RELATIVE] = Transform::toJson(relativeTransform);
|
||||||
root[JSON_AVATAR_BASIS] = Transform::toJson(*recordingBasis);
|
root[JSON_AVATAR_BASIS] = Transform::toJson(*recordingBasis);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
root[JSON_AVATAR_RELATIVE] = Transform::toJson(_avatar->getTransform());
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonArray jointRotations;
|
// Skeleton pose
|
||||||
for (const auto& jointRotation : _avatar->getJointRotations()) {
|
QJsonArray jointArray;
|
||||||
jointRotations.push_back(toJsonValue(jointRotation));
|
for (const auto& joint : _avatar->getRawJointData()) {
|
||||||
|
jointArray.push_back(toJsonValue(joint));
|
||||||
}
|
}
|
||||||
root[JSON_AVATAR_JOINT_ROTATIONS] = jointRotations;
|
root[JSON_AVATAR_JOINT_ARRAY] = jointArray;
|
||||||
|
|
||||||
const HeadData* head = _avatar->getHeadData();
|
const HeadData* head = _avatar->getHeadData();
|
||||||
if (head) {
|
if (head) {
|
||||||
|
@ -1646,21 +1667,29 @@ void avatarStateFromFrame(const QByteArray& frameData, AvatarData* _avatar) {
|
||||||
_avatar->setTargetScale(worldTransform.getScale().x);
|
_avatar->setTargetScale(worldTransform.getScale().x);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (root.contains(JSON_AVATAR_ATTACHEMENTS)) {
|
if (root.contains(JSON_AVATAR_ATTACHEMENTS)) {
|
||||||
// FIXME de-serialize attachment data
|
// FIXME de-serialize attachment data
|
||||||
}
|
}
|
||||||
|
|
||||||
// Joint rotations are relative to the avatar, so they require no basis correction
|
// Joint rotations are relative to the avatar, so they require no basis correction
|
||||||
if (root.contains(JSON_AVATAR_JOINT_ROTATIONS)) {
|
if (root.contains(JSON_AVATAR_JOINT_ARRAY)) {
|
||||||
QVector<quat> jointRotations;
|
QVector<JointData> jointArray;
|
||||||
QJsonArray jointRotationsJson = root[JSON_AVATAR_JOINT_ROTATIONS].toArray();
|
QJsonArray jointArrayJson = root[JSON_AVATAR_JOINT_ARRAY].toArray();
|
||||||
jointRotations.reserve(jointRotationsJson.size());
|
jointArray.reserve(jointArrayJson.size());
|
||||||
for (const auto& jointRotationJson : jointRotationsJson) {
|
for (const auto& jointJson : jointArrayJson) {
|
||||||
jointRotations.push_back(quatFromJsonValue(jointRotationJson));
|
jointArray.push_back(jointDataFromJsonValue(jointJson));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<glm::quat> jointRotations;
|
||||||
|
jointRotations.reserve(jointArray.size());
|
||||||
|
for (const auto& joint : jointArray) {
|
||||||
|
jointRotations.push_back(joint.rotation);
|
||||||
|
}
|
||||||
|
_avatar->setJointRotations(jointRotations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
// Most head data is relative to the avatar, and needs no basis correction,
|
// Most head data is relative to the avatar, and needs no basis correction,
|
||||||
// but the lookat vector does need correction
|
// but the lookat vector does need correction
|
||||||
HeadData* head = _avatar->_headData;
|
HeadData* head = _avatar->_headData;
|
||||||
|
|
|
@ -457,6 +457,9 @@ public:
|
||||||
bool translationSet = false;
|
bool translationSet = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QJsonValue toJsonValue(const JointData& joint);
|
||||||
|
JointData jointDataFromJsonValue(const QJsonValue& q);
|
||||||
|
|
||||||
class AttachmentData {
|
class AttachmentData {
|
||||||
public:
|
public:
|
||||||
QUrl modelURL;
|
QUrl modelURL;
|
||||||
|
|
Loading…
Reference in a new issue