本文整理汇总了C++中wfmath::Polygon::shift方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon::shift方法的具体用法?C++ Polygon::shift怎么用?C++ Polygon::shift使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wfmath::Polygon
的用法示例。
在下文中一共展示了Polygon::shift方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shadeArea
void AreaShader::shadeArea(Surface& s, const Area* ar) const
{
WFMath::Polygon<2> clipped = ar->clipToSegment(s.m_segment);
assert(clipped.isValid());
if (clipped.numCorners() == 0) return;
Point2 segOrigin = s.m_segment.getRect().lowCorner();
clipped.shift(Point2(0,0) - segOrigin);
scanConvert(clipped, s);
}
示例2: parseArea
bool TerrainArea::parseArea()
{
if (!mEntity.hasAttr("area")) {
S_LOG_FAILURE("TerrainArea created for entity with no area attribute");
return false;
}
const Atlas::Message::Element areaElem(mEntity.valueOfAttr("area"));
if (!areaElem.isMap()) {
S_LOG_FAILURE("TerrainArea element ('area') must be of map type.");
return false;
}
const Atlas::Message::MapType& areaData(areaElem.asMap());
int layer = 0;
WFMath::Polygon<2> poly;
TerrainAreaParser parser;
if (parser.parseArea(areaData, poly, layer)) {
if (!mArea) {
mArea = new Mercator::Area(layer, false);
} else {
//A bit of an ugly hack here since the Mercator system doesn't support changing the layer. We need to swap the old area for a new one if the layer has changed.
if (mArea->getLayer() != layer) {
mOldArea = mArea;
mArea = new Mercator::Area(layer, false);
}
}
// transform polygon into terrain coords
WFMath::Vector<3> xVec = WFMath::Vector<3>(1.0, 0.0, 0.0).rotate(mEntity.getOrientation());
double theta = atan2(xVec.y(), xVec.x()); // rotation about Z
WFMath::RotMatrix<2> rm;
poly.rotatePoint(rm.rotation(theta), WFMath::Point<2>(0, 0));
poly.shift(WFMath::Vector<2>(mEntity.getPosition().x(), mEntity.getPosition().y()));
mArea->setShape(poly);
return true;
} else {
return false;
}
}
示例3: placeArea
bool TerrainArea::placeArea(WFMath::Polygon<2>& poly)
{
//If the position if invalid we can't do anything with the area yet.
if (!mEntity.getPosition().isValid()) {
return false;
}
// transform polygon into terrain coords
if (mEntity.getOrientation().isValid()) {
WFMath::Vector<3> xVec = WFMath::Vector<3>(1.0, 0.0, 0.0).rotate(mEntity.getOrientation());
double theta = atan2(xVec.y(), xVec.x()); // rotation about Z
WFMath::RotMatrix<2> rm;
poly.rotatePoint(rm.rotation(theta), WFMath::Point<2>(0, 0));
}
poly.shift(WFMath::Vector<2>(mEntity.getPosition().x(), mEntity.getPosition().y()));
return true;
}