Adding palm accessor method that fetches left or right, as specified.

This commit is contained in:
Andrew Meadows 2014-01-14 16:08:40 -08:00
parent 038f8d5777
commit f28fc5f79b
2 changed files with 13 additions and 0 deletions

View file

@ -41,6 +41,18 @@ PalmData& HandData::addNewPalm() {
const int SIXENSE_CONTROLLER_ID_LEFT_HAND = 0;
const int SIXENSE_CONTROLLER_ID_RIGHT_HAND = 1;
const PalmData* HandData::getPalm(int sixSenseID) const {
// the palms are not necessarily added in left-right order,
// so we have to search for the right SixSenseID
for (int i = 0; i < _palms.size(); i++) {
const PalmData* palm = &(_palms[i]);
if (palm->getSixenseID() == sixSenseID) {
return palm->isActive() ? palm : NULL;
}
}
return NULL;
}
void HandData::getLeftRightPalmIndices(int& leftPalmIndex, int& rightPalmIndex) const {
leftPalmIndex = -1;
rightPalmIndex = -1;

View file

@ -55,6 +55,7 @@ public:
std::vector<PalmData>& getPalms() { return _palms; }
const std::vector<PalmData>& getPalms() const { return _palms; }
const PalmData* getPalm(int sixSenseID) const;
size_t getNumPalms() const { return _palms.size(); }
PalmData& addNewPalm();