本文整理汇总了C++中DebugDraw类的典型用法代码示例。如果您正苦于以下问题:C++ DebugDraw类的具体用法?C++ DebugDraw怎么用?C++ DebugDraw使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DebugDraw类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ToRenderUnits
void OverlayTask::Update()
{
for (auto it = m_Selected.begin(), end = m_Selected.end(); it != end; ++it)
{
const auto& entity = *it;
auto pos = entity->GetPosition();
pos.x = ToRenderUnits(pos.x), pos.y = ToRenderUnits(pos.y);
pos += m_Offset;
clan::Rectf box(clan::Sizef(50, 50));
box.translate(pos.x - box.get_width() * 0.5f, pos.y - box.get_height() * 0.5f);
m_DebugDraw.DrawRectangle(box, GetColour(it));
}
if (m_EditCam)
{
clan::Colorf rangeColour(1.0f, 0.6f, 0.6f, 0.95f);
auto center = m_EditCam->GetPosition();
auto radius = ToRenderUnits(m_CamRange);
clan::Rectf camRect(center.x - radius, center.y - radius, center.x + radius, center.y + radius);
m_DebugDraw.DrawRectangle(camRect, rangeColour);
}
if (m_PolygonTool && m_PolygonTool->IsActive())
m_PolygonTool->Draw();
if (m_RectangleTool && m_RectangleTool->IsActive())
m_RectangleTool->Draw();
if (m_CircleTool && m_CircleTool->IsActive())
m_CircleTool->Draw();
}
示例2: engine
GinsengSandbox::GinsengSandbox(Engine *engine) : engine(engine)
{
ModulePtr sensorModule(new Module());
utility::add_class<FootSensor>(*sensorModule,
"FootSensor",
{ },
{ {fun(&FootSensor::OnGround), "OnGround"} }
);
engine->chai->add(sensorModule);
accumulator = 0.f;
sf::Vector2u wSize = engine->window.getSize();
gridView.reset(sf::FloatRect(wSize.x / -2.f, wSize.y / -2.f, wSize.x, wSize.y));
PhysicsWorld physicsWorld(b2Vec2(0.f, -9.81f * 8), 1.f / 60.f, 8, 3);
physicsWorld.World->SetContactListener(new ContactListener());
DebugDraw* debugDraw = new DebugDraw(engine->window, 64.f);
debugDraw->SetFlags(b2Draw::e_shapeBit);
physicsWorld.World->SetDebugDraw(debugDraw);
db.makeComponent(db.makeEntity(), physicsWorld);
loadLevel("data/scripts/level/test.json");
EntID player = db.makeEntity();
db.makeComponent(player, DynamicBody(physicsWorld, 4.f, 0.9f, 1.f , 1.8f));
db.makeComponent(player, FootSensor(player.get<DynamicBody>().data().Body));
db.makeComponent(player, AIComponent{PlayerAI(player)});
engine->chai->add(var(player.get<FootSensor>().data()), "foot");
}
示例3: Update
void SelectionDrawerTask::Update()
{
if (!fe_fzero(m_SelectionBox.get_width()) || !fe_fzero(m_SelectionBox.get_height()))
{
auto fillC = clan::Colorf::aquamarine;
fillC.set_alpha(0.20f);
m_DebugDraw.DrawRectangle(m_SelectionBox, clan::Colorf::white);
m_DebugDraw.DrawSolidRectangle(m_SelectionBox, fillC);
}
}
示例4: Arrow
void Arrow(ArrowSelection as, int dir, float angle, float scale, float offset2)
{
DebugDraw dbgDraw;
glPushMatrix();
glTranslatef(settings.viewCenter.x + (extents.x - arrowOffset + arrowScale - offset2) * dir, settings.viewCenter.y, 0);
glRotatef(angle, 0, 0, 1);
glScalef(arrowScale * scale, arrowScale * scale, 1);
dbgDraw.DrawArrow(lMouseDown && whichArrow == as ? arrowActiveColor : arrowPassiveColor);
glPopMatrix();
}
示例5: main
void main()
{
auto &window = Window::instance();
auto &input = Input::instance();
auto &time = Time::instance();
window.init();
input.init();
time.init();
Asset::instance().loadTexture("Ship", "../textures/sprite.png");
//Factory::makeBall({ 40, 40 }, {10,10}, 400, 40)->rigidbody->addTorque(1000);
// Factory::makeBall({ 80, 200 }, { 100,0}, 120, 120);
//auto e = Factory::makeBall({ 720, 200 }, { }, 60, 1);
Factory::makePlayer({ 400,350 });
DebugDraw debugDraw;
RigidbodyDynamics rigidbodies;
LifetimeSystem lifetimes;
CollisionDetection collisioner;
DynamicResolution dynamic;
PlayerFlightSystem flightsystem;
RenderSystem render;
while (window.step())
{
input.step();
time.step();
flightsystem.step();
rigidbodies.step();
lifetimes.step();
collisioner.step();
dynamic.step();
render.step();
debugDraw.step();
}
time.term();
input.term();
window.term();
}
示例6: LoadImages
// Load your images here
void LoadImages ()
{
myWorld.SetDebugDraw (&draw);
draw.SetFlags ( DebugDraw::e_shapeBit | DebugDraw::e_aabbBit |
DebugDraw::e_jointBit | DebugDraw::e_centerOfMassBit | DebugDraw::e_pairBit);
glutTimerFunc (1000 / 100.0, Update, 1);
glutTimerFunc (2000 / 1000, Clear, 1);
}
示例7: b2Vec2
// Draw a colored arrow rotated by angle, scaled by scale and at
// the viewport relative position using DebugDraw.
// With no transformation matrix applied, the arrow is drawn in box
// area (3.5f, 3.5f) (see Arrow::k_size) and the overall bounding box
// of the arrow is (-1.75f, -1.75f) to (1.75f, 1.75f).
void Arrow::DrawArrow(const b2Color &color, const float32 angle,
const float32 scale, const b2Vec2 &position)
{
static const b2Vec2 square[] =
{
b2Vec2(0.25f, 1.0f), b2Vec2(0.25f, -1.0f),
b2Vec2(-1.75f, -1.0f), b2Vec2(-1.75f, 1.0f)
};
static const b2Vec2 triangle[] =
{
b2Vec2(0.25f, 1.75f), b2Vec2(1.75f, 0.0f),
b2Vec2(0.25f, -1.75f)
};
// Build the transformation matrix.
glPushMatrix();
glTranslatef(position.x, position.y, 0.0f);
glRotatef(angle, 0.0f, 0.0f, 1.0f);
glScalef(scale, scale, 1.0f);
// Draw the arrow.
DebugDraw dbgDraw;
dbgDraw.DrawFlatPolygon(square, B2_ARRAY_SIZE(square), color);
dbgDraw.DrawFlatPolygon(triangle, B2_ARRAY_SIZE(triangle), color);
glPopMatrix();
}
示例8: DrawFixture
//Rotina que chama os métodos de desenho da classe DebugDraw para desenhar os objetos da cena
void DrawFixture(b2Fixture* fixture, b2Color color)
{
const b2Transform& xf = fixture->GetBody()->GetTransform();
switch (fixture->GetType())
{
case b2Shape::e_circle:
{
b2CircleShape* circle = (b2CircleShape*)fixture->GetShape();
b2Vec2 center = b2Mul(xf, circle->m_p);
float32 radius = circle->m_radius;
renderer.DrawCircle(center, radius, color);
}
break;
case b2Shape::e_polygon:
{
b2PolygonShape* poly = (b2PolygonShape*)fixture->GetShape();
int32 vertexCount = poly->m_count;
b2Assert(vertexCount <= b2_maxPolygonVertices);
b2Vec2 vertices[b2_maxPolygonVertices];
for (int32 i = 0; i < vertexCount; ++i)
{
vertices[i] = b2Mul(xf, poly->m_vertices[i]);
}
renderer.DrawPolygon(vertices, vertexCount, color);
}
break;
case b2Shape::e_edge:
{
b2EdgeShape* edge = (b2EdgeShape*)fixture->GetShape();
int32 vertexCount;
b2Vec2 vertices[b2_maxPolygonVertices];
int i=0;
if (edge->m_hasVertex0)
{
vertices[i] = b2Mul(xf, edge->m_vertex0);
i++;
}
vertices[i] = b2Mul(xf, edge->m_vertex1); i++;
vertices[i] = b2Mul(xf, edge->m_vertex2); i++;
if (edge->m_hasVertex3)
{
vertices[i] = b2Mul(xf, edge->m_vertex3);
i++;
}
vertexCount = i;
renderer.DrawPolygon(vertices, vertexCount, color);
}
break;
}
}
示例9: DrawShape
//Rotina que chama os métodos de desenho da classe DebugDraw para desenhar os objetos da cena
void DrawShape(b2Fixture* fixture, b2Color color)
{
const b2Transform& xf = fixture->GetBody()->GetTransform();
switch (fixture->GetType())
{
case b2Shape::e_circle:
{
b2CircleShape* circle = (b2CircleShape*)fixture->GetShape();
b2Vec2 center = b2Mul(xf, circle->m_p);
float32 radius = circle->m_radius;
b2Vec2 axis = b2Mul(xf.q, b2Vec2(1.0f, 0.0f));
float angle = xf.q.GetAngle();
renderer.DrawSolidCircle(center, radius, axis, color);
DrawSprite((radius*1.44)*2,center.x,center.y,0.0,RadianosParaGraus(angle)); //este 1.44 foi um cálculo q eu fiz para encaixar... o ideal é que o circulo tenha o raio da imagem
}
break;
case b2Shape::e_polygon:
{
b2PolygonShape* poly = (b2PolygonShape*)fixture->GetShape();
int32 vertexCount = poly->m_count;
b2Assert(vertexCount <= b2_maxPolygonVertices);
b2Vec2 vertices[b2_maxPolygonVertices];
for (int32 i = 0; i < vertexCount; ++i)
{
vertices[i] = b2Mul(xf, poly->m_vertices[i]);
}
renderer.DrawPolygon(vertices, vertexCount, color);
}
break;
case b2Shape::e_edge:
{
b2EdgeShape* edge = (b2EdgeShape*)fixture->GetShape();
int32 vertexCount;
b2Vec2 vertices[b2_maxPolygonVertices];
int i=0;
if (edge->m_hasVertex0)
{
vertices[i] = b2Mul(xf, edge->m_vertex0);
i++;
}
vertices[i] = b2Mul(xf, edge->m_vertex1); i++;
vertices[i] = b2Mul(xf, edge->m_vertex2); i++;
if (edge->m_hasVertex3)
{
vertices[i] = b2Mul(xf, edge->m_vertex3);
i++;
}
vertexCount = i;
renderer.DrawPolygon(vertices, vertexCount, color);
}
break;
case b2Shape::e_chain:
{
b2ChainShape* chain = (b2ChainShape*)fixture->GetShape();
int32 count = chain->m_count;
const b2Vec2* vertices = chain->m_vertices;
b2Vec2 v1 = b2Mul(xf, vertices[0]);
for (int32 i = 1; i < count; ++i)
{
b2Vec2 v2 = b2Mul(xf, vertices[i]);
renderer.DrawSegment(v1, v2, color);
renderer.DrawCircle(v1, 0.05f, color);
v1 = v2;
}
}
break;
}
}
示例10: DebugDrawDir
void DebugDrawDir(DebugDraw &draw, const core::math::Vec4 &start, const core::math::Vec4 &dir, const core::math::Color &color) {
const Color color1(color.r(), color.g(), color.b(), 0);
const Color color2(color.r(), color.g(), color.b(), 255);
draw.addLine(start, start + dir, color1, color2);
}
示例11: DebugDraw
DebugDraw* DebugDraw::create()
{
DebugDraw* draw = new DebugDraw();
draw->autorelease();
return draw;
}
示例12: DebugDrawMatrix
void DebugDrawMatrix(DebugDraw &draw, const core::math::Matrix44 &mat) {
draw.addLine(mat.pos() + mat.left() * 0.5f, mat.pos() - mat.left() * 0.5f, Color(255, 0, 0, 255), Color(64, 0, 0, 255));
draw.addLine(mat.pos() + mat.up() * 0.5f, mat.pos() - mat.up() * 0.5f, Color(0, 255, 0, 255), Color(0, 64, 0, 255));
draw.addLine(mat.pos() + mat.at() * 0.5f, mat.pos() - mat.at() * 0.5f, Color(0, 0, 255, 255), Color(0, 0, 64, 255));
}
示例13: glViewport
void Game::Setup(void){
sf::WindowSettings s = this->app->GetSettings();
s.DepthBits = 24;
s.StencilBits = 8;
s.AntialiasingLevel = 4;
this->app->PreserveOpenGLStates(true);
this->app->SetFramerateLimit(60);
glViewport(0,0,800,600);
glEnable(GL_TEXTURE_RECTANGLE_EXT);
glDisable( GL_LIGHTING );
/* glDisable(GL_DITHER); */
glDepthFunc(GL_LESS);
glEnable(GL_DEPTH_TEST);
// Setup a perspective projection
glMatrixMode(GL_PROJECTION);
glAlphaFunc(GL_GREATER, 0.5);
glEnable(GL_ALPHA_TEST);
glOrtho(0, 800, 600, 0, -100, 100);
// Setup a perspective projection
glMatrixMode(GL_MODELVIEW);
// Displacement trick for exact pixelization
glTranslatef(0.375, 0.375, 0);
/* glTranslatef(0, 0, -5); */
// Box2D initialization
b2Vec2 gravity(0, 9.8f);
b2World *w = Utils::GetWorld();
w = new b2World(gravity);
w->SetContinuousPhysics(true);
this->world = w;
Utils::SetWorld(w);
// Ground definition
b2BodyDef groundBodyDef;
groundBodyDef.position.Set(0.0f / RATIO / 2, 0.0f / RATIO / 2);
b2Body *groundBody = w->CreateBody(&groundBodyDef);
b2EdgeShape groundEdge;
b2FixtureDef boxShapeDef;
boxShapeDef.shape = &groundEdge;
groundEdge.Set(b2Vec2(0.0f, 600.0f / RATIO), b2Vec2(800.0f / RATIO, 600.0f / RATIO));
/* b2PolygonShape groundBox; */
/* groundBox.SetAsBox(800.0f / RATIO / 2, 600.0f / RATIO / 2); */
/* groundBody->CreateFixture(&groundBox, 1.0f); */
groundBody->CreateFixture(&boxShapeDef);
// DebugDraw initialization
if (DEBUG_DRAW) {
DebugDraw *debug = new DebugDraw();
this->world->SetDebugDraw(debug);
uint32 flags = 0;
flags += 1 * b2Draw::e_shapeBit;
flags += 1 * b2Draw::e_jointBit;
/* flags += 1 * b2Draw::e_aabbBit; */
flags += 1 * b2Draw::e_pairBit;
flags += 1 * b2Draw::e_centerOfMassBit;
debug->SetFlags(flags);
}
}
示例14: DebugDrawPoint
void DebugDrawPoint(DebugDraw &draw, const core::math::Vec4 &point) {
const Color white(255, 255, 255, 255);
draw.addLine(point + core::math::G_UpVector * 0.5f, point - core::math::G_UpVector * 0.5f, white, white);
draw.addLine(point + core::math::G_LeftVector * 0.5f, point - core::math::G_LeftVector * 0.5f, white, white);
draw.addLine(point + core::math::G_AtVector * 0.5f, point - core::math::G_AtVector * 0.5f, white, white);
}
示例15: DrawJoint
void DrawJoint( b2Joint *joint, b2Color color)
{
b2Vec2 anchor1, anchor2;
anchor1 = joint->GetAnchorA();
anchor2 = joint->GetAnchorB();
glPointSize(5);
glBegin(GL_POINTS);
glVertex2f(anchor1.x,anchor1.y);
glVertex2f(anchor2.x,anchor2.y);
glEnd();
glPointSize(1);
renderer.DrawSegment(anchor1, anchor2, color);
}