示例#1
0
void Geometry::offset(const Point &offset)
{
   S32 count = getVertCount();

   for(S32 i = 0; i < count; i++)
      setVert(getVert(i) + offset, i);
}
示例#2
0
// Make object bigger or smaller
void Geometry::scale(const Point &center, F32 scale) 
{
   S32 count = getVertCount();

   for(S32 j = 0; j < count; j++)
      setVert((getVert(j) - center) * scale + center, j);
}
示例#3
0
void SpritePolygonPerformanceTestStatic::initIncrementStats()
{
    auto t = experimental::SpritePolygon::create(s_pathGrossini);
    _incVert = (int)t->getVertCount();
    _incTri = (int)t->getTrianglesCount();
    _incPix = (int)t->getArea();
}
示例#4
0
// Could probably be more clever about this, but only used when merging polygons in the editor, so speed not critical
void Geometry::reverseWinding()
{
   S32 count = getVertCount();
   Vector<Point> temp(count);

   for(S32 i = 0; i < count; i++)
      temp.push_back(getVert(i));

   for(S32 i = 0; i < count; i++)
      setVert(temp[i], count - i - 1);
}
示例#5
0
void Geometry::rotateAboutPoint(const Point &center, F32 angle)
{
   F32 sinTheta = sin(angle * Float2Pi / 360.0f);
   F32 cosTheta = cos(angle * Float2Pi / 360.0f);

   for(S32 j = 0; j < getVertCount(); j++)
   {
      Point v = getVert(j) - center;
      Point n(v.x * cosTheta + v.y * sinTheta, v.y * cosTheta - v.x * sinTheta);

      setVert(n + center, j);
   }
}
示例#6
0
void Geometry::flip(F32 center, bool isHoriz)
{
   S32 count = getVertCount();

   for(S32 i = 0; i < count; i++)
   {
      Point p = getVert(i);
      
      if(isHoriz)
         p.x = center * 2 - p.x;
      else
         p.y = center * 2 - p.y;

      setVert(p, i);
   }
}