void HandData::updateFingerTrails() { for (size_t i = 0; i < getNumPalms(); ++i) { PalmData& palm = getPalms()[i]; for (size_t f = 0; f < palm.getNumFingers(); ++f) { FingerData& finger = palm.getFingers()[f]; finger.updateTrail(); } } }
void HandData::setFingerTrailLength(unsigned int length) { for (size_t i = 0; i < getNumPalms(); ++i) { PalmData& palm = getPalms()[i]; for (size_t f = 0; f < palm.getNumFingers(); ++f) { FingerData& finger = palm.getFingers()[f]; finger.setTrailLength(length); } } }
void HandData::decodeRemoteData(const std::vector<glm::vec3>& fingerVectors) { size_t vectorIndex = 0; for (size_t i = 0; i < getNumPalms(); ++i) { PalmData& palm = getPalms()[i]; // If a palm is active, there will be // 1 vector for its position // 1 vector for normal // 10 vectors for fingers (5 tip/root pairs) bool palmActive = fingerVectors.size() >= i * 12; palm.setActive(palmActive); if (palmActive) { palm.setRawPosition(fingerVectors[vectorIndex++]); palm.setRawNormal(fingerVectors[vectorIndex++]); for (size_t f = 0; f < NUM_FINGERS_PER_HAND; ++f) { FingerData& finger = palm.getFingers()[f]; finger.setActive(true); finger.setRawTipPosition(fingerVectors[vectorIndex++]); finger.setRawRootPosition(fingerVectors[vectorIndex++]); } } } }
void HandData::encodeRemoteData(std::vector<glm::vec3>& fingerVectors) { fingerVectors.clear(); for (size_t i = 0; i < getNumPalms(); ++i) { PalmData& palm = getPalms()[i]; if (!palm.isActive()) { continue; } fingerVectors.push_back(palm.getRawPosition()); fingerVectors.push_back(palm.getRawNormal()); for (size_t f = 0; f < palm.getNumFingers(); ++f) { FingerData& finger = palm.getFingers()[f]; if (finger.isActive()) { fingerVectors.push_back(finger.getTipRawPosition()); fingerVectors.push_back(finger.getRootRawPosition()); } else { fingerVectors.push_back(glm::vec3(0,0,0)); fingerVectors.push_back(glm::vec3(0,0,0)); } } } }