本文整理汇总了C++中Obstacle::setPolygon方法的典型用法代码示例。如果您正苦于以下问题:C++ Obstacle::setPolygon方法的具体用法?C++ Obstacle::setPolygon怎么用?C++ Obstacle::setPolygon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Obstacle
的用法示例。
在下文中一共展示了Obstacle::setPolygon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetEnvironment
void Playground::SetEnvironment()
{
ClearEnvironment();
countingTimeText = scene.addSimpleText(QString("0"));
countingTimeText->setPos(-100, 100);
srand(numberAgents * numberObstacles);
Obstacle * tempObstacle;
QPolygonF polygon;
int centerX, centerY;
qreal koef = 0.5;
for(int loop1 = 0; loop1 < numberObstacles; loop1++)
{
tempObstacle = new Obstacle();
polygon.clear();
centerX = rand() % 10 * 100 - 25 + rand() % 50;
centerY = rand() % 10 * 100 - 25 + rand() % 50;
int size = 30;
switch(rand() % 3)
{
case 0:
polygon.push_back(QPointF(koef * (centerX - size), koef * (centerY - size)));
polygon.push_back(QPointF(koef * (centerX + size), koef * (centerY - size)));
polygon.push_back(QPointF(koef * (centerX), koef * (centerY + size)));
break;
case 1:
polygon.push_back(QPointF(koef * (centerX - size), koef * (centerY - size)));
polygon.push_back(QPointF(koef * (centerX + size), koef * (centerY)));
polygon.push_back(QPointF(koef * (centerX - size), koef * (centerY + size)));
break;
case 2:
polygon.push_back(QPointF(koef * (centerX - size), koef * (centerY - size)));
polygon.push_back(QPointF(koef * (centerX + size), koef * (centerY - size)));
polygon.push_back(QPointF(koef * (centerX - size), koef * (centerY + size)));
break;
}
tempObstacle->setPolygon(polygon);
obstacle.push_back(tempObstacle);
scene.addItem(tempObstacle);
}
Agent * tempAgent;
PotentialField * tempField;
GoalPoint * tempGoal;
int agentX, agentY;
int agentWidth = 5;
for(int loop1 = 0; loop1 < numberAgents; loop1++)
{
switch(loop1 % 4)
{
case 0 :
agentX = -40;
agentY = rand() % 100 * 5;
break;
case 1 :
agentX = 510;
agentY = rand() % 100 * 5;
break;
case 2 :
agentY = -40;
agentX = rand() % 100 * 5;
break;
case 3 :
agentY = 510;
agentX = rand() % 100 * 5;
break;
}
tempAgent = new Agent(agentX, agentY, agentWidth, agentWidth, 0);
tempAgent->SetGoal(470 - agentX, 470 - agentY);
tempGoal = new GoalPoint(470 - agentX - 5, 470 - agentY - 5, 10, 10, 0);
tempField = new PotentialField(tempAgent, agentX, agentY, 0);
tempAgent->SetField(tempField);
agent.push_back(tempAgent);
scene.addItem(tempAgent);
field.push_back(tempField);
scene.addItem(tempField);
goalPoint.push_back(tempGoal);
scene.addItem(tempGoal);
}
}