Ejemplo n.º 1
0
void Character::Draw()
{
    const s_Polygon& ImgPos = GetPolygon();

    Sprite.Pos->X = (int)ImgPos.MinX;
    Sprite.Pos->Y = (int)ImgPos.MinY;

    Screen->DrawImage(Sprite);

    //imgpos << "X: " << Sprite.Pos->X << " " << "Y: " << Sprite.Pos->Y << std::endl;
    //boxpos << "MinX: " << ImgPos.MinX << " " << "MinY: " << ImgPos.MinY << std::endl;
}
Ejemplo n.º 2
0
int llPolygonList::AddVertexToPolygon(float _x, float _y, char *_name) {

	llPolygon * mypoly = GetPolygon(_name);

	if (!mypoly) {
		mesg->WriteNextLine(LOG_ERROR,"Polygon (%s) not existing",_name);
		return 0;
	}

	int point1 = points->GetPoint(_x, _y);
	if (point1 < 0)
		point1 = points->AddPoint(_x, _y, map->GetZ(_x, _y));

	mypoly->AddPoint(point1);

	return 1;
}
Ejemplo n.º 3
0
int llPolygonList::AddPolygon(float _x1, float _y1, float _x2, float _y2, char *_name) {

	if (GetPolygon(_name)) {
		mesg->WriteNextLine(LOG_ERROR,"Polygon (%s) already existing",_name);
		return 0;
	}

	char *myname2 = new char[strlen(_name) + 1];
	strcpy_s(myname2,strlen(_name)+1,_name);

	int point1 = points->GetPoint(_x1, _y1);
	if (point1 < 0)
		point1 = points->AddPoint(_x1, _y1, map->GetZ(_x1, _y1));
	int point2 = points->GetPoint(_x2, _y2);
	if (point2 < 0)
		point2 = points->AddPoint(_x2, _y2, map->GetZ(_x2, _y2));
	
	p.resize(p.size()+1);

	llPolygon * mypoly = new llPolygon(point1, point2, myname2, points);
	p[p.size()-1] = mypoly;

	return 1;
}
Ejemplo n.º 4
0
static LWObject *createLWObject(const char *name)
{
   char  sname[MAX_SURFNAME];
   LWOBInfo LWObj;
   LWPoint pnt;
   LWObject   *Object=NULL;
   LWSurface   surf;
   int   p;


   surf.name = sname;
   surf.data = NULL;
   surf.size = 0;
   if(!OpenLWObject((char *)name,&LWObj))
      return(NULL);


   if(Object=malloc(sizeof(LWObject)+strlen(name)+2) )
   {
      memset(Object,0,sizeof(LWObject));
      Object->name = (char *)&(Object[1]);
      strcpy(Object->name,name);
      while(GetPolygon(&LWObj,&MaxPoly)==1)
         Object->nPols++;
      ResetPosition(&LWObj);
      if(Object->pols = calloc(sizeof(LWPolygon),Object->nPols))
      {
         for(p=0; (p<Object->nPols) && (GetPolygon(&LWObj,&MaxPoly)==1); p++ )
            copyPolygon(&(Object->pols[p]), &MaxPoly);
      }
      while(GetPoint(&LWObj,&pnt)==1)
         Object->nPnts++;
      ResetPosition(&LWObj);
      if(Object->pnts = calloc(sizeof(LWPoint),Object->nPnts))
      {
         double r;
         for(p=0; (p<Object->nPnts) && (GetPoint(&LWObj,&pnt)==1); p++ )
         {
            if(p)
            {
               if(pnt.x>Object->bounds[BB_XMAX])
                  Object->bounds[BB_XMAX] = pnt.x;
               if(pnt.x<Object->bounds[BB_XMIN])
                  Object->bounds[BB_XMIN] = pnt.x;
               if(pnt.y>Object->bounds[BB_YMAX])
                  Object->bounds[BB_YMAX] = pnt.y;
               if(pnt.y<Object->bounds[BB_YMIN])
                  Object->bounds[BB_YMIN] = pnt.y;
               if(pnt.z>Object->bounds[BB_ZMAX])
                  Object->bounds[BB_ZMAX] = pnt.z;
               if(pnt.z<Object->bounds[BB_ZMIN])
                  Object->bounds[BB_ZMIN] = pnt.z;
               r = sqrt(pnt.x*pnt.x + pnt.y*pnt.y + pnt.z*pnt.z);
               if(Object->rMax<r)
                  Object->rMax = r;
            }
            else   // initialize max values = first values
            {
               Object->rMax = sqrt(pnt.x*pnt.x + pnt.y*pnt.y + pnt.z*pnt.z);
               Object->bounds[BB_XMIN] = Object->bounds[BB_XMAX] = pnt.x;
               Object->bounds[BB_YMIN] = Object->bounds[BB_YMAX] = pnt.y;
               Object->bounds[BB_ZMIN] = Object->bounds[BB_ZMAX] = pnt.z;
            }
            Object->pnts[p] = pnt;
         }
         while(GetSurface(&LWObj,&surf)==1)
            Object->nSurfs++;
         if(Object->surfs = malloc( LWObj.srfSize+(sizeof(LWSurface)*(Object->nSurfs+1)) ))
         {
            int   i,len,siz;
            fpos_t datpos;
            char *buf = (char *)&(Object->surfs[Object->nSurfs+1]);
            memset(Object->surfs,0,( LWObj.srfSize + (sizeof(LWSurface)*(Object->nSurfs+1)) ));
            GetSRF(&LWObj,buf,LWObj.srfSize);
            for(i=0; i<Object->nSurfs; i++)
            {
               Object->surfs[i].name = buf;
               Object->surfs[i].size = 0;
               Object->surfs[i].data = NULL;
               if( (siz=GetSDatSize(&LWObj,buf,&datpos)) )
               {
                  if( (Object->surfs[i].data=malloc(siz)) )
                  {
                     GetSDat(&LWObj,Object->surfs[i].data,siz,&datpos);
                     Object->surfs[i].size = siz;
                  }
               }
               len = strlen(buf) + 1;  // get NULL too
               if(len&1) len++;
               buf +=  len;
            }
            Object->surfs[i].name = NULL;
         }
      }
   }
   CloseLWObject(&LWObj);
#ifdef HEAP_PROBLEM
   _heapmin();
#endif
   return(Object);
}
Ejemplo n.º 5
0
	inline const Polygon<T, Dim>& PolygonMesh<T, Dim>::operator[](const int& iIndex) const
	{
		return GetPolygon(iIndex);
	}