Store hand position relative to body orientation/position.

This commit is contained in:
Andrzej Kapolka 2014-01-20 12:44:09 -08:00
parent 520f7a78a8
commit 81ab68a529
5 changed files with 14 additions and 8 deletions

View file

@ -124,10 +124,6 @@ glm::vec3 Avatar::getChestPosition() const {
return _skeletonModel.getNeckPosition(neckPosition) ? (_position + neckPosition) * 0.5f : _position;
}
glm::quat Avatar::getOrientation() const {
return glm::quat(glm::radians(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll)));
}
glm::quat Avatar::getWorldAlignedOrientation () const {
return computeRotationFromBodyToWorldUp() * getOrientation();
}

View file

@ -92,7 +92,6 @@ public:
const glm::vec3& getVelocity() const { return _velocity; }
Head& getHead() { return _head; }
Hand& getHand() { return _hand; }
glm::quat getOrientation() const;
glm::quat getWorldAlignedOrientation() const;
bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance) const;

View file

@ -44,6 +44,15 @@ AvatarData::~AvatarData() {
delete _handData;
}
glm::vec3 AvatarData::getHandPosition() const {
return getOrientation() * _handPosition + _position;
}
void AvatarData::setHandPosition(const glm::vec3& handPosition) {
// store relative to position/orientation
_handPosition = glm::inverse(getOrientation()) * (handPosition - _position);
}
int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
unsigned char* bufferStart = destinationBuffer;

View file

@ -76,8 +76,8 @@ public:
const glm::vec3& getPosition() const { return _position; }
void setPosition(const glm::vec3 position) { _position = position; }
const glm::vec3& getHandPosition() const { return _handPosition; }
void setHandPosition(const glm::vec3 handPosition) { _handPosition = handPosition; }
glm::vec3 getHandPosition() const;
void setHandPosition(const glm::vec3& handPosition);
int getBroadcastData(unsigned char* destinationBuffer);
int parseData(unsigned char* sourceBuffer, int numBytes);
@ -93,6 +93,8 @@ public:
float getBodyRoll() const { return _bodyRoll; }
void setBodyRoll(float bodyRoll) { _bodyRoll = bodyRoll; }
glm::quat getOrientation() const { return glm::quat(glm::radians(glm::vec3(_bodyPitch, _bodyYaw, _bodyRoll))); }
// Scale
float getTargetScale() const { return _targetScale; }
void setTargetScale(float targetScale) { _targetScale = targetScale; }

View file

@ -20,7 +20,7 @@ PACKET_VERSION versionForPacketType(PACKET_TYPE type) {
return 2;
case PACKET_TYPE_HEAD_DATA:
return 14;
return 15;
case PACKET_TYPE_AVATAR_URLS:
return 2;