本文整理汇总了C++中b2World::DrawDebugData方法的典型用法代码示例。如果您正苦于以下问题:C++ b2World::DrawDebugData方法的具体用法?C++ b2World::DrawDebugData怎么用?C++ b2World::DrawDebugData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类b2World
的用法示例。
在下文中一共展示了b2World::DrawDebugData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Box2DRenderer::render (Graphics& g, b2World& world,
float left, float top, float right, float bottom,
const Rectangle<float>& target)
{
graphics = &g;
g.addTransform (AffineTransform::fromTargetPoints (left, top, target.getX(), target.getY(),
right, top, target.getRight(), target.getY(),
left, bottom, target.getX(), target.getBottom()));
world.SetDebugDraw (this);
world.DrawDebugData();
}
示例2: draw
void DebugDraw::draw()
{
mWorld->SetDebugDraw(this);
mWorld->DrawDebugData();
mWorld->SetDebugDraw(0);
}
示例3: Render
//.........这里部分代码省略.........
glEnd ();
}
}
turnToDestination();
turnToNearestAngle ();
agent->isCollision = 0;
// checking collision here, not so important now
for (int i = 1; i < 15; ++i)
{
float x = 20 + (i * 2) * sinf (agent->angle + 1.57) ;
float y = 20 + (i * 2) * cosf (agent->angle + 1.57);
if (x < 40 && y < 40)
if (carCollisionMap[ (int) y][ (int) x] == 1)
{
// printf ("obstacle found\n");
agent->isCollision = 1;
static float timerT = glutGet (GLUT_ELAPSED_TIME);
bool safe = 1;
safe = rand () % 2;
if (!agent->frontObstacle)
if (agent->nearestAngle[LEFT_SIDE] != 1000 || agent->nearestAngle[RIGHT_SIDE] != 1000)
{
// if (glutGet (GLUT_ELAPSED_TIME) - timerT > 500)
{
if (agent->nearestAngle[LEFT_SIDE] < agent->nearestAngle[RIGHT_SIDE])
{
printf ("Left side wins %f\n", agent->nearestAngle[LEFT_SIDE]);
agent->angle = agent->angle - .2;
agent->foundNearestAngle = true;
// agent->nearestAngle[RIGHT_SIDE] = 1000;
}
else
{
printf ("Right side wins %f\n", agent->nearestAngle[RIGHT_SIDE]);
agent->foundNearestAngle = true;
// agent->nearestAngle[LEFT_SIDE] = 1000;
agent->angle = agent->angle + .2;
}
timerT = glutGet (GLUT_ELAPSED_TIME);
}
}
// if (glutGet (GLUT_ELAPSED_TIME) - timerT > 1000)
// {
//
// if (safe == 1)
// for (int j = 0; j < 10; ++j)
// {
// float x = 20 + ( (j ) * sinf (agent->angle + 1.57 + .3) ) ;
// float y = 20 + ( (j ) * cosf (agent->angle + 1.57 + .3) ) ;
//
// if (carCollisionMap[ (int) y][ (int) x] == 1)
// {
// safe = 0;
// break;
// }
// }
// if (safe == 1)
// { agent->angle = agent->angle + .3; }
// {
// memset (carCollisionMap, 0, sizeof (carCollisionMap) );
// }
// if (safe == 0)
// {
// safe = 1;
// for (int j = 0; j < 10; ++j)
// {
// float x = 20 + ( (j ) * sinf (agent->angle + 1.57 - .3) ) ;
// float y = 20 + ( (j ) * cosf (agent->angle + 1.57 - .3) ) ;
// if (carCollisionMap[ (int) y][ (int) x] == 1)
// {
// safe = 0;
// break;
// }
// }
// if (safe == 1)
// {
// agent->angle = agent->angle - .3;
// memset (carCollisionMap, 0, sizeof (carCollisionMap) );
// }
// }
// timerT = glutGet (GLUT_ELAPSED_TIME);
// }
}
}
agent->moveForward ();
SetRenderColor (0, 0, 0, 255);
RenderBitmapText (60, 550, GLUT_BITMAP_9_BY_15, "ctrl + left click to add obstacle, alt + left click to add a destination");
sprintf (fps, "%f", GetFps () );
SetRenderColor (255, 0, 255, 255);
RenderBitmapText (10, 590, GLUT_BITMAP_9_BY_15, fps);
myWorld.DrawDebugData ();
}