mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Added setFinalPitch/Yaw/Roll to HeadData
This commit is contained in:
parent
9e686b4096
commit
3826ed0d69
6 changed files with 27 additions and 16 deletions
|
@ -222,6 +222,18 @@ glm::vec3 Head::getScalePivot() const {
|
|||
return _faceModel.isActive() ? _faceModel.getTranslation() : _position;
|
||||
}
|
||||
|
||||
void Head::setFinalPitch(float finalPitch) {
|
||||
_deltaPitch = glm::clamp(finalPitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH) - _basePitch;
|
||||
}
|
||||
|
||||
void Head::setFinalYaw(float finalYaw) {
|
||||
_deltaYaw = glm::clamp(finalYaw, MIN_HEAD_YAW, MAX_HEAD_YAW) - _baseYaw;
|
||||
}
|
||||
|
||||
void Head::setFinalRoll(float finalRoll) {
|
||||
_deltaRoll = glm::clamp(finalRoll, MIN_HEAD_ROLL, MAX_HEAD_ROLL) - _baseRoll;
|
||||
}
|
||||
|
||||
float Head::getFinalYaw() const {
|
||||
return glm::clamp(_baseYaw + _deltaYaw, MIN_HEAD_YAW, MAX_HEAD_YAW);
|
||||
}
|
||||
|
|
|
@ -95,6 +95,9 @@ public:
|
|||
void setDeltaRoll(float roll) { _deltaRoll = roll; }
|
||||
float getDeltaRoll() const { return _deltaRoll; }
|
||||
|
||||
virtual void setFinalYaw(float finalYaw);
|
||||
virtual void setFinalPitch(float finalPitch);
|
||||
virtual void setFinalRoll(float finalRoll);
|
||||
virtual float getFinalPitch() const;
|
||||
virtual float getFinalYaw() const;
|
||||
virtual float getFinalRoll() const;
|
||||
|
|
|
@ -153,7 +153,8 @@ QByteArray AvatarData::toByteArray() {
|
|||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyYaw);
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyPitch);
|
||||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll);
|
||||
|
||||
|
||||
|
||||
// Body scale
|
||||
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale);
|
||||
|
||||
|
@ -793,6 +794,9 @@ void AvatarData::setJointRotations(QVector<glm::quat> jointRotations) {
|
|||
"setJointRotations", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(QVector<glm::quat>, jointRotations));
|
||||
}
|
||||
if (_jointData.size() < jointRotations.size()) {
|
||||
_jointData.resize(jointRotations.size());
|
||||
}
|
||||
for (int i = 0; i < jointRotations.size(); ++i) {
|
||||
if (i < _jointData.size()) {
|
||||
setJointData(i, jointRotations[i]);
|
||||
|
|
|
@ -41,6 +41,10 @@ public:
|
|||
void setBasePitch(float pitch) { _basePitch = glm::clamp(pitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH); }
|
||||
float getBaseRoll() const { return _baseRoll; }
|
||||
void setBaseRoll(float roll) { _baseRoll = glm::clamp(roll, MIN_HEAD_ROLL, MAX_HEAD_ROLL); }
|
||||
|
||||
virtual void setFinalYaw(float finalYaw) { _baseYaw = finalYaw; }
|
||||
virtual void setFinalPitch(float finalPitch) { _basePitch = finalPitch; }
|
||||
virtual void setFinalRoll(float finalRoll) { _baseRoll = finalRoll; }
|
||||
virtual float getFinalYaw() const { return _baseYaw; }
|
||||
virtual float getFinalPitch() const { return _basePitch; }
|
||||
virtual float getFinalRoll() const { return _baseRoll; }
|
||||
|
|
|
@ -229,11 +229,6 @@ void Player::startPlaying() {
|
|||
_audioThread->start();
|
||||
QMetaObject::invokeMethod(_injector.data(), "injectAudio", Qt::QueuedConnection);
|
||||
|
||||
// Save head orientation
|
||||
if (_avatar->getHeadData()) {
|
||||
_originalHeadOrientation = _avatar->getHeadOrientation();
|
||||
}
|
||||
|
||||
_timer.start();
|
||||
}
|
||||
}
|
||||
|
@ -258,11 +253,6 @@ void Player::stopPlaying() {
|
|||
_injector.clear();
|
||||
_audioThread = NULL;
|
||||
|
||||
// Restore head orientation
|
||||
if (_avatar->getHeadData()) {
|
||||
_avatar->setHeadOrientation(_originalHeadOrientation);
|
||||
}
|
||||
|
||||
qDebug() << "Recorder::stopPlaying()";
|
||||
}
|
||||
|
||||
|
@ -307,9 +297,9 @@ void Player::play() {
|
|||
head->setLeanSideways(_recording->getFrame(_currentFrame).getLeanSideways());
|
||||
head->setLeanForward(_recording->getFrame(_currentFrame).getLeanForward());
|
||||
glm::vec3 eulers = glm::degrees(safeEulerAngles(_recording->getFrame(_currentFrame).getHeadRotation()));
|
||||
head->setBasePitch(eulers.x);
|
||||
head->setBaseYaw(eulers.y);
|
||||
head->setBaseRoll(eulers.z);
|
||||
head->setFinalPitch(eulers.x);
|
||||
head->setFinalYaw(eulers.y);
|
||||
head->setFinalRoll(eulers.z);
|
||||
}
|
||||
|
||||
_options.setPosition(_avatar->getPosition());
|
||||
|
|
|
@ -162,8 +162,6 @@ private:
|
|||
QSharedPointer<AudioInjector> _injector;
|
||||
AudioInjectorOptions _options;
|
||||
|
||||
glm::quat _originalHeadOrientation;
|
||||
|
||||
AvatarData* _avatar;
|
||||
QThread* _audioThread;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue