当前位置: 首页>>代码示例>>C++>>正文


C++ b2World::DrawDebugData方法代码示例

本文整理汇总了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();
}
开发者ID:0x4d52,项目名称:JUCE,代码行数:13,代码来源:juce_Box2DRenderer.cpp

示例2: draw

void DebugDraw::draw()
{
    mWorld->SetDebugDraw(this);
    mWorld->DrawDebugData();
    mWorld->SetDebugDraw(0);
}
开发者ID:ragner,项目名称:quickbox2d,代码行数:6,代码来源:box2ddebugdraw.cpp

示例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 ();

}
开发者ID:rakib-csedu,项目名称:savide,代码行数:101,代码来源:main.cpp


注:本文中的b2World::DrawDebugData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。