本文整理汇总了C++中ControlPoint::getDuration方法的典型用法代码示例。如果您正苦于以下问题:C++ ControlPoint::getDuration方法的具体用法?C++ ControlPoint::getDuration怎么用?C++ ControlPoint::getDuration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControlPoint
的用法示例。
在下文中一共展示了ControlPoint::getDuration方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
//--------------------------------------------------------------
void testApp::update(){
float elapsed = (ofGetElapsedTimef() - startTime);
switch (status) {
case VISIBLE:
break;
case FORWARD:
if (elapsed > maxDuration) {
vector<ofVec3f> verts = mesh.getVertices();
for (vector<ofVec3f>::iterator it=verts.begin(); it!=verts.end(); ++it) {
it->x = clickedPosition.x;
it->y = clickedPosition.y;
}
status = INVISIBLE;
break;
}
for (int y=0; y<rows; ++y) {
for (int x=0; x<cols; ++x) {
for (int i=0; i<6; ++i) {
int index = 6*(y*cols+x) + i;
ControlPoint p = controlPoints[index];
float easedValue = easingForward(ofClamp(elapsed / p.getDuration(), 0.0, 1.0));
ofVec3f v;
v.x = p.x + easedValue*(clickedPosition.x - p.x);
v.y = p.y + easedValue*(clickedPosition.y - p.y);
v.z = 0;
mesh.setVertex(index, v);
}
}
}
break;
case INVISIBLE:
break;
case BACKWARD:
if (elapsed > maxDuration) {
vector<ofVec3f> verts = mesh.getVertices();
for(int i=0; i<verts.size(); ++i) {
verts[i].x = controlPoints[i].x;
verts[i].y = controlPoints[i].y;
}
status = VISIBLE;
break;
}
for (int y=0; y<rows; ++y) {
for (int x=0; x<cols; ++x) {
for (int i=0; i<6; ++i) {
int index = 6*(y*cols+x) + i;
ControlPoint p = controlPoints[index];
float easedValue = easingBackward(ofClamp(elapsed / p.getDuration(), 0.0, 1.0));
ofVec3f v;
v.x = clickedPosition.x + easedValue*(p.x - clickedPosition.x);
v.y = clickedPosition.y + easedValue*(p.y - clickedPosition.y);
v.z = 0;
mesh.setVertex(index, v);
}
}
}
break;
}
}