本文整理汇总了C++中PointPath::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ PointPath::push_back方法的具体用法?C++ PointPath::push_back怎么用?C++ PointPath::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointPath
的用法示例。
在下文中一共展示了PointPath::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeSpline
bool NavigationMesh::makeSpline(PointPath& path) {
if( path.size() < 2 )
return false;
PointPath::iterator p0, p1, p2, p3;
p0 = p1 = path.begin();
++p1;
Ogre::Vector3 pextra = *p0 - ((*p1 - *p0).normalise() * 0.5);
path.push_front(pextra);
p0 = p1 = path.end();
--p1;
--p0;
--p0;
pextra = *p1 + ((*p1 - *p0).normalise() * 0.5);
path.push_back(pextra);
int dotsPerUnit = 2;
p0 = path.begin();
p1 = p0;
++p1;
p2 = p1;
++p2;
p3 = p2;
++p3;
while( p3 != path.end() ){
int n = (*p1 - *p2).length() * dotsPerUnit;
Ogre::Real step = 1.0/n;
Ogre::Real s = step;
for(int i = 1; i < n; ++i) {
path.insert(p2, CatmullRollSpline(*p0, *p1, *p2, *p3, s));
s += step;
}
p0 = p1;
p1 = p2;
++p2;
++p3;
}
path.pop_front();
path.pop_back();
return true;
}
示例2: buildPath
bool NavigationMesh::buildPath(PointPath& path,
const Ogre::Vector3& startPos,
const Ogre::Vector3& endPos,
Cell* startCell,
Cell* endCell) {
if (!startCell)
startCell = findCell(startPos);
if (!endCell)
endCell = findCell(endPos);
if (!startCell || !endCell) {
cout << "Celdas no pertenecen a la rejilla" << endl;
return false;
}
int startId = startCell->getId();
int endId = endCell->getId();
if (_graph[startId * _cellNumber + endId] == Ogre::Math::POS_INFINITY) {
cout << "No se ha encontrado camino" << endl;
return false;
}
CellPath cellPath;
recoverPath(startId, endId, cellPath);
path.clear();
for(CellPath::iterator i = cellPath.begin(); i != cellPath.end(); ++i)
path.push_back((*i)->getCenter());
path.push_front(startPos);
path.push_back(endPos);
makeSpline(path);
return true;
}