本文整理汇总了C++中osg::Vec2::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec2::set方法的具体用法?C++ Vec2::set怎么用?C++ Vec2::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Vec2
的用法示例。
在下文中一共展示了Vec2::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
osg::Vec2 CityModel::findCollisionEdge(std::vector<osg::Vec2> &points, std::vector<osg::Vec2> &checks, osg::Vec2 &resultVector)
{
osg::Vec2 direction1, direction2;
if (points.size() == 1)
{
int i=0;
for (; i < 4; i++)
{
if (points.front() == checks[i])
break;
}
direction1 = checks[(i + 1) % 4] - checks[i];
direction2 = checks[posMod(i - 1,4)] - checks[i];
// insert same again, to apply 2nd direction later
points.push_back(points.front());
}
else if (points.size() == 2)
for (int i = 0; i < 4; i++)
if (contains(points, checks[i]) && contains(points, checks[(i + 1) % 4]))
{
direction1 = checks[posMod(i - 1, 4)] - checks[i];
direction2 = checks[(i + 2) % 4] - checks[(i + 1) % 4];
break;
}
else if (points.size() == 3)
for (int i = 0; i < 4; i++)
if (!contains(points, checks[i]))
{
direction1 = checks[posMod(i - 1, 4)] - checks[i];
direction2 = checks[(i + 2) % 4] - checks[(i + 1) % 4];
break;
}
direction1.normalize();
direction2.normalize();
osg::Vec2 pix1 = worldToPixelIndex(points[0]);
osg::Vec2 pix2 = worldToPixelIndex(points[1]);
osg::Vec2 p1 = pixelToWorld( findBorder(pix1, direction1) );
osg::Vec2 p2 = pixelToWorld( findBorder(pix2, direction2) );
if (debugging)
{
std::vector<osg::Vec2> redPoints{ findBorder(pix1, direction1), findBorder(pix2, direction2) };
std::vector<osg::Vec2> markPoints2{ worldToPixelIndex(checks[0]),
worldToPixelIndex(checks[1]),
worldToPixelIndex(checks[2]),
worldToPixelIndex(checks[3])
};
writeDebugImage(pix1.x(), pix1.y(), &redPoints, &markPoints2);
resultVector.set((p2 - p1).x(), (p2 - p1).y());
std::cout << "[CityModel] resultVector" << resultVector.x() << " " << resultVector.y() << std::endl;
while (1);
}
//resultNormal.set(osg::Vec3(p2-p1,0)^osg::Vec3(0,0,1));
resultVector.set((p2 - p1).x(),(p2-p1).y());
//center
return (p2 + p1) / 2;
}
示例2: Frame
void Frame(bool& request_warp, osg::Vec2& warp, bool& handled)
{
request_warp = true ;
warp.set(0,0) ;
handled = true ;
}