当前位置: 首页>>代码示例>>C++>>正文


C++ Duration::seconds方法代码示例

本文整理汇总了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));
}
开发者ID:khoshino,项目名称:sirikata,代码行数:42,代码来源:Camera.cpp


注:本文中的Duration::seconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。