mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
debugging to solve the no-neck crazy scale problem
This commit is contained in:
parent
e9f23a43f6
commit
c774dd7f5b
6 changed files with 35 additions and 0 deletions
|
@ -3064,6 +3064,7 @@ void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) {
|
|||
auto myAvatar = getMyAvatar();
|
||||
boomOffset = myAvatar->getModelScale() * myAvatar->getBoomLength() * -IDENTITY_FORWARD;
|
||||
|
||||
//qCDebug(interfaceapp) << "boom offset" << boomOffset;
|
||||
// The render mode is default or mirror if the camera is in mirror mode, assigned further below
|
||||
renderArgs._renderMode = RenderArgs::DEFAULT_RENDER_MODE;
|
||||
|
||||
|
@ -3074,10 +3075,12 @@ void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) {
|
|||
_thirdPersonHMDCameraBoomValid= false;
|
||||
if (isHMDMode()) {
|
||||
mat4 camMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
|
||||
//qCDebug(interfaceapp) << "camera 1rst translation hmd " << extractTranslation(camMat);
|
||||
_myCamera.setPosition(extractTranslation(camMat));
|
||||
_myCamera.setOrientation(glmExtractRotation(camMat));
|
||||
}
|
||||
else {
|
||||
//qCDebug(interfaceapp) << "camera 1rst translation desktop " << myAvatar->getDefaultEyePosition();
|
||||
_myCamera.setPosition(myAvatar->getDefaultEyePosition());
|
||||
_myCamera.setOrientation(myAvatar->getMyHead()->getHeadOrientation());
|
||||
}
|
||||
|
@ -3099,6 +3102,7 @@ void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) {
|
|||
|
||||
_myCamera.setOrientation(glm::normalize(glmExtractRotation(worldCameraMat)));
|
||||
_myCamera.setPosition(extractTranslation(worldCameraMat));
|
||||
//qCDebug(interfaceapp) << "camera translation 3rd hmd " << extractTranslation(worldCameraMat);
|
||||
}
|
||||
else {
|
||||
_thirdPersonHMDCameraBoomValid = false;
|
||||
|
@ -3112,6 +3116,7 @@ void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) {
|
|||
_myCamera.setPosition(myAvatar->getDefaultEyePosition()
|
||||
+ myAvatar->getWorldOrientation() * boomOffset);
|
||||
}
|
||||
qCDebug(interfaceapp) << "camera translation 3rd desktop " << (myAvatar->getDefaultEyePosition() + _myCamera.getOrientation() * boomOffset);
|
||||
}
|
||||
}
|
||||
else if (_myCamera.getMode() == CAMERA_MODE_MIRROR) {
|
||||
|
|
|
@ -1704,8 +1704,10 @@ glm::vec3 MyAvatar::getSkeletonPosition() const {
|
|||
// The avatar is rotated PI about the yAxis, so we have to correct for it
|
||||
// to get the skeleton offset contribution in the world-frame.
|
||||
const glm::quat FLIP = glm::angleAxis(PI, glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
//qCDebug(interfaceapp) << "position third person " << getWorldPosition();
|
||||
return getWorldPosition() + getWorldOrientation() * FLIP * _skeletonOffset;
|
||||
}
|
||||
//qCDebug(interfaceapp) << "position first person " << Avatar::getWorldPosition();
|
||||
return Avatar::getWorldPosition();
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,9 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
|
||||
// make sure lookAt is not too close to face (avoid crosseyes)
|
||||
glm::vec3 lookAt = head->getLookAtPosition();
|
||||
//qCDebug(interfaceapp) << "look at " << lookAt;
|
||||
glm::vec3 focusOffset = lookAt - _owningAvatar->getHead()->getEyePosition();
|
||||
//qCDebug(interfaceapp) << "focus offset " << focusOffset;
|
||||
float focusDistance = glm::length(focusOffset);
|
||||
const float MIN_LOOK_AT_FOCUS_DISTANCE = 1.0f;
|
||||
if (focusDistance < MIN_LOOK_AT_FOCUS_DISTANCE && focusDistance > EPSILON) {
|
||||
|
@ -113,6 +115,8 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
glm::mat4 avatarToWorldMatrix = createMatFromQuatAndPos(myAvatar->getWorldOrientation(), myAvatar->getWorldPosition());
|
||||
glm::mat4 sensorToWorldMatrix = myAvatar->getSensorToWorldMatrix();
|
||||
params.rigToSensorMatrix = glm::inverse(sensorToWorldMatrix) * avatarToWorldMatrix * rigToAvatarMatrix;
|
||||
//qCDebug(interfaceapp) << "AVATAR: " << avatarToWorldMatrix;
|
||||
//qCDebug(interfaceapp) << "SENSOR " << sensorToWorldMatrix;
|
||||
|
||||
// input action is the highest priority source for head orientation.
|
||||
auto avatarHeadPose = myAvatar->getControllerPoseInAvatarFrame(controller::Action::HEAD);
|
||||
|
@ -282,6 +286,7 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
|
|||
eyeParams.leftEyeJointIndex = geometry.leftEyeJointIndex;
|
||||
eyeParams.rightEyeJointIndex = geometry.rightEyeJointIndex;
|
||||
|
||||
//qCDebug(interfaceapp) << "right eye index is " << geometry.leftEyeJointIndex;
|
||||
_rig.updateFromEyeParameters(eyeParams);
|
||||
|
||||
updateFingers();
|
||||
|
|
|
@ -169,6 +169,8 @@ AABox Avatar::getBounds() const {
|
|||
// approximately 2m tall, scaled to user request.
|
||||
return AABox(getWorldPosition() - glm::vec3(getModelScale()), getModelScale() * 2.0f);
|
||||
}
|
||||
//float temp = _skeletonModel->getRenderableMeshBound().getLargestDimension();
|
||||
//qCDebug(animation) << " largest bounding box dimension " << temp;
|
||||
return _skeletonModel->getRenderableMeshBound();
|
||||
}
|
||||
|
||||
|
@ -1775,6 +1777,7 @@ void Avatar::buildUnscaledEyeHeightCache() {
|
|||
// Sanity check by looking at the model extents.
|
||||
Extents meshExtents = _skeletonModel->getUnscaledMeshExtents();
|
||||
float meshHeight = meshExtents.size().y;
|
||||
//qCDebug(animation) << "mesh height " << meshHeight << " skeleton height " << skeletonHeight;
|
||||
|
||||
// if we determine the mesh is much larger then the skeleton, then we use the mesh height instead.
|
||||
// This helps prevent absurdly large avatars from exceeding the domain height limit.
|
||||
|
|
|
@ -71,14 +71,23 @@ void SkeletonModel::initJointStates() {
|
|||
qCWarning(avatars_renderer) << "Bad head joint! Got:" << headJointIndex << "jointCount:" << _rig.getJointStateCount();
|
||||
}
|
||||
glm::vec3 leftEyePosition, rightEyePosition;
|
||||
qCDebug(avatars_renderer) << "initial left and right eyes " << leftEyePosition << " " << rightEyePosition;
|
||||
getEyeModelPositions(leftEyePosition, rightEyePosition);
|
||||
qCDebug(avatars_renderer) << "after setting the left and right eyes " << leftEyePosition << " " << rightEyePosition;
|
||||
glm::vec3 midEyePosition = (leftEyePosition + rightEyePosition) / 2.0f;
|
||||
|
||||
int rootJointIndex = geometry.rootJointIndex;
|
||||
glm::vec3 rootModelPosition;
|
||||
getJointPosition(rootJointIndex, rootModelPosition);
|
||||
qCDebug(avatars_renderer) << "root joint index " << rootJointIndex << " root position: " << rootModelPosition;
|
||||
|
||||
_defaultEyeModelPosition = midEyePosition - rootModelPosition;
|
||||
if (headJointIndex > -1) {
|
||||
glm::vec3 headModelPosition;
|
||||
getJointPosition(headJointIndex, headModelPosition);
|
||||
qCDebug(avatars_renderer) << "we have a head joint " << headJointIndex << " and " << headModelPosition;
|
||||
}
|
||||
qCDebug(avatars_renderer) << "the default eye pos " << _defaultEyeModelPosition << " and scale " << _scale;
|
||||
|
||||
// Skeleton may have already been scaled so unscale it
|
||||
_defaultEyeModelPosition = _defaultEyeModelPosition / _scale;
|
||||
|
@ -294,6 +303,16 @@ bool SkeletonModel::getEyeModelPositions(glm::vec3& firstEyePosition, glm::vec3&
|
|||
firstEyePosition = baseEyePosition + headRotation * glm::vec3(EYE_SEPARATION, 0.0f, EYES_FORWARD) * headHeight;
|
||||
secondEyePosition = baseEyePosition + headRotation * glm::vec3(-EYE_SEPARATION, 0.0f, EYES_FORWARD) * headHeight;
|
||||
return true;
|
||||
} else if (getJointPosition(geometry.headJointIndex, headPosition)) {
|
||||
glm::vec3 baseEyePosition = headPosition;
|
||||
glm::quat headRotation;
|
||||
getJointRotation(geometry.headJointIndex, headRotation);
|
||||
const float EYES_FORWARD = 0.25f;
|
||||
const float EYE_SEPARATION = 0.1f;
|
||||
float headHeight = glm::distance(neckPosition, headPosition);
|
||||
firstEyePosition = baseEyePosition + headRotation * glm::vec3(EYE_SEPARATION, 0.0f, EYES_FORWARD);
|
||||
secondEyePosition = baseEyePosition + headRotation * glm::vec3(-EYE_SEPARATION, 0.0f, EYES_FORWARD);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
//
|
||||
|
||||
#include "Camera.h"
|
||||
//#include "../SharedLogging.h"
|
||||
|
||||
/**jsdoc
|
||||
* <p>Camera modes affect the position of the camera and the controls for camera movement. The camera can be in one of the
|
||||
|
|
Loading…
Reference in a new issue