void Contact::calcSpeed(CursorEventPtr pEvent, CursorEventPtr pOldEvent) { if (pEvent->getSpeed() == glm::vec2(0,0)) { glm::vec2 posDiff = pEvent->getPos() - pOldEvent->getPos(); long long timeDiff = pEvent->getWhen() - pOldEvent->getWhen(); if (timeDiff != 0) { pEvent->setSpeed(posDiff/float(timeDiff)); } } }
void TUIOInputDevice::setEventSpeed(CursorEventPtr pEvent, glm::vec2 speed) { const glm::vec2 size = getTouchArea(); glm::vec2 screenSpeed(int(speed.x*size.x+0.5), int(speed.y*size.y+0.5)); pEvent->setSpeed(screenSpeed/1000.f); }