mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 16:30:10 +02:00
Add jdoc to camera modes and fix variable namings
This commit is contained in:
parent
279e25ca70
commit
365aa1bf03
4 changed files with 33 additions and 21 deletions
|
@ -3631,12 +3631,12 @@ void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) {
|
|||
+ myAvatar->getWorldOrientation() * boomOffset);
|
||||
}
|
||||
} else {
|
||||
glm::quat lookAtOffset = myAvatar->getLookAtOffset();
|
||||
glm::quat lookAtRotation = myAvatar->getLookAtRotation();
|
||||
if (mode == CAMERA_MODE_SELFIE) {
|
||||
lookAtOffset = lookAtOffset * glm::angleAxis(PI, myAvatar->getWorldOrientation() * Vectors::UP);
|
||||
lookAtRotation = lookAtRotation * glm::angleAxis(PI, myAvatar->getWorldOrientation() * Vectors::UP);
|
||||
}
|
||||
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
||||
+ lookAtOffset * boomOffset);
|
||||
+ lookAtRotation * boomOffset);
|
||||
_myCamera.lookAt(myAvatar->getDefaultEyePosition());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3513,23 +3513,23 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
|||
if (!computeLookAt) {
|
||||
setWorldOrientation(getWorldOrientation() * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f))));
|
||||
_lookAtCameraTarget = eyesPosition + getWorldOrientation() * Vectors::FRONT;
|
||||
_lookAtOffsetYaw = getWorldOrientation();
|
||||
_lookAtOffsetPitch = Quaternions::IDENTITY;
|
||||
_lookAtYaw = getWorldOrientation();
|
||||
_lookAtPitch = Quaternions::IDENTITY;
|
||||
} else {
|
||||
// Compute new look at vectors
|
||||
if (totalBodyYaw != 0.0f) {
|
||||
_lookAtOffsetYaw = _lookAtOffsetYaw * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f)));
|
||||
_lookAtYaw = _lookAtYaw * glm::quat(glm::radians(glm::vec3(0.0f, totalBodyYaw, 0.0f)));
|
||||
}
|
||||
float pitchIncrement = getDriveKey(PITCH) * _pitchSpeed * deltaTime
|
||||
+ getDriveKey(DELTA_PITCH) * _pitchSpeed / PITCH_SPEED_DEFAULT;
|
||||
if (pitchIncrement != 0.0f) {
|
||||
glm::quat _previousLookAtOffsetPitch = _lookAtOffsetPitch;
|
||||
_lookAtOffsetPitch = _lookAtOffsetPitch * glm::quat(glm::radians(glm::vec3(pitchIncrement, 0.0f, 0.0f)));
|
||||
glm::quat _previousLookAtPitch = _lookAtPitch;
|
||||
_lookAtPitch = _lookAtPitch * glm::quat(glm::radians(glm::vec3(pitchIncrement, 0.0f, 0.0f)));
|
||||
// Limit the camera horizontal pitch
|
||||
float MAX_LOOK_AT_PITCH_DEGREES = 80.0f;
|
||||
float pitchFromHorizont = glm::degrees(angleBetween(getLookAtOffset() * Vectors::FRONT, _lookAtOffsetYaw * Vectors::FRONT));
|
||||
if (pitchFromHorizont > MAX_LOOK_AT_PITCH_DEGREES || pitchFromHorizont < -MAX_LOOK_AT_PITCH_DEGREES) {
|
||||
_lookAtOffsetPitch = _previousLookAtOffsetPitch;
|
||||
float pitchFromHorizont = glm::degrees(angleBetween(getLookAtRotation() * Vectors::FRONT, _lookAtYaw * Vectors::FRONT));
|
||||
if (pitchFromHorizont > MAX_LOOK_AT_PITCH_DEGREES) {
|
||||
_lookAtPitch = _previousLookAtPitch;
|
||||
}
|
||||
}
|
||||
bool isMovingFwdBwd = getDriveKey(TRANSLATE_Z) != 0.0f;
|
||||
|
@ -3545,13 +3545,13 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
|||
if (blend > 1.0f) {
|
||||
blend = 1.0f;
|
||||
}
|
||||
glm::quat faceRotation = _lookAtOffsetYaw;
|
||||
glm::quat faceRotation = _lookAtYaw;
|
||||
if (isMovingFwdBwd && isMovingSideways) {
|
||||
// Reorient avatar to face camera diagonal
|
||||
blend = DIAGONAL_TURN_BLEND;
|
||||
float turnSign = getDriveKey(TRANSLATE_Z) < 0.0f ? -1.0f : 1.0f;
|
||||
turnSign = getDriveKey(TRANSLATE_X) > 0.0f ? -turnSign : turnSign;
|
||||
faceRotation = _lookAtOffsetYaw * glm::angleAxis(turnSign * 0.25f * PI, Vectors::UP);
|
||||
faceRotation = _lookAtYaw * glm::angleAxis(turnSign * 0.25f * PI, Vectors::UP);
|
||||
}
|
||||
setWorldOrientation(glm::slerp(getWorldOrientation(), faceRotation, blend));
|
||||
} else if (isRotatingWhileSeated) {
|
||||
|
@ -3585,8 +3585,8 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
|||
head->setBasePitch(0.0f);
|
||||
head->setBaseRoll(0.0f);
|
||||
|
||||
glm::vec3 cameraVector = (faceForward ? _lookAtOffsetPitch * getWorldOrientation() : getLookAtOffset()) * Vectors::FRONT;
|
||||
glm::vec3 cameraYawVector = _lookAtOffsetYaw * Vectors::FRONT;
|
||||
glm::vec3 cameraVector = (faceForward ? _lookAtPitch * getWorldOrientation() : getLookAtRotation()) * Vectors::FRONT;
|
||||
glm::vec3 cameraYawVector = _lookAtYaw * Vectors::FRONT;
|
||||
|
||||
// Cap and attenuate head's lookat pitch angle
|
||||
const float START_LOOKING_UP_DEGREES = 5.0f;
|
||||
|
@ -3608,17 +3608,17 @@ void MyAvatar::updateOrientation(float deltaTime) {
|
|||
}
|
||||
}
|
||||
glm::vec3 avatarVectorFront = getWorldOrientation() * Vectors::FRONT;
|
||||
float frontBackDot = glm::dot(cameraVector, avatarVectorFront);
|
||||
float frontBackDot = glm::dot(cameraYawVector, avatarVectorFront);
|
||||
|
||||
glm::vec3 avatarVectorRight = getWorldOrientation() * Vectors::RIGHT;
|
||||
float leftRightDot = glm::dot(cameraVector, avatarVectorRight);
|
||||
float leftRightDot = glm::dot(cameraYawVector, avatarVectorRight);
|
||||
|
||||
const float REORIENT_ANGLE = 65.0f;
|
||||
const float TRIGGER_REORIENT_ANGLE = 45.0f;
|
||||
glm::vec3 ajustedYawVector = cameraYawVector;
|
||||
if (frontBackDot < 0.0f) {
|
||||
ajustedYawVector = (leftRightDot < 0.0f ? -avatarVectorRight : avatarVectorRight);
|
||||
cameraVector = (ajustedYawVector * _lookAtOffsetPitch) * Vectors::FRONT;
|
||||
cameraVector = (ajustedYawVector * _lookAtPitch) * Vectors::FRONT;
|
||||
if (frontBackDot < -glm::sin(glm::radians(TRIGGER_REORIENT_ANGLE))) {
|
||||
_shouldTurnToFaceCamera = true;
|
||||
}
|
||||
|
|
|
@ -1763,7 +1763,7 @@ public:
|
|||
*/
|
||||
Q_INVOKABLE glm::vec3 getHeadLookAt() { return _lookAtCameraTarget; }
|
||||
|
||||
glm::quat getLookAtOffset() { return _lookAtOffsetYaw * _lookAtOffsetPitch; }
|
||||
glm::quat getLookAtRotation() { return _lookAtYaw * _lookAtPitch; }
|
||||
|
||||
/**jsdoc
|
||||
* Creates a new grab that grabs an entity.
|
||||
|
@ -2643,8 +2643,8 @@ private:
|
|||
glm::vec3 _trackedHeadPosition;
|
||||
|
||||
const float MAX_LOOK_AT_TIME_SCRIPT_CONTROL = 2.0f;
|
||||
glm::quat _lookAtOffsetPitch;
|
||||
glm::quat _lookAtOffsetYaw;
|
||||
glm::quat _lookAtPitch;
|
||||
glm::quat _lookAtYaw;
|
||||
glm::vec3 _lookAtCameraTarget;
|
||||
glm::vec3 _lookAtScriptTarget;
|
||||
bool _headLookAtActive { false };
|
||||
|
|
|
@ -35,6 +35,18 @@
|
|||
* your avatar.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><strong>Look At</strong></td>
|
||||
* <td><code>"look at"</code></td>
|
||||
* <td>The camera is positioned behind your avatar. The camera moves and rotates independently from your avatar.
|
||||
* The avatar's head always faces the camera look at point.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><strong>Selfie</strong></td>
|
||||
* <td><code>"selfie"</code></td>
|
||||
* <td>The camera is positioned in front of your avatar. The camera moves and rotates independently from your avatar.
|
||||
* Your avatar's head is always facing the camera.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><strong>Mirror</strong></td>
|
||||
* <td><code>"mirror"</code></td>
|
||||
* <td>The camera is positioned such that you are looking directly at your avatar. The camera moves and rotates with your
|
||||
|
|
Loading…
Reference in a new issue