本文整理汇总了C++中Polygon2::pad方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon2::pad方法的具体用法?C++ Polygon2::pad怎么用?C++ Polygon2::pad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon2
的用法示例。
在下文中一共展示了Polygon2::pad方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
void BlockPhysicsComponent::create()
{
Vector2 centroid = polygon_.getCentroid();
float angle = -M_PI + 2.0f * M_PI * actor_->getGame()->getRandomFloat();
b2BodyDef bodyDef;
bodyDef.position.Set(centroid.x, centroid.y);
bodyDef.angle = angle;
bodyDef.userData = actor_;
body_ = physicsManager_->getWorld()->CreateBody(&bodyDef);
b2Vec2 vertices[b2_maxPolygonVertices];
int32 vertexCount = std::min(int32(polygon_.vertices.size()),
b2_maxPolygonVertices);
for (int32 i = 0; i < vertexCount; ++i) {
b2Vec2 vertex(polygon_.vertices[i].x, polygon_.vertices[i].y);
vertices[i] = body_->GetLocalPoint(vertex);
localPolygon_.vertices.push_back(Vector2(vertices[i].x, vertices[i].y));
}
b2PolygonShape shape;
shape.Set(vertices, vertexCount);
b2FixtureDef fixtureDef;
fixtureDef.shape = &shape;
fixtureDef.density = 2.5f;
fixtureDef.filter.groupIndex = -1;
body_->CreateFixture(&fixtureDef);
Polygon2 innerPolygon = polygon_;
innerPolygon.pad(-0.15f);
for (int32 i = 0; i < vertexCount; ++i) {
b2Vec2 vertex(innerPolygon.vertices[i].x, innerPolygon.vertices[i].y);
vertices[i] = body_->GetLocalPoint(vertex);
}
b2PolygonShape innerShape;
innerShape.Set(vertices, vertexCount);
body_->CreateFixture(&innerShape, 0.0f);
rasterize(polygon_);
}