本文整理汇总了C++中Duration::seconds方法的典型用法代码示例。如果您正苦于以下问题:C++ Duration::seconds方法的具体用法?C++ Duration::seconds怎么用?C++ Duration::seconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Duration
的用法示例。
在下文中一共展示了Duration::seconds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tick
void Camera::tick(const Time& t, const Duration& dt) {
if (!haveGoal()) return;
Vector3d goalPos = getGoalPosition();
Quaternion goalOrient = getGoalOrientation();
Vector3d pos;
Quaternion orient;
if (mMode == FirstPerson) {
// In first person mode we are tied tightly to the position of
// the object.
pos = goalPos;
orient = goalOrient;
}
else {
// In third person mode, the target is offset so we'll be behind and
// above ourselves and we need to interpolate to the target.
// Offset the goal.
BoundingSphere3f following_bounds = getGoalBounds();
goalPos += Vector3d(following_bounds.center());
// > 1 factor gets us beyond the top of the object
goalPos += mOffset * (following_bounds.radius());
// Restore the current values from the scene node.
pos = fromOgre(mSceneNode->getPosition(), mScene->getOffset());
orient = fromOgre(mSceneNode->getOrientation());
// And interpolate.
Vector3d toGoal = goalPos-pos;
double toGoalLen = toGoal.length();
if (toGoalLen < 1e-06) {
pos = goalPos;
orient = goalOrient;
} else {
double step = exp(-dt.seconds()*2.f);
pos = goalPos - (toGoal/toGoalLen)*(toGoalLen*step);
orient = (goalOrient*(1.f-step) + orient*step).normal();
}
}
mSceneNode->setPosition(toOgre(pos, mScene->getOffset()));
mSceneNode->setOrientation(toOgre(orient));
}