本文整理汇总了C++中PointArray::count方法的典型用法代码示例。如果您正苦于以下问题:C++ PointArray::count方法的具体用法?C++ PointArray::count怎么用?C++ PointArray::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointArray
的用法示例。
在下文中一共展示了PointArray::count方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: curve
PointArray<256> CurveFitter::curve(const PointArray<256> &curvePoints, int count)
{
PointArray<256> points;
points.resize(count);
curve(curvePoints.count(), curvePoints.data(), count, points.data());
return points;
}
示例2: reverse
CatmullRomBy* CatmullRomBy::reverse() const
{
PointArray *copyConfig = _points->clone();
//
// convert "absolutes" to "diffs"
//
Vector2 p = copyConfig->getControlPointAtIndex(0);
for (ssize_t i = 1; i < copyConfig->count(); ++i)
{
Vector2 current = copyConfig->getControlPointAtIndex(i);
Vector2 diff = current - p;
copyConfig->replaceControlPoint(diff, i);
p = current;
}
// convert to "diffs" to "reverse absolute"
PointArray *reverse = copyConfig->reverse();
// 1st element (which should be 0,0) should be here too
p = reverse->getControlPointAtIndex(reverse->count()-1);
reverse->removeControlPointAtIndex(reverse->count()-1);
p = -p;
reverse->insertControlPoint(p, 0);
for (ssize_t i = 1; i < reverse->count(); ++i)
{
Vector2 current = reverse->getControlPointAtIndex(i);
current = -current;
Vector2 abs = current + p;
reverse->replaceControlPoint(abs, i);
p = abs;
}
return CatmullRomBy::create(_duration, reverse);
}
示例3: reverse
CardinalSplineBy* CardinalSplineBy::reverse() const
{
PointArray *copyConfig = _points->clone();
//
// convert "absolutes" to "diffs"
//
Point p = copyConfig->getControlPointAtIndex(0);
for (unsigned int i = 1; i < copyConfig->count(); ++i)
{
Point current = copyConfig->getControlPointAtIndex(i);
Point diff = current - p;
copyConfig->replaceControlPoint(diff, i);
p = current;
}
// convert to "diffs" to "reverse absolute"
PointArray *pReverse = copyConfig->reverse();
// 1st element (which should be 0,0) should be here too
p = pReverse->getControlPointAtIndex(pReverse->count()-1);
pReverse->removeControlPointAtIndex(pReverse->count()-1);
p = -p;
pReverse->insertControlPoint(p, 0);
for (unsigned int i = 1; i < pReverse->count(); ++i)
{
Point current = pReverse->getControlPointAtIndex(i);
current = -current;
Point abs = current + p;
pReverse->replaceControlPoint(abs, i);
p = abs;
}
return CardinalSplineBy::create(_duration, pReverse, _tension);
}
示例4: flushPoints
void flushPoints()
{
if (pointArray.count() == 0)
return;
SimpleColorShader &shader = shState->shaders().simpleColor;
shader.bind();
shader.setTranslation(Vec2i());
bindFBO();
pushSetViewport(shader);
glState.blendMode.pushSet(BlendNone);
pointArray.commit();
pointArray.draw();
pointArray.reset();
glState.blendMode.pop();
popViewport();
}
示例5: actionDone
void HelloWorld::actionDone(Node *pSender){
int newTarget = _mapInfo->getRandomMapIdByType(MapInfoType::Road);
int oldTarget = _mapInfo->convertPointToId(pSender->getPosition());
MapPath* pMathPath = _mapInfo->getMapPath(oldTarget, newTarget);
PointArray *pointArr = pMathPath->getPointArr();
float duration = 0.2 * pointArr->count();
EaseWalkTo *easeWalkTo1 = EaseWalkTo::create(duration, pointArr);
Sequence *seq = Sequence::create(
easeWalkTo1,
CallFuncN::create(CC_CALLBACK_1(HelloWorld::actionDone,this)),
NULL
);
pSender->runAction(seq);
}
示例6: findPath
void AStarPathHelper::findPath(AStarPathUnit * originUnit, AStarPathUnit * destUnit)
{
if (originUnit->isEqual(destUnit))
return;
insertOpenVecByOrder(originUnit);
do
{
AStarPathUnit* curUnit = _openVec.at(0);
// 先添加到closeVec,再从openVec中移除
_closeVec.pushBack(curUnit);
_openVec.erase(0);
// 判断是否到达目的地
if (curUnit->isEqual(destUnit))
{
_isFound = true;
// 将找到的路径添加到pathVec中
do
{
_pathVec.insert(0, curUnit);
curUnit = curUnit->getParent();
} while (curUnit->getParent() != nullptr);
break;
}
PointArray* arr = checkFourDirection(curUnit);
for (int i = 0; i < arr->count(); ++i)
{
AStarPathUnit* nextUnit = AStarPathUnit::createWithTileCoord(arr->getControlPointAtIndex(i));
// 如果nextUnit已经在关闭列表中,跳过
if (-1 != getIndexInVec(nextUnit, _closeVec))
continue;
int index = getIndexInVec(nextUnit, _openVec);
// index等于-1, 表示nextUnit不在开启列表中
if (-1 == index)
{
nextUnit->setParent(curUnit);
nextUnit->setGScore(curUnit->getGScore() + curUnit->costMoveToAdjacentUnit());
nextUnit->setHScore(nextUnit->computHScoreFromThisUnitToDestUnit(destUnit));
// 按F值的大小顺序添加进开启列表
insertOpenVecByOrder(nextUnit);
}
else
{
nextUnit = _openVec.at(index);
int newGSocre = curUnit->getGScore() + curUnit->costMoveToAdjacentUnit();
// 如果当前路径得到的G值小于从openVec中得到的该路径G值
if (newGSocre < nextUnit->getGScore())
{
nextUnit->setParent(curUnit);
nextUnit->setGScore(newGSocre);
// nextUnit的G值改变后导致F值改变,其在openVec中的顺序需要设置
nextUnit->retain();
_openVec.erase(index);
insertOpenVecByOrder(nextUnit);
nextUnit->release();
}
}
}
} while (!_openVec.empty());
}
示例7: moveTowardTarget
//This is the function for A-star pathfinding and moving
void FloatingSprite::moveTowardTarget(const Point &target)
{
if(!_HelloLayer){
return;
}
//Stop current movint action and start a new pathfinding
this->stopActionByTag(TAG_FOR_MOVING);
Point fromTileCoord = _HelloLayer->getTileCoordForPosition(this->getPosition());
Point toTileCoord = _HelloLayer->getTileCoordForPosition(target);
if(fromTileCoord == toTileCoord){
log("It's already there");
return;
}
if((_HelloLayer->isBlockageTile(toTileCoord)) || !(_HelloLayer->isValidTile(toTileCoord))){
log("Target [%f,%f] is unaccessible",toTileCoord.x, toTileCoord.y);
return;
}
log("From: %f, %f", fromTileCoord.x, fromTileCoord.y);
log("To: %f, %f", toTileCoord.x, toTileCoord.y);
_OpenSteps.clear();
_ClosedSteps.clear();
_FoundPathSteps.clear();
//Add current position(start position)
this->insertInOpenSteps(PathStep::createWithPosition(fromTileCoord));
do{
//1. get the top step in open steps array, push it to close steps array, then check the step
PathStep* currentStep = _OpenSteps.at(0);
_ClosedSteps.pushBack(currentStep);
_OpenSteps.erase(0);
//current step is the target to move, finished
//log("%s",currentStep->getDescription().c_str());
if(currentStep->getPosition() == toTileCoord){
PathStep* tmpStep = currentStep;
log("Path found");
//Got the path, start moving to the target point
buildFoundedPathSteps(tmpStep);
moveStepByStep();
_OpenSteps.clear();
_ClosedSteps.clear();
break;
}
//Check all adjacent tiles, put it into open steps array according to the F score
PointArray* adjSteps = _HelloLayer->accessibleTilesAdjacentToTileCoord(currentStep->getPosition());
for(ssize_t i = 0; i < adjSteps->count(); i++){
PathStep* step = PathStep::createWithPosition(adjSteps->getControlPointAtIndex(i));
//log("%s",step->getDescription().c_str());
if(this->getStepIndex(_ClosedSteps,step) != -1){
//the step is already in the closed steps, ignore
continue;
}
int moveCost = this->calcCostFromStepToAdjacent(currentStep, step);
ssize_t openIndex = this->getStepIndex(_OpenSteps, step);
if(openIndex == -1){
//this step is not in the open steps array, calc scores and put it into the array
step->setParent(currentStep);
step->setGScore(currentStep->getGScore() + moveCost);
step->setHScore(this->calcHScoreFromCoordToCoord(step->getPosition(), toTileCoord));
this->insertInOpenSteps(step);
}else{
step = _OpenSteps.at(openIndex);
//this step is already in the open steps array ,recalc scores and refine the score and parent
if((currentStep->getGScore() + moveCost) < step->getGScore()){
//Fix me: why not set parent?
step->setParent(currentStep);
step->setGScore(currentStep->getGScore() + moveCost);
step->retain();
_OpenSteps.erase(openIndex);
this->insertInOpenSteps(step);
step->release();
}
}
}
}while(_OpenSteps.size() > 0);
if(_FoundPathSteps.empty()){
log("Cannot find a path to the destination");
}
}