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


C++ Polygon2::pad方法代码示例

本文整理汇总了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_);
 }
开发者ID:elemel,项目名称:crust,代码行数:40,代码来源:block_physics_component.cpp


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