mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +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::quat palmRotation;
|
||||
if (_hand == "right") {
|
||||
palmPosition = myAvatar->getRightPalmPosition();
|
||||
palmRotation = myAvatar->getRightPalmRotation();
|
||||
} else {
|
||||
palmPosition = myAvatar->getLeftPalmPosition();
|
||||
palmRotation = myAvatar->getLeftPalmRotation();
|
||||
}
|
||||
|
||||
auto rotation = myAvatar->getWorldAlignedOrientation();
|
||||
auto offset = rotation * _relativePosition;
|
||||
auto position = palmPosition + offset;
|
||||
rotation *= palmRotation;
|
||||
rotation *= _relativeRotation;
|
||||
unlock();
|
||||
|
||||
|
|
|
@ -371,6 +371,19 @@ glm::vec3 MyAvatar::getLeftPalmPosition() {
|
|||
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 rightHandPosition;
|
||||
getSkeletonModel().getRightHandPosition(rightHandPosition);
|
||||
|
@ -380,6 +393,19 @@ glm::vec3 MyAvatar::getRightPalmPosition() {
|
|||
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() {
|
||||
changeReferential(NULL);
|
||||
}
|
||||
|
|
|
@ -195,10 +195,12 @@ public slots:
|
|||
void setThrust(glm::vec3 newThrust) { _thrust = newThrust; }
|
||||
|
||||
void updateMotionBehavior();
|
||||
|
||||
|
||||
glm::vec3 getLeftPalmPosition();
|
||||
glm::quat getLeftPalmRotation();
|
||||
glm::vec3 getRightPalmPosition();
|
||||
|
||||
glm::quat getRightPalmRotation();
|
||||
|
||||
void clearReferential();
|
||||
bool setModelReferential(const QUuid& id);
|
||||
bool setJointReferential(const QUuid& id, int jointIndex);
|
||||
|
|
Loading…
Reference in a new issue