17 #include "GLMHelpers.h"
18 #include "StreamUtils.h"
21 using GrabPointer = std::shared_ptr<Grab>;
22 using GrabWeakPointer = std::weak_ptr<Grab>;
24 class GrabLocationAccumulator {
26 void accumulate(glm::vec3 position, glm::quat orientation) {
27 _position += position;
28 _orientation = orientation;
32 glm::vec3 finalizePosition() {
return _count > 0 ? _position * (1.0f / _count) : glm::vec3(0.0f); }
33 glm::quat finalizeOrientation() {
return _orientation; }
37 glm::quat _orientation;
44 Grab(
const QUuid& newOwnerID,
const QUuid& newTargetID,
int newParentJointIndex,
const QString& newHand,
45 glm::vec3 newPositionalOffset, glm::quat newRotationalOffset) :
47 _targetID(newTargetID),
48 _parentJointIndex(newParentJointIndex),
50 _positionalOffset(newPositionalOffset),
51 _rotationalOffset(newRotationalOffset),
54 QByteArray toByteArray();
55 bool fromByteArray(
const QByteArray& grabData);
57 Grab& operator=(
const GrabPointer& other) {
58 _ownerID = other->_ownerID;
59 _targetID = other->_targetID;
60 _parentJointIndex = other->_parentJointIndex;
62 _positionalOffset = other->_positionalOffset;
63 _rotationalOffset = other->_rotationalOffset;
64 _actionID = other->_actionID;
65 _released = other->_released;
69 QUuid getActionID()
const {
return _actionID; }
70 void setActionID(
const QUuid& actionID) { _actionID = actionID; }
72 QUuid getOwnerID()
const {
return _ownerID; }
73 void setOwnerID(QUuid ownerID) { _ownerID = ownerID; }
75 QUuid getTargetID()
const {
return _targetID; }
76 void setTargetID(QUuid targetID) { _targetID = targetID; }
78 int getParentJointIndex()
const {
return _parentJointIndex; }
79 void setParentJointIndex(
int parentJointIndex) { _parentJointIndex = parentJointIndex; }
81 QString getHand()
const {
return _hand; }
82 void setHand(QString hand) { _hand = hand; }
84 glm::vec3 getPositionalOffset()
const {
return _positionalOffset; }
85 void setPositionalOffset(glm::vec3 positionalOffset) { _positionalOffset = positionalOffset; }
87 glm::quat getRotationalOffset()
const {
return _rotationalOffset; }
88 void setRotationalOffset(glm::quat rotationalOffset) { _rotationalOffset = rotationalOffset; }
90 bool getReleased()
const {
return _released; }
91 void setReleased(
bool value) { _released = value; }
97 int _parentJointIndex { -1 };
99 glm::vec3 _positionalOffset;
100 glm::quat _rotationalOffset;
101 bool _released {
false };