本文整理汇总了C++中ogre::Vector3::directionEquals方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector3::directionEquals方法的具体用法?C++ Vector3::directionEquals怎么用?C++ Vector3::directionEquals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Vector3
的用法示例。
在下文中一共展示了Vector3::directionEquals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slidingPlane
Ogre::Vector3
CharacterController::_collideWithWorld(int recursionDepth,
const Ogre::Vector3& pos, const Ogre::Vector3& vel,
CollisionPacket& colData, bool gravityStep,
const Ogre::Degree& slopeSlideThresold)
{
// do we need to worry?
if (recursionDepth > 5)
return pos;
// Ok, we need to worry:
colData.velocity = vel;
colData.normalizedVelocity = vel;
colData.normalizedVelocity.normalise();
colData.basePoint = pos;
colData.foundCollision = false;
// ----------------------------
// OgreOpcode part begin
_doOgreOpcodeCollision(colData, mVeryCloseDistance);
// OgreOpcode part end
// ----------------------------
// If no collision we just move along the velocity
if (colData.foundCollision == false)
{
return pos + vel;
}
// *** Collision occured ***
// The original destination point
Ogre::Vector3 destinationPoint = pos + vel;
Ogre::Vector3 newBasePoint = pos;
// only update if we are not already very close
// and if so we only move very close to intersection..not
// to the exact spot.
if (colData.nearestDistance >= mVeryCloseDistance)
{
Ogre::Vector3 V = vel;
V.normalise();
V = V * (colData.nearestDistance - mVeryCloseDistance);
newBasePoint = colData.basePoint + V;
// Adjust polygon intersection point (so sliding
// plane will be unaffected by the fact that we
// move slightly less than collision tells us)
V.normalise();
colData.intersectionPoint -= mVeryCloseDistance * V;
}
// Determine the sliding plane
Ogre::Vector3 slidePlaneOrigin = colData.intersectionPoint;
Ogre::Vector3 slidePlaneNormal = newBasePoint - colData.intersectionPoint;
slidePlaneNormal.normalise();
Ogre::Plane slidingPlane(slidePlaneNormal, slidePlaneOrigin);
Ogre::Vector3 newDestinationPoint = destinationPoint
- slidingPlane.getDistance(destinationPoint) * slidePlaneNormal;
// Generate the slide vector, which will become our new
// velocity vector for the next iteration
Ogre::Vector3 newVelocityVector = newDestinationPoint
- colData.intersectionPoint;
// Recurse:
// dont recurse if the new velocity is very small
if (newVelocityVector.length() < mVeryCloseDistance)
{
return newBasePoint;
}
// simulate "friction"
if (gravityStep)
{
// apply gravity only if slope is steep enough
const Ogre::Radian tolerance = Ogre::Radian(slopeSlideThresold);
Ogre::Vector3 gravity = vel;
gravity.normalise();
if (slidePlaneNormal.directionEquals(-gravity, tolerance))
{
return newBasePoint;
}
}
return _collideWithWorld(recursionDepth++, newBasePoint, newVelocityVector,
colData, gravityStep, slopeSlideThresold);
}
开发者ID:PlumInTheLateAfternoonShade,项目名称:ember_gsoc_2013_test,代码行数:87,代码来源:OgreOpcodeCharacterController.cpp