From 71dfff7c3579c9395c03c1d356cd6535c011660b Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 23 Oct 2015 12:00:40 -0700 Subject: [PATCH] first cut at adding MyAvatar.xxxHandPose --- interface/src/avatar/MyAvatar.cpp | 28 ++++++++++++++++++++++++++++ interface/src/avatar/MyAvatar.h | 20 ++++++++++++++++---- libraries/avatars/src/HandData.h | 1 + 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index d822d37055..6e08ca24cf 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -596,6 +596,34 @@ glm::vec3 MyAvatar::getRightHandTipPosition() const { return palmData ? palmData->getTipPosition() : glm::vec3(0.0f); } +controller::Pose MyAvatar::getLeftHandPose() const { + const int LEFT_HAND = 0; + auto palmData = getActivePalm(LEFT_HAND); + return palmData ? controller::Pose(palmData->getPosition(), palmData->getRotation(), + palmData->getVelocity(), palmData->getRawAngularVelocityAsQuat()) : controller::Pose(); +} + +controller::Pose MyAvatar::getRightHandPose() const { + const int RIGHT_HAND = 1; + auto palmData = getActivePalm(RIGHT_HAND); + return palmData ? controller::Pose(palmData->getPosition(), palmData->getRotation(), + palmData->getVelocity(), palmData->getRawAngularVelocityAsQuat()) : controller::Pose(); +} + +controller::Pose MyAvatar::getLeftHandTipPose() const { + const int LEFT_HAND = 0; + auto palmData = getActivePalm(LEFT_HAND); + return palmData ? controller::Pose(palmData->getTipPosition(), palmData->getRotation(), + palmData->getTipVelocity(), palmData->getRawAngularVelocityAsQuat()) : controller::Pose(); +} + +controller::Pose MyAvatar::getRightHandTipPose() const { + const int RIGHT_HAND = 1; + auto palmData = getActivePalm(RIGHT_HAND); + return palmData ? controller::Pose(palmData->getTipPosition(), palmData->getRotation(), + palmData->getTipVelocity(), palmData->getRawAngularVelocityAsQuat()) : controller::Pose(); +} + // virtual void MyAvatar::render(RenderArgs* renderArgs, const glm::vec3& cameraPosition) { // don't render if we've been asked to disable local rendering diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index c80a855149..0a3d7dedf4 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -16,6 +16,8 @@ #include #include +#include + #include "Avatar.h" #include "AtRestDetector.h" @@ -64,10 +66,15 @@ class MyAvatar : public Avatar { //TODO: make gravity feature work Q_PROPERTY(glm::vec3 gravity READ getGravity WRITE setGravity) - Q_PROPERTY(glm::vec3 leftHandPosition READ getLeftHandPosition) - Q_PROPERTY(glm::vec3 rightHandPosition READ getRightHandPosition) - Q_PROPERTY(glm::vec3 leftHandTipPosition READ getLeftHandTipPosition) - Q_PROPERTY(glm::vec3 rightHandTipPosition READ getRightHandTipPosition) + Q_PROPERTY(glm::vec3 leftHandPosition READ getLeftHandPosition) + Q_PROPERTY(glm::vec3 rightHandPosition READ getRightHandPosition) + Q_PROPERTY(glm::vec3 leftHandTipPosition READ getLeftHandTipPosition) + Q_PROPERTY(glm::vec3 rightHandTipPosition READ getRightHandTipPosition) + + Q_PROPERTY(controller::Pose leftHandPose READ getLeftHandPose) + Q_PROPERTY(controller::Pose rightHandPose READ getRightHandPose) + Q_PROPERTY(controller::Pose leftHandTipPose READ getLeftHandTipPose) + Q_PROPERTY(controller::Pose rightHandTipPose READ getRightHandTipPose) public: MyAvatar(RigPointer rig); @@ -160,6 +167,11 @@ public: Q_INVOKABLE glm::vec3 getLeftHandTipPosition() const; Q_INVOKABLE glm::vec3 getRightHandTipPosition() const; + Q_INVOKABLE controller::Pose getLeftHandPose() const; + Q_INVOKABLE controller::Pose getRightHandPose() const; + Q_INVOKABLE controller::Pose getLeftHandTipPose() const; + Q_INVOKABLE controller::Pose getRightHandTipPose() const; + AvatarWeakPointer getLookAtTargetAvatar() const { return _lookAtTargetAvatar; } void updateLookAtTargetAvatar(); void clearLookAtTargetAvatar(); diff --git a/libraries/avatars/src/HandData.h b/libraries/avatars/src/HandData.h index 7514e38055..7cc9faad3d 100644 --- a/libraries/avatars/src/HandData.h +++ b/libraries/avatars/src/HandData.h @@ -103,6 +103,7 @@ public: const glm::vec3& getRawVelocity() const { return _rawVelocity; } void setRawAngularVelocity(const glm::vec3& angularVelocity) { _rawAngularVelocity = angularVelocity; } const glm::vec3& getRawAngularVelocity() const { return _rawAngularVelocity; } + glm::quat getRawAngularVelocityAsQuat() const { return glm::quat(); } // FIXME void addToPosition(const glm::vec3& delta); void addToPenetration(const glm::vec3& penetration) { _totalPenetration += penetration; }