本文整理汇总了C++中PathPoint::getFirstID方法的典型用法代码示例。如果您正苦于以下问题:C++ PathPoint::getFirstID方法的具体用法?C++ PathPoint::getFirstID怎么用?C++ PathPoint::getFirstID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathPoint
的用法示例。
在下文中一共展示了PathPoint::getFirstID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
PathPoint Path::update(Vector3<float> refPos, Vector3<float> playerPos)
{
float D_val;
PathPoint current = getCurrent();
PathPoint previous = getPrevious();
float diffX = refPos.x - current.getPosition().x;
float diffY = refPos.y - current.getPosition().y;
float diffZ = refPos.z - current.getPosition().z;
float playerDistFromPlane = 0;
float firstDistFromPlane = 0;
Vector3<float> vect1 (current.getPosition().x - previous.getPosition().x,
current.getPosition().y - previous.getPosition().y,
current.getPosition().z - previous.getPosition().z);
Vector3<float> vect2 (current.getPosition().x + current.getUp().x,
current.getPosition().y + current.getUp().y,
current.getPosition().z + current.getUp().z);
Vector3<float> normal;
float distance = sqrt(diffX * diffX + diffY * diffY + diffZ * diffZ);
PathPoint firstChoice = getAt(current.getFirstID());
if (distance < RANGE_CHECK) {
if (current.getNumberOfIDs() == 1) {
setChoice(current.getFirstID());
return getCurrent();
}
normal = vect1.Cross(vect2).Normalized();
D_val = (current.getPosition().x * normal.x + current.getPosition().y
* normal.y + current.getPosition().z * normal.z) * -1.0f;
playerDistFromPlane = (normal.x * playerPos.x) +
(normal.y * playerPos.y) + (normal.z * playerPos.z) + D_val;
if (abs(playerDistFromPlane) < MID_BUFFER_WIDTH &&
current.getNumberOfIDs() == 3) {
setChoice(current.getThirdID());
return getCurrent();
}
firstDistFromPlane = normal.x * firstChoice.getPosition().x
+ normal.y * firstChoice.getPosition().y
+ normal.z * firstChoice.getPosition().z + D_val;
if (playerDistFromPlane / abs(playerDistFromPlane) ==
firstDistFromPlane / abs(firstDistFromPlane)) {
setChoice(current.getFirstID());
return getCurrent();
}
else {
setChoice(current.getSecondID());
return getCurrent();
}
}
return getCurrent();
}