本文整理汇总了C++中Sector::getProjectionToPuckVector方法的典型用法代码示例。如果您正苦于以下问题:C++ Sector::getProjectionToPuckVector方法的具体用法?C++ Sector::getProjectionToPuckVector怎么用?C++ Sector::getProjectionToPuckVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sector
的用法示例。
在下文中一共展示了Sector::getProjectionToPuckVector方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSimplePuckVector
Math::Vector3d Actor::getPuckVector() const {
Math::Vector3d forwardVec = getSimplePuckVector();
Set * currSet = g_grim->getCurrSet();
if (!currSet)
return forwardVec;
Sector *sector = currSet->findPointSector(_pos, Sector::WalkType);
if (!sector)
return forwardVec;
else
return sector->getProjectionToPuckVector(forwardVec);
}
示例2: walkForward
void Actor::walkForward() {
float dist = g_grim->getPerSecond(_walkRate);
// Limit the amount of the movement per frame, otherwise with low fps
// scripts that use WalkActorForward and proximity may break.
if ((dist > 0 && dist > _walkRate / 5.f) || (dist < 0 && dist < _walkRate / 5.f))
dist = _walkRate / 5.f;
_walking = false;
if (! _constrain) {
Math::Vector3d forwardVec(-_moveYaw.getSine() * _pitch.getCosine(),
_moveYaw.getCosine() * _pitch.getCosine(), _pitch.getSine());
// EMI: Y is up-down, sectors use an X-Z plane for movement
if (g_grim->getGameType() == GType_MONKEY4) {
float temp = forwardVec.z();
forwardVec.z() = forwardVec.y();
forwardVec.y() = temp;
}
_pos += forwardVec * dist;
_walkedCur = true;
return;
}
bool backwards = false;
if (dist < 0) {
dist = -dist;
backwards = true;
}
int tries = 0;
while (dist > 0.0f) {
Math::Vector3d forwardVec(-_moveYaw.getSine() * _pitch.getCosine(),
_moveYaw.getCosine() * _pitch.getCosine(), _pitch.getSine());
// EMI: Y is up-down, sectors use an X-Z plane for movement
if (g_grim->getGameType() == GType_MONKEY4) {
float temp = forwardVec.z();
forwardVec.z() = forwardVec.y();
forwardVec.y() = temp;
}
if (backwards)
forwardVec = -forwardVec;
Sector *currSector = NULL, *prevSector = NULL, *startSector = NULL;
Sector::ExitInfo ei;
g_grim->getCurrSet()->findClosestSector(_pos, &currSector, &_pos);
if (!currSector) { // Shouldn't happen...
moveTo(_pos + forwardVec * dist);
_walkedCur = true;
return;
}
startSector = currSector;
float oldDist = dist;
while (currSector) {
prevSector = currSector;
Math::Vector3d puckVec = currSector->getProjectionToPuckVector(forwardVec);
puckVec /= puckVec.getMagnitude();
currSector->getExitInfo(_pos, puckVec, &ei);
float exitDist = (ei.exitPoint - _pos).getMagnitude();
if (dist < exitDist) {
moveTo(_pos + puckVec * dist);
_walkedCur = true;
return;
}
_pos = ei.exitPoint;
dist -= exitDist;
if (exitDist > 0.0001)
_walkedCur = true;
// Check for an adjacent sector which can continue
// the path
currSector = g_grim->getCurrSet()->findPointSector(ei.exitPoint + (float)0.0001 * puckVec, Sector::WalkType);
// EMI: some sectors are significantly higher/lower than others.
if (currSector && g_grim->getGameType() == GType_MONKEY4) {
float planeDist = currSector->distanceToPoint(_pos);
if (fabs(planeDist) < 1.f)
_pos -= planeDist * currSector->getNormal();
}
if (currSector == prevSector || currSector == startSector)
break;
}
int turnDir = 1;
if (ei.angleWithEdge > 90) {
ei.angleWithEdge = 180 - ei.angleWithEdge;
ei.edgeDir = -ei.edgeDir;
turnDir = -1;
}
if (ei.angleWithEdge > _reflectionAngle)
return;
ei.angleWithEdge += (float)1.0f;
turnTo(0, _moveYaw + ei.angleWithEdge * turnDir, 0);
//.........这里部分代码省略.........