예제 #1
0
// Called when we create a brand new object and insert it in the editor, like when we drag a new item from the dock
void PolygonObject::newObjectFromDock(F32 gridSize)
{
#ifndef ZAP_DEDICATED
   F32 w = INITIAL_HEIGHT * gridSize / 2;
   F32 h = INITIAL_WIDTH * gridSize / 2;

   setVert(Point(-w, -h), 0);
   setVert(Point(-w,  h), 1);
   setVert(Point( w,  h), 2);
   setVert(Point( w, -h), 3);

   Parent::newObjectFromDock(gridSize);
#endif
}
예제 #2
0
void Geometry::offset(const Point &offset)
{
   S32 count = getVertCount();

   for(S32 i = 0; i < count; i++)
      setVert(getVert(i) + offset, i);
}
예제 #3
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);
}
예제 #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);
   }
}
예제 #7
0
void polygon :: listMess(int argc, t_atom*argv) {
	if(0==m_numInputs) {
		if(argc%3) {
			error("list must contain 3 elements for each vertex!");
			return;
		}
		createVertices(argc/3);
	}
	
	if(m_numVertices*3==argc) {
		int i=0;
		for(i=0; i<m_numVertices; i++) {
			setVert(i, 
							atom_getfloat(argv+0),
							atom_getfloat(argv+1),
							atom_getfloat(argv+2)
							);
			argv+=3;
		}
	} else {
		error("vertex-list must have exactly %d numbers", m_numVertices*3);
	}
}