本文整理汇总了C++中TuioTime::getTotalMilliseconds方法的典型用法代码示例。如果您正苦于以下问题:C++ TuioTime::getTotalMilliseconds方法的具体用法?C++ TuioTime::getTotalMilliseconds怎么用?C++ TuioTime::getTotalMilliseconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TuioTime
的用法示例。
在下文中一共展示了TuioTime::getTotalMilliseconds方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void TuioContainer::update (TuioTime ttime, float xp, float yp) {
lastPoint = &path.back();
TuioPoint::update(ttime,xp, yp);
TuioTime diffTime = currentTime - lastPoint->getTuioTime();
float dt = diffTime.getTotalMilliseconds()/1000.0f;
float dx = xpos - lastPoint->getX();
float dy = ypos - lastPoint->getY();
float dist = sqrt(dx*dx+dy*dy);
float last_motion_speed = motion_speed;
float last_x_speed = x_speed;
float last_y_speed = y_speed;
x_speed = dx/dt;
y_speed = dy/dt;
motion_speed = dist/dt;
motion_accel = (motion_speed - last_motion_speed)/dt;
x_accel = (x_speed - last_x_speed)/dt;
y_accel = (y_speed - last_y_speed)/dt;
TuioPoint p(currentTime,xpos,ypos);
path.push_back(p);
if (path.size()>MAX_PATH_SIZE) path.pop_front();
if (motion_accel>0) state = TUIO_ACCELERATING;
else if (motion_accel<0) state = TUIO_DECELERATING;
else state = TUIO_STOPPED;
}
示例2: predictPosition
TuioPoint TuioContainer::predictPosition() {
/*if (path.size()>1) {
std::list<TuioPoint>::iterator iter = path.end();
std::advance(iter, -2);
TuioTime diffTime = currentTime - (*iter).getTuioTime();
float dt = diffTime.getTotalMilliseconds()/1000.0f;
float tx = x_speed * dt;
float ty = y_speed * dt;
float nx = xpos+tx-tx*x_accel*dt;
float ny = ypos+ty-ty*y_accel*dt;
//if (xposFilter && yposFilter) {
// nx = xposFilter->filter(nx,dt);
// ny = yposFilter->filter(ny,dt);
// //std::cout << dt << " " << xp << " " << xpos << " " << yp << " " << ypos << std::endl;
//}
//std::cout << nx << " " << ny << std::endl;
return TuioPoint(nx,ny);
} else return TuioPoint(xpos,ypos);*/
TuioTime diffTime = currentTime - lastPoint->getTuioTime();
float dt = diffTime.getTotalMilliseconds()/1000.0f;
float tx = x_speed * dt;
float ty = y_speed * dt;
float nx = xpos+tx-tx*x_accel*dt;
float ny = ypos+ty-ty*y_accel*dt;
//if (xposFilter && yposFilter) {
// nx = xposFilter->filter(nx,dt);
// ny = yposFilter->filter(ny,dt);
// //std::cout << dt << " " << xp << " " << xpos << " " << yp << " " << ypos << std::endl;
//}
//std::cout << nx << " " << ny << std::endl;
return TuioPoint(nx,ny);
}
示例3: update
void TuioBlob::update (TuioTime ttime, float xp, float yp, float a, float w, float h, float f) {
TuioPoint lastPoint = path.back();
TuioContainer::update(ttime,xp,yp);
TuioTime diffTime = currentTime - lastPoint.getTuioTime();
float dt = diffTime.getTotalMilliseconds()/1000.0f;
float last_rotation_speed = rotation_speed;
float prev_angle = angle_sum;
float da = a-angle;
if (da > M_PI/2.0f) angle_sum += (da-2*M_PI);
else if (da < M_PI/-2.0f) angle_sum += (da+2*M_PI);
else angle_sum += da;
if (angleFilter) angle_sum = angleFilter->filter(angle_sum,dt);
if (fabs(angle_sum-prev_angle)<angleThreshold) angle_sum = prev_angle;
int m = floor(angle_sum/(2*M_PI));
angle = angle_sum-(m*(2*M_PI));
da = (angle-a)/(2*M_PI);
if (da > 0.75f) da-=1.0f;
else if (da < -0.75f) da+=1.0f;
if (widthFilter && heightFilter) {
w = widthFilter->filter(w,dt);
h = heightFilter->filter(h,dt);
}
float dw = fabs(width - w);
float dh = fabs(height - h);
if ((dw>sizeThreshold) || (dh>sizeThreshold)) {
width = w;
height = h;
}
area = f;
rotation_speed = (float)da/dt;
rotation_accel = (rotation_speed - last_rotation_speed)/dt;
if ((rotation_accel!=0) && (state==TUIO_STOPPED)) state = TUIO_ROTATING;
}
示例4: update
void TuioObject::update (TuioTime ttime, float xp, float yp, float a) {
TuioPoint lastPoint = path.back();
TuioContainer::update(ttime,xp,yp);
TuioTime diffTime = currentTime - lastPoint.getTuioTime();
float dt = diffTime.getTotalMilliseconds()/1000.0f;
float last_angle = angle;
float last_rotation_speed = rotation_speed;
angle = a;
double da = (angle-last_angle)/(2*M_PI);
if (da > 0.75f) da-=1.0f;
else if (da < -0.75f) da+=1.0f;
rotation_speed = (float)da/dt;
rotation_accel = (rotation_speed - last_rotation_speed)/dt;
if ((rotation_accel!=0) && (state==TUIO_STOPPED)) state = TUIO_ROTATING;
}
示例5: refresh
void IupTuioListener::refresh(TuioTime frameTime)
{
if (this->changed)
{
Ihandle* ih_canvas = IupGetAttributeHandle(this->ih, "TARGETCANVAS");
if (!ih_canvas)
ih_canvas = this->ih;
this->changed = 0;
IFniiis cb = (IFniiis)IupGetCallback(ih_canvas, "TOUCH_CB");
IFniIIII mcb = (IFniIIII)IupGetCallback(ih_canvas, "MULTITOUCH_CB");
if (cb || mcb)
{
this->client->lockCursorList();
this->locked = 1;
}
if (this->debug)
printf("IupTuioClient-RefreshChanged(time=%d)\n", (int)frameTime.getTotalMilliseconds());
}
}
示例6:
void Tuio2Dump::tuioRefresh(TuioTime frameTime) {
std::cout << "refresh " << frameTime.getFrameID() << " "<< frameTime.getTotalMilliseconds() << std::endl;
std::cout << std::flush;
}