mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 16:36:54 +02:00
Fixing mouselook.
Faceshift head rotations are stored separately and then integrated into the final (rendered) head rotation at the right times but do not affect the camera.
This commit is contained in:
parent
8c3ba5b2de
commit
6b2c7c556d
4 changed files with 43 additions and 11 deletions
|
@ -59,15 +59,15 @@ void FaceModel::maybeUpdateNeckRotation(const JointState& parentState, const FBX
|
||||||
glm::mat3 inverse = glm::mat3(glm::inverse(parentState.transform * glm::translate(state.translation) *
|
glm::mat3 inverse = glm::mat3(glm::inverse(parentState.transform * glm::translate(state.translation) *
|
||||||
joint.preTransform * glm::mat4_cast(joint.preRotation)));
|
joint.preTransform * glm::mat4_cast(joint.preRotation)));
|
||||||
state.rotation = glm::angleAxis(-_owningHead->getRoll(), glm::normalize(inverse * axes[2])) *
|
state.rotation = glm::angleAxis(-_owningHead->getRoll(), glm::normalize(inverse * axes[2])) *
|
||||||
glm::angleAxis(_owningHead->getYaw(), glm::normalize(inverse * axes[1])) *
|
glm::angleAxis(_owningHead->getTweakedYaw(), glm::normalize(inverse * axes[1])) *
|
||||||
glm::angleAxis(-_owningHead->getPitch(), glm::normalize(inverse * axes[0])) * joint.rotation;
|
glm::angleAxis(-_owningHead->getTweakedPitch(), glm::normalize(inverse * axes[0])) * joint.rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaceModel::maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) {
|
void FaceModel::maybeUpdateEyeRotation(const JointState& parentState, const FBXJoint& joint, JointState& state) {
|
||||||
// likewise with the eye joints
|
// likewise with the eye joints
|
||||||
glm::mat4 inverse = glm::inverse(parentState.transform * glm::translate(state.translation) *
|
glm::mat4 inverse = glm::inverse(parentState.transform * glm::translate(state.translation) *
|
||||||
joint.preTransform * glm::mat4_cast(joint.preRotation * joint.rotation));
|
joint.preTransform * glm::mat4_cast(joint.preRotation * joint.rotation));
|
||||||
glm::vec3 front = glm::vec3(inverse * glm::vec4(_owningHead->getOrientation() * IDENTITY_FRONT, 0.0f));
|
glm::vec3 front = glm::vec3(inverse * glm::vec4(_owningHead->getTweakedOrientation() * IDENTITY_FRONT, 0.0f));
|
||||||
glm::vec3 lookAt = glm::vec3(inverse * glm::vec4(_owningHead->getLookAtPosition() +
|
glm::vec3 lookAt = glm::vec3(inverse * glm::vec4(_owningHead->getLookAtPosition() +
|
||||||
_owningHead->getSaccade() - _translation, 1.0f));
|
_owningHead->getSaccade() - _translation, 1.0f));
|
||||||
glm::quat between = rotationBetween(front, lookAt);
|
glm::quat between = rotationBetween(front, lookAt);
|
||||||
|
|
|
@ -18,7 +18,6 @@ using namespace std;
|
||||||
|
|
||||||
Head::Head(Avatar* owningAvatar) :
|
Head::Head(Avatar* owningAvatar) :
|
||||||
HeadData((AvatarData*)owningAvatar),
|
HeadData((AvatarData*)owningAvatar),
|
||||||
yawRate(0.0f),
|
|
||||||
_returnHeadToCenter(false),
|
_returnHeadToCenter(false),
|
||||||
_position(0.0f, 0.0f, 0.0f),
|
_position(0.0f, 0.0f, 0.0f),
|
||||||
_rotation(0.0f, 0.0f, 0.0f),
|
_rotation(0.0f, 0.0f, 0.0f),
|
||||||
|
@ -37,6 +36,9 @@ Head::Head(Avatar* owningAvatar) :
|
||||||
_leftEyeBlinkVelocity(0.0f),
|
_leftEyeBlinkVelocity(0.0f),
|
||||||
_rightEyeBlinkVelocity(0.0f),
|
_rightEyeBlinkVelocity(0.0f),
|
||||||
_timeWithoutTalking(0.0f),
|
_timeWithoutTalking(0.0f),
|
||||||
|
_tweakedPitch(0.f),
|
||||||
|
_tweakedYaw(0.f),
|
||||||
|
_tweakedRoll(0.f),
|
||||||
_isCameraMoving(false),
|
_isCameraMoving(false),
|
||||||
_faceModel(this)
|
_faceModel(this)
|
||||||
{
|
{
|
||||||
|
@ -186,9 +188,14 @@ glm::quat Head::getOrientation() const {
|
||||||
return glm::quat(glm::radians(_bodyRotation)) * glm::quat(glm::radians(glm::vec3(_pitch, _yaw, _roll)));
|
return glm::quat(glm::radians(_bodyRotation)) * glm::quat(glm::radians(glm::vec3(_pitch, _yaw, _roll)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::quat Head::getTweakedOrientation() const {
|
||||||
|
return glm::quat(glm::radians(_bodyRotation)) * glm::quat(glm::radians(glm::vec3(getTweakedPitch(), getTweakedYaw(), getTweakedRoll() )));
|
||||||
|
}
|
||||||
|
|
||||||
glm::quat Head::getCameraOrientation () const {
|
glm::quat Head::getCameraOrientation () const {
|
||||||
Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
|
Avatar* owningAvatar = static_cast<Avatar*>(_owningAvatar);
|
||||||
return owningAvatar->getWorldAlignedOrientation();
|
return owningAvatar->getWorldAlignedOrientation()
|
||||||
|
* glm::quat(glm::radians(glm::vec3(_pitch, 0.f, 0.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::quat Head::getEyeRotation(const glm::vec3& eyePosition) const {
|
glm::quat Head::getEyeRotation(const glm::vec3& eyePosition) const {
|
||||||
|
@ -200,6 +207,18 @@ glm::vec3 Head::getScalePivot() const {
|
||||||
return _faceModel.isActive() ? _faceModel.getTranslation() : _position;
|
return _faceModel.isActive() ? _faceModel.getTranslation() : _position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Head::getTweakedYaw() const {
|
||||||
|
return glm::clamp(_yaw + _tweakedYaw, MIN_HEAD_YAW, MAX_HEAD_YAW);
|
||||||
|
}
|
||||||
|
|
||||||
|
float Head::getTweakedPitch() const {
|
||||||
|
return glm::clamp(_pitch + _tweakedPitch, MIN_HEAD_PITCH, MAX_HEAD_PITCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
float Head::getTweakedRoll() const {
|
||||||
|
return glm::clamp(_roll + _tweakedRoll, MIN_HEAD_ROLL, MAX_HEAD_ROLL);
|
||||||
|
}
|
||||||
|
|
||||||
void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition) {
|
void Head::renderLookatVectors(glm::vec3 leftEyePosition, glm::vec3 rightEyePosition, glm::vec3 lookatPosition) {
|
||||||
|
|
||||||
Application::getInstance()->getGlowEffect()->begin();
|
Application::getInstance()->getGlowEffect()->begin();
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
#include <AvatarData.h>
|
#include <HeadData.h>
|
||||||
|
|
||||||
#include <VoxelConstants.h>
|
#include <VoxelConstants.h>
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ public:
|
||||||
void setRenderLookatVectors(bool onOff) { _renderLookatVectors = onOff; }
|
void setRenderLookatVectors(bool onOff) { _renderLookatVectors = onOff; }
|
||||||
|
|
||||||
glm::quat getOrientation() const;
|
glm::quat getOrientation() const;
|
||||||
|
glm::quat getTweakedOrientation() const;
|
||||||
glm::quat getCameraOrientation () const;
|
glm::quat getCameraOrientation () const;
|
||||||
const glm::vec3& getAngularVelocity() const { return _angularVelocity; }
|
const glm::vec3& getAngularVelocity() const { return _angularVelocity; }
|
||||||
void setAngularVelocity(glm::vec3 angularVelocity) { _angularVelocity = angularVelocity; }
|
void setAngularVelocity(glm::vec3 angularVelocity) { _angularVelocity = angularVelocity; }
|
||||||
|
@ -70,9 +71,15 @@ public:
|
||||||
|
|
||||||
/// Returns the point about which scaling occurs.
|
/// Returns the point about which scaling occurs.
|
||||||
glm::vec3 getScalePivot() const;
|
glm::vec3 getScalePivot() const;
|
||||||
|
|
||||||
float yawRate;
|
|
||||||
|
|
||||||
|
void tweakPitch(float pitch) { _tweakedPitch = pitch; }
|
||||||
|
void tweakYaw(float yaw) { _tweakedYaw = yaw; }
|
||||||
|
void tweakRoll(float roll) { _tweakedRoll = roll; }
|
||||||
|
|
||||||
|
float getTweakedPitch() const;
|
||||||
|
float getTweakedYaw() const;
|
||||||
|
float getTweakedRoll() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// disallow copies of the Head, copy of owning Avatar is disallowed too
|
// disallow copies of the Head, copy of owning Avatar is disallowed too
|
||||||
Head(const Head&);
|
Head(const Head&);
|
||||||
|
@ -96,6 +103,12 @@ private:
|
||||||
float _leftEyeBlinkVelocity;
|
float _leftEyeBlinkVelocity;
|
||||||
float _rightEyeBlinkVelocity;
|
float _rightEyeBlinkVelocity;
|
||||||
float _timeWithoutTalking;
|
float _timeWithoutTalking;
|
||||||
|
|
||||||
|
// tweaked angles affect the rendered head, but not the camera
|
||||||
|
float _tweakedPitch;
|
||||||
|
float _tweakedYaw;
|
||||||
|
float _tweakedRoll;
|
||||||
|
|
||||||
bool _isCameraMoving;
|
bool _isCameraMoving;
|
||||||
FaceModel _faceModel;
|
FaceModel _faceModel;
|
||||||
|
|
||||||
|
|
|
@ -396,9 +396,9 @@ void MyAvatar::updateFromGyros(bool turnWithHead) {
|
||||||
const float AVATAR_HEAD_PITCH_MAGNIFY = 1.0f;
|
const float AVATAR_HEAD_PITCH_MAGNIFY = 1.0f;
|
||||||
const float AVATAR_HEAD_YAW_MAGNIFY = 1.0f;
|
const float AVATAR_HEAD_YAW_MAGNIFY = 1.0f;
|
||||||
const float AVATAR_HEAD_ROLL_MAGNIFY = 1.0f;
|
const float AVATAR_HEAD_ROLL_MAGNIFY = 1.0f;
|
||||||
_head.setPitch(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY);
|
_head.tweakPitch(estimatedRotation.x * AVATAR_HEAD_PITCH_MAGNIFY);
|
||||||
_head.setYaw(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY);
|
_head.tweakYaw(estimatedRotation.y * AVATAR_HEAD_YAW_MAGNIFY);
|
||||||
_head.setRoll(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY);
|
_head.tweakRoll(estimatedRotation.z * AVATAR_HEAD_ROLL_MAGNIFY);
|
||||||
|
|
||||||
// Update torso lean distance based on accelerometer data
|
// Update torso lean distance based on accelerometer data
|
||||||
const float TORSO_LENGTH = 0.5f;
|
const float TORSO_LENGTH = 0.5f;
|
||||||
|
|
Loading…
Reference in a new issue