mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 16:48:55 +02:00
first attempt at palm rotation
This commit is contained in:
parent
542a5f100a
commit
08d63b7fd8
3 changed files with 34 additions and 2 deletions
|
@ -52,15 +52,19 @@ void AvatarActionHold::updateActionWorker(float deltaTimeStep) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 palmPosition;
|
glm::vec3 palmPosition;
|
||||||
|
glm::quat palmRotation;
|
||||||
if (_hand == "right") {
|
if (_hand == "right") {
|
||||||
palmPosition = myAvatar->getRightPalmPosition();
|
palmPosition = myAvatar->getRightPalmPosition();
|
||||||
|
palmRotation = myAvatar->getRightPalmRotation();
|
||||||
} else {
|
} else {
|
||||||
palmPosition = myAvatar->getLeftPalmPosition();
|
palmPosition = myAvatar->getLeftPalmPosition();
|
||||||
|
palmRotation = myAvatar->getLeftPalmRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto rotation = myAvatar->getWorldAlignedOrientation();
|
auto rotation = myAvatar->getWorldAlignedOrientation();
|
||||||
auto offset = rotation * _relativePosition;
|
auto offset = rotation * _relativePosition;
|
||||||
auto position = palmPosition + offset;
|
auto position = palmPosition + offset;
|
||||||
|
rotation *= palmRotation;
|
||||||
rotation *= _relativeRotation;
|
rotation *= _relativeRotation;
|
||||||
unlock();
|
unlock();
|
||||||
|
|
||||||
|
|
|
@ -371,6 +371,19 @@ glm::vec3 MyAvatar::getLeftPalmPosition() {
|
||||||
return leftHandPosition;
|
return leftHandPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::quat MyAvatar::getLeftPalmRotation() {
|
||||||
|
unsigned int leftIndex = 0;
|
||||||
|
if (getHand()->getNumPalms() > leftIndex) {
|
||||||
|
PalmData& palm = getHand()->getPalms()[leftIndex];
|
||||||
|
if (palm.isActive()) {
|
||||||
|
glm::vec3 tipDirection = glm::normalize(palm.getTipPosition() - palm.getPosition());
|
||||||
|
glm::vec3 avatarDirection = glm::vec3(0.0f, 0.0f, 1.0f) * getOrientation();
|
||||||
|
return rotationBetween(avatarDirection, tipDirection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return glm::quat();
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 MyAvatar::getRightPalmPosition() {
|
glm::vec3 MyAvatar::getRightPalmPosition() {
|
||||||
glm::vec3 rightHandPosition;
|
glm::vec3 rightHandPosition;
|
||||||
getSkeletonModel().getRightHandPosition(rightHandPosition);
|
getSkeletonModel().getRightHandPosition(rightHandPosition);
|
||||||
|
@ -380,6 +393,19 @@ glm::vec3 MyAvatar::getRightPalmPosition() {
|
||||||
return rightHandPosition;
|
return rightHandPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::quat MyAvatar::getRightPalmRotation() {
|
||||||
|
unsigned int rightIndex = 1;
|
||||||
|
if (getHand()->getNumPalms() > rightIndex) {
|
||||||
|
PalmData& palm = getHand()->getPalms()[rightIndex];
|
||||||
|
if (palm.isActive()) {
|
||||||
|
glm::vec3 tipDirection = glm::normalize(palm.getTipPosition() - palm.getPosition());
|
||||||
|
glm::vec3 avatarDirection = glm::vec3(0.0f, 0.0f, 1.0f) * getOrientation();
|
||||||
|
return rotationBetween(avatarDirection, tipDirection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return glm::quat();
|
||||||
|
}
|
||||||
|
|
||||||
void MyAvatar::clearReferential() {
|
void MyAvatar::clearReferential() {
|
||||||
changeReferential(NULL);
|
changeReferential(NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,10 +195,12 @@ public slots:
|
||||||
void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }
|
void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }
|
||||||
|
|
||||||
void updateMotionBehavior();
|
void updateMotionBehavior();
|
||||||
|
|
||||||
glm::vec3 getLeftPalmPosition();
|
glm::vec3 getLeftPalmPosition();
|
||||||
|
glm::quat getLeftPalmRotation();
|
||||||
glm::vec3 getRightPalmPosition();
|
glm::vec3 getRightPalmPosition();
|
||||||
|
glm::quat getRightPalmRotation();
|
||||||
|
|
||||||
void clearReferential();
|
void clearReferential();
|
||||||
bool setModelReferential(const QUuid& id);
|
bool setModelReferential(const QUuid& id);
|
||||||
bool setJointReferential(const QUuid& id, int jointIndex);
|
bool setJointReferential(const QUuid& id, int jointIndex);
|
||||||
|
|
Loading…
Reference in a new issue