本文整理汇总了C++中PathNode::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ PathNode::getPosition方法的具体用法?C++ PathNode::getPosition怎么用?C++ PathNode::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PathNode
的用法示例。
在下文中一共展示了PathNode::getPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findNearestPathNode
PathNode* CollisionManager::findNearestPathNode(TriangleNode* triangle, FloorMesh* floor, const Vector3& finalTarget) {
// this is overkill TODO: find something faster
PathGraph* graph = floor->getPathGraph();
if (graph == NULL)
return NULL;
Vector<PathNode*>* pathNodes = graph->getPathNodes();
PathNode* returnNode = NULL;
float distance = 16000;
Vector3 trianglePos(triangle->getBarycenter());
//trianglePos.set(trianglePos.getX(), trianglePos.getY(), trianglePos.getZ());*/
for (int i = 0; i < pathNodes->size(); ++i) {
PathNode* node = pathNodes->get(i);
TriangleNode* triangleOfPathNode = getTriangle(node->getPosition(), floor);
Vector<Triangle*>* path = TriangulationAStarAlgorithm::search(trianglePos, triangleOfPathNode->getBarycenter(), triangle, triangleOfPathNode);
if (path == NULL)
continue;
else {
delete path;
float sqrDistance = node->getPosition().squaredDistanceTo(finalTarget);
if (sqrDistance < distance) {
distance = sqrDistance;
returnNode = node;
}
}
}
return returnNode;
}
示例2: coord
Vector<WorldCoordinates>* PathFinderManager::findPathFromCellToWorld(const WorldCoordinates& pointA, const WorldCoordinates& pointB, Zone *zone) {
Vector<WorldCoordinates>* path = new Vector<WorldCoordinates>(5, 1);
if (path == NULL)
return NULL;
path->add(pointA);
CellObject* ourCell = pointA.getCell();
ManagedReference<BuildingObject*> building = cast<BuildingObject*>( ourCell->getParent().get().get());
int ourCellID = ourCell->getCellNumber();
SharedObjectTemplate* templateObject = ourCell->getParent().get()->getObjectTemplate();
if (templateObject == NULL) {
delete path;
return NULL;
}
PortalLayout* portalLayout = templateObject->getPortalLayout();
if (portalLayout == NULL) {
delete path;
return NULL;
}
FloorMesh* sourceFloorMesh = portalLayout->getFloorMesh(ourCellID);
if (sourceFloorMesh == NULL) {
delete path;
return NULL;
}
PathGraph* sourcePathGraph = sourceFloorMesh->getPathGraph();
if (sourcePathGraph == NULL) {
delete path;
return NULL;
}
FloorMesh* exteriorFloorMesh = portalLayout->getFloorMesh(0);
if (exteriorFloorMesh == NULL) {
delete path;
return NULL;
}
PathGraph* exteriorPathGraph = exteriorFloorMesh->getPathGraph();
if (exteriorPathGraph == NULL) {
delete path;
return NULL;
}
// we need to move world position into model space
Vector3 transformedPosition = transformToModelSpace(pointB.getPoint(), building);
//find exit node in our cell
//PathNode* exitNode = sourcePathGraph->findNearestNode(pointA.getPoint());
TriangleNode* nearestTargetNodeTriangle = CollisionManager::getTriangle(pointA.getPoint(), sourceFloorMesh);
if (nearestTargetNodeTriangle == NULL) {
delete path;
return NULL;
}
PathNode* exitNode = CollisionManager::findNearestPathNode(nearestTargetNodeTriangle, sourceFloorMesh, transformedPosition);//targetPathGraph->findNearestNode(pointB.getPoint());
if (exitNode == NULL) {
delete path;
return NULL;
}
//find exterior node
PathNode* exteriorNode = exteriorPathGraph->findNearestGlobalNode(transformedPosition);
if (exteriorNode == NULL) {
delete path;
return NULL;
}
//find path to the exit
Vector<PathNode*>* exitPath = portalLayout->getPath(exitNode, exteriorNode);
if (exitPath == NULL) {
error("exitPath == NULL");
delete path;
return NULL;
}
//find triangle path to exitNode
Vector<Triangle*>* trianglePath = NULL;
int res = getFloorPath(pointA.getPoint(), exitNode->getPosition(), sourceFloorMesh, trianglePath);
if (res != -1 && trianglePath != NULL)
addTriangleNodeEdges(pointA.getPoint(), exitNode->getPosition(), trianglePath, path, ourCell);
if (trianglePath != NULL)
delete trianglePath;
//.........这里部分代码省略.........