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


C++ btVector3::lerp方法代码示例

本文整理汇总了C++中btVector3::lerp方法的典型用法代码示例。如果您正苦于以下问题:C++ btVector3::lerp方法的具体用法?C++ btVector3::lerp怎么用?C++ btVector3::lerp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在btVector3的用法示例。


在下文中一共展示了btVector3::lerp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: stepDown

btVector3 btKinematicCharacterController::stepDown( btCollisionWorld* collisionWorld, const btVector3& currentPosition, btScalar currentStepOffset )
{
    btVector3 stepDrop = getUpAxisDirections()[ m_upAxis ] * currentStepOffset;

    // Be sure we are falling from the last m_currentPosition
    // It prevents some flickering
    //
    btVector3 targetPosition = currentPosition - stepDrop;

    //if the no collisions mode is on, no need to go any further
    if(!mCollision) return targetPosition;

    btTransform start;
    start.setIdentity();
    start.setOrigin( currentPosition );

    btTransform end;
    end.setIdentity();
    end.setOrigin( targetPosition );

    btKinematicClosestNotMeConvexResultCallback callback( internalGhostObject, getUpAxisDirections()[ m_upAxis ], m_maxSlopeCosine );
    callback.m_collisionFilterGroup = internalGhostObject->getBroadphaseHandle()->m_collisionFilterGroup;
    callback.m_collisionFilterMask = internalGhostObject->getBroadphaseHandle()->m_collisionFilterMask;

    // Retrieve the collision shape
    //
    btCollisionShape* collisionShape = internalGhostObject->getCollisionShape();
    btAssert( collisionShape->isConvex() );
    btConvexShape* convexShape = ( btConvexShape* )collisionShape;

    if( m_useGhostObjectSweepTest )
        externalGhostObject->convexSweepTest( convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration );

    else
        collisionWorld->convexSweepTest( convexShape, start, end, callback, collisionWorld->getDispatchInfo().m_allowedCcdPenetration );

    if( callback.hasHit() )
    {
        m_verticalVelocity = btScalar( 0.0 );
        m_verticalOffset = btScalar( 0.0 );
        m_wasJumping = false;

        // We dropped a fraction of the height -> hit floor
        //
        return currentPosition.lerp( targetPosition, callback.m_closestHitFraction );
    }
    else

        // We dropped the full height
        //
        return targetPosition;
}
开发者ID:Adrian-Revk,项目名称:openmw,代码行数:52,代码来源:btKinematicCharacterController.cpp

示例2: smearAllBonesToDefault

/* PMDModel::smearAllBonesToDefault: smear all bone pos/rot into default value (rate 1.0 = keep, rate 0.0 = reset) */
void PMDModel::smearAllBonesToDefault(float rate)
{
   unsigned short i;
   const btVector3 v(0.0f, 0.0f, 0.0f);
   const btQuaternion q(0.0f, 0.0f, 0.0f, 1.0f);
   btVector3 tmpv;
   btQuaternion tmpq;

   for (i = 0; i < m_numBone; i++) {
      m_boneList[i].getCurrentPosition(&tmpv);
      tmpv = v.lerp(tmpv, rate);
      m_boneList[i].setCurrentPosition(&tmpv);
      m_boneList[i].getCurrentRotation(&tmpq);
      tmpq = q.slerp(tmpq, rate);
      m_boneList[i].setCurrentRotation(&tmpq);
   }
   for (i = 0; i < m_numFace; i++) {
      m_faceList[i].setWeight(m_faceList[i].getWeight() * rate);
   }
}
开发者ID:shirayukikitsune,项目名称:xbeat,代码行数:21,代码来源:PMDModel_update.cpp

示例3: stepUp

btVector3 btKinematicCharacterController::stepUp( btCollisionWorld* world, const btVector3& currentPosition, btScalar& currentStepOffset )
{
    btVector3 targetPosition = currentPosition + getUpAxisDirections()[ m_upAxis ] * ( m_stepHeight + ( m_verticalOffset > btScalar( 0.0 ) ? m_verticalOffset : 0.0 ) );

    //if the no collisions mode is on, no need to go any further
    if(!mCollision)
    {
        currentStepOffset = m_stepHeight;
        return targetPosition;
    }

    // Retrieve the collision shape
    //
    btCollisionShape* collisionShape = externalGhostObject->getCollisionShape();
    btAssert( collisionShape->isConvex() );

    btConvexShape* convexShape = ( btConvexShape* )collisionShape;

    // FIXME: Handle penetration properly
    //
    btTransform start;
    start.setIdentity();
    start.setOrigin( currentPosition + getUpAxisDirections()[ m_upAxis ] * ( convexShape->getMargin() ) );

    btTransform end;
    end.setIdentity();
    end.setOrigin( targetPosition );

    btKinematicClosestNotMeConvexResultCallback callback( externalGhostObject, -getUpAxisDirections()[ m_upAxis ], m_maxSlopeCosine );
    callback.m_collisionFilterGroup = externalGhostObject->getBroadphaseHandle()->m_collisionFilterGroup;
    callback.m_collisionFilterMask = externalGhostObject->getBroadphaseHandle()->m_collisionFilterMask;

    // Sweep test
    //
    if( m_useGhostObjectSweepTest )
        externalGhostObject->convexSweepTest( convexShape, start, end, callback, world->getDispatchInfo().m_allowedCcdPenetration );

    else
        world->convexSweepTest( convexShape, start, end, callback );

    if( callback.hasHit() )
    {
        // Only modify the position if the hit was a slope and not a wall or ceiling.
        //
        if( callback.m_hitNormalWorld.dot(getUpAxisDirections()[m_upAxis]) > btScalar( 0.0 ) )
        {
            // We moved up only a fraction of the step height
            //
            currentStepOffset = m_stepHeight * callback.m_closestHitFraction;

            return currentPosition.lerp( targetPosition, callback.m_closestHitFraction );
        }

        m_verticalVelocity = btScalar( 0.0 );
        m_verticalOffset = btScalar( 0.0 );

        return currentPosition;
    }
    else
    {
        currentStepOffset = m_stepHeight;
        return targetPosition;
    }
}
开发者ID:Adrian-Revk,项目名称:openmw,代码行数:64,代码来源:btKinematicCharacterController.cpp


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