Ejemplo n.º 1
0
static void _DemoRandomGraph(void) {
  PARAM Param;
  int tDiff, t0, Cnt = 0;
  GUI_RECT Rect = {19, (LCD_YSIZE - 20) - YSIZE, (LCD_XSIZE - 2), (LCD_YSIZE - 21)};
  GUI_HMEM hMem = GUI_ALLOC_AllocZero((LCD_XSIZE - 20) * sizeof(I16));
  _ShowText("Random graph");
  Param.aY = (I16*)GUI_ALLOC_h2p(hMem);
  /*
  GUI_SetFont(&GUI_Font6x8);
  GUI_DispStringAt("msec/graph:", 10, 50);
  */
  _LabelMS();
  t0 = GUI_GetTime();
  while(((tDiff = (GUI_GetTime() - t0)) < 10000) && !GUIDEMO_CheckCancel()) {
    int t1, tDiff2;
    _GetRandomData(Param.aY, tDiff, (LCD_XSIZE - 20));
    t1 = GUI_GetTime();
    GUI_MEMDEV_Draw(&Rect, _Draw, &Param, 0, GUI_MEMDEV_NOTRANS);
    tDiff2 = GUI_GetTime() - t1;
    if (tDiff2 < 100) {
      GUI_Delay(100 - tDiff2);
    }
    if(!((++Cnt)%10)) {
      _DisplayTime(tDiff2);
      /*
      GUI_GotoXY(80, 50);
      GUI_SetColor(GUI_WHITE);
      GUI_SetBkColor(GUI_RED);
      GUI_DispDecSpace(tDiff2, 3);
      */
    }
  }
  GUI_ALLOC_Free(hMem);
}
Ejemplo n.º 2
0
static void _DemoOrData(void) {
  int i;
  PARAM Param;
  GUI_RECT Rect = {19, (LCD_YSIZE - 20) - YSIZE, (LCD_XSIZE - 2), (LCD_YSIZE - 21)};
  GUI_HMEM hMem = GUI_ALLOC_AllocZero((LCD_XSIZE + 90) * sizeof(I16));
  _ShowText("Several waves...");
  Param.aY = (I16*)GUI_ALLOC_h2p(hMem);
  _GetSineData(Param.aY, LCD_XSIZE + 90);
  GUI_MEMDEV_Draw(&Rect, _Draw, &Param, 0, GUI_MEMDEV_NOTRANS);
  for (i = 0; (i < 90) && !GUIDEMO_CheckCancel(); i++) {
    _DrawOrData(GUI_GREEN, ++Param.aY);
    GUI_Delay(10);
  }
  GUI_ALLOC_Free(hMem);
}
Ejemplo n.º 3
0
static void _DemoSineWave(void) {
  PARAM Param;
  I16 * pStart;
  int t0, Cnt = 0;
  GUI_HMEM hMem;
  GUI_RECT Rect;
  Rect.x0 = 19;
  Rect.y0 = (LCD_YSIZE - 20) - _YSize;
  Rect.x1 = LCD_XSIZE - 2;
  Rect.y1 = LCD_YSIZE - 21;
  hMem = GUI_ALLOC_AllocZero((LCD_XSIZE + 90) * sizeof(I16));
  _ShowText("Sine wave");
  GUI_LOCK();
  pStart = (I16*)GUI_ALLOC_h2p(hMem);
  GUI_UNLOCK();    /* Note: unlocking is permitted only if no further allocation is done so hMem stays valid */
  _GetSineData(pStart, LCD_XSIZE + 90);
  /*
  GUI_SetFont(&GUI_Font6x8);
  GUI_DispStringAt("msec/graph:", 10, 50);
  */
  _LabelMS();
  t0 = GUI_GetTime();
  while(((GUI_GetTime() - t0) < 10000) && !GUIDEMO_CheckCancel()) {
    U32 t1, tDiff2;
    if (Cnt % 90) {
      Param.aY++;
    } else {
      Param.aY = pStart;
    }
    t1 = GUI_GetTime();
    GUI_MEMDEV_Draw(&Rect, _Draw2, &Param, 0, GUI_MEMDEV_NOTRANS);
    tDiff2 = GUI_GetTime() - t1;
    if (tDiff2 < 100) {
      GUI_Delay(100 - tDiff2);
    }
    if(!((++Cnt) % 10)) {
      _DisplayTime(tDiff2);
      /*
      GUI_GotoXY(80, 50);
      GUI_SetColor(GUI_WHITE);
      GUI_SetBkColor(GUI_RED);
      GUI_DispDecSpace(tDiff2, 3);
      */
    }
  }
  GUI_ALLOC_Free(hMem);
}
Ejemplo n.º 4
0
static void _DemoSineWave(void) {
  PARAM Param;
  I16 * pStart;
  int t0, Cnt = 0;
  GUI_RECT Rect = {19, (LCD_YSIZE - 20) - YSIZE, (LCD_XSIZE - 2), (LCD_YSIZE - 21)};
  GUI_HMEM hMem = GUI_ALLOC_AllocZero((LCD_XSIZE + 90) * sizeof(I16));
  _ShowText("Sine wave");
  pStart = (I16*)GUI_ALLOC_h2p(hMem);
  _GetSineData(pStart, LCD_XSIZE + 90);
  /*
  GUI_SetFont(&GUI_Font6x8);
  GUI_DispStringAt("msec/graph:", 10, 50);
  */
  _LabelMS();
  t0 = GUI_GetTime();
  while(((GUI_GetTime() - t0) < 10000) && !GUIDEMO_CheckCancel()) {
    int t1, tDiff2;
    if (Cnt % 90) {
      Param.aY++;
    } else {
      Param.aY = pStart;
    }
    t1 = GUI_GetTime();
    GUI_MEMDEV_Draw(&Rect, _Draw2, &Param, 0, GUI_MEMDEV_NOTRANS);
    tDiff2 = GUI_GetTime() - t1;
    if (tDiff2 < 100) {
      GUI_Delay(100 - tDiff2);
    }
    if(!((++Cnt) % 10)) {
      _DisplayTime(tDiff2);
      /*
      GUI_GotoXY(80, 50);
      GUI_SetColor(GUI_WHITE);
      GUI_SetBkColor(GUI_RED);
      GUI_DispDecSpace(tDiff2, 3);
      */
    }
  }
  GUI_ALLOC_Free(hMem);
}
Ejemplo n.º 5
0
static void _DemoRandomGraph(void) {
  PARAM Param;
  int tDiff, t0;
  int Cnt = 0;
  GUI_HMEM hMem;
  GUI_RECT Rect;
  int lcd_xsize;
  int lcd_ysize;
  lcd_xsize = LCD_GetXSize();
  lcd_ysize = LCD_GetYSize();
  Rect.x0 = 19;
  Rect.y0 = (lcd_ysize - 20) - _YSize;
  Rect.x1 = lcd_xsize - 2;
  Rect.y1 = lcd_ysize - 21;
  hMem = GUI_ALLOC_AllocZero((LCD_GetXSize() - 20) * sizeof(I16));
  _ShowText("Random graph");
  GUI_LOCK();
  Param.aY = (I16*)GUI_ALLOC_h2p(hMem);
  GUI_UNLOCK();    /* Note: unlocking is permitted only if no further allocation is done so hMem stays valid */
  _LabelMS();
  t0 = GUI_GetTime();
  while(((tDiff = (GUI_GetTime() - t0)) < 10000) && !GUIDEMO_CheckCancel()) {
    U32 t1, tDiff2;
    _GetRandomData(Param.aY, tDiff, (lcd_xsize - 20));
    t1 = GUI_GetTime();
    GUI_MEMDEV_Draw(&Rect, _Draw, &Param, 0, GUI_MEMDEV_NOTRANS);
    tDiff2 = GUI_GetTime() - t1;
    if (tDiff2 < 100) {
      GUI_Delay(100 - tDiff2);
    }
    if(!((++Cnt)%10)) {
      _DisplayTime(tDiff2);
    }
  }
  GUI_ALLOC_Free(hMem);
}
Ejemplo n.º 6
0
/*********************************************************************
*
*       _cbFontDemo
*
* Purpose:
*   The function uses the given pointer to a true type font for creating
*   a couple of GUI fonts and showing the outline of the TTF font.
*
* Parameters:
*   pData    - Location of font file
*   NumBytes - Size of font file
*/
static void _cbFontDemo(const U8 * pData, U32 NumBytes) {
  _CreateFonts(pData, NumBytes); /* Create fonts */
  _ShowText();                   /* Show some text */
  GUI_TTF_DestroyCache();        /* Clear the TTF cache */
}
Ejemplo n.º 7
0
void AnchorData_Create_Links_Original_Method(EERIE_BACKGROUND * eb)
{
	EERIE_BKG_INFO * eg;
	EERIE_BKG_INFO * eg2;
	long ii, ia, ji, ja;
	EERIE_3D p1, p2; 
	char text[256];
	long count = 0;
	long per;
	long lastper = -1;
	long total = eb->Zsize * eb->Xsize;

	for (long j = 0; j < eb->Zsize; j++)
		for (long i = 0; i < eb->Xsize; i++)
		{
			F2L((float)count / (float)total * 100.f, &per);

			if (per != lastper)
			{
				sprintf(text, "Anchor Links Generation: %d%%", per);
				lastper = per;
				_ShowText(text);
			}

			danaeApp.WinManageMess();
			count++;
			eg = &eb->Backg[i+j*eb->Xsize];
			long precise = 0;

			for (long kkk = 0; kkk < eg->nbpolyin; kkk++)
			{
				EERIEPOLY * ep = eg->polyin[kkk];

				if (ep->type & POLY_PRECISE_PATH)
				{
					precise = 1;
					break;
				}
			}


			for (long k = 0; k < eg->nbianchors; k++)
			{
				ii = i - 2;
				ia = i + 2;
				ji = j - 2;
				ja = j + 2;
				FORCERANGE(ii, 0, eb->Xsize - 1);
				FORCERANGE(ia, 0, eb->Xsize - 1);
				FORCERANGE(ji, 0, eb->Zsize - 1);
				FORCERANGE(ja, 0, eb->Zsize - 1);

				for (long j2 = ji; j2 <= ja; j2++)
					for (long i2 = ii; i2 <= ia; i2++)
					{
						eg2 = &eb->Backg[i2+j2*eb->Xsize];
						long precise2 = 0;

						for (long kkk = 0; kkk < eg2->nbpolyin; kkk++)
						{
							EERIEPOLY * ep2 = eg2->polyin[kkk];

							if (ep2->type & POLY_PRECISE_PATH)
							{
								precise2 = 1;
								break;
							}
						}

						for (long k2 = 0; k2 < eg2->nbianchors; k2++)
						{
							// don't treat currently treated anchor
							if (eg->ianchors[k] == eg2->ianchors[k2]) continue;

							memcpy(&p1, &eb->anchors[eg->ianchors[k]].pos, sizeof(EERIE_3D));
							memcpy(&p2, &eb->anchors[eg2->ianchors[k2]].pos, sizeof(EERIE_3D));
							p1.y += 10.f;
							p2.y += 10.f;
							long _onetwo = 0;
							BOOL treat = TRUE;
							float dist = TRUEEEDistance3D(&p1, &p2);
							float dd = TRUEDistance2D(p1.x, p1.z, p2.x, p2.z);

							if (dd < 5.f) continue;

							if (dd > 200.f) continue; 

							if (precise || precise2)
							{
								if (dist > 120.f) continue;
							}
							else	if (dist > 200.f) continue;

							if (EEfabs(p1.y - p2.y) > dd * 0.9f) continue;

					
							IO_PHYSICS ip;
							ip.startpos.x = ip.cyl.origin.x = p1.x;
							ip.startpos.y = ip.cyl.origin.y = p1.y;
							ip.startpos.z = ip.cyl.origin.z = p1.z;
							ip.targetpos.x = p2.x;
							ip.targetpos.y = p2.y;
							ip.targetpos.z = p2.z;
						
							ip.cyl.height = eb->anchors[eg->ianchors[k]].height; 
							ip.cyl.radius = eb->anchors[eg->ianchors[k]].radius;
							EERIE_3D vect;
							vect.x = p2.x - p1.x;
							vect.y = p2.y - p1.y;
							vect.z = p2.z - p1.z;

							long t = 2;

							if (ANCHOR_ARX_COLLISION_Move_Cylinder(&ip, NULL, 20, CFLAG_CHECK_VALID_POS | CFLAG_NO_INTERCOL | CFLAG_EASY_SLIDING | CFLAG_NPC | CFLAG_JUST_TEST | CFLAG_EXTRA_PRECISION)) //CFLAG_SPECIAL
							{
								if (TRUEDistance2D(ip.cyl.origin.x, ip.cyl.origin.z, ip.targetpos.x, ip.targetpos.z) > 25) 
									t--;
								else _onetwo = 1;
							}
							else t--;

							if (t == 1)
							{
								ip.startpos.x = ip.cyl.origin.x = p2.x;
								ip.startpos.y = ip.cyl.origin.y = p2.y;
								ip.startpos.z = ip.cyl.origin.z = p2.z;
								ip.targetpos.x = p1.x;
								ip.targetpos.y = p1.y;
								ip.targetpos.z = p1.z;

								ip.cyl.height = eb->anchors[eg2->ianchors[k2]].height;
								ip.cyl.radius = eb->anchors[eg2->ianchors[k2]].radius; 

								if (ANCHOR_ARX_COLLISION_Move_Cylinder(&ip, NULL, 20, CFLAG_CHECK_VALID_POS | CFLAG_NO_INTERCOL | CFLAG_EASY_SLIDING | CFLAG_NPC | CFLAG_JUST_TEST | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT)) //CFLAG_SPECIAL
								{
									if (TRUEDistance2D(ip.cyl.origin.x, ip.cyl.origin.z, ip.targetpos.x, ip.targetpos.z) > 25) 
										t--;
									else _onetwo |= 2;
								}
								else t--;
							}
							else t--;

							if (t <= 0)
								treat = FALSE;
							else treat = TRUE;

							if (treat)
							{
								if (_onetwo)
								{
									AddAnchorLink(eb, eg->ianchors[k], eg2->ianchors[k2]);
									AddAnchorLink(eb, eg2->ianchors[k2], eg->ianchors[k]);
								}

							}
						}
					}
			}
		}

	EERIE_PATHFINDER_Create(eb);
}
Ejemplo n.º 8
0
////////////////////////////////////////////////////////////////////////////////////
//					ALTERNATIVE METHOD
void AnchorData_Create_Alternative_Method_I(EERIE_BACKGROUND * eb)
{
	char text[256];
	AnchorData_ClearAll(eb);
	EERIE_BKG_INFO * eg;
	EERIEPOLY * ep;
	EERIE_3D pos;
	long k;
	float count = 0;

	long lastper	=	-1;
	long per;
	float total		=	ARX_CLEAN_WARN_CAST_FLOAT(eb->Zsize * eb->Xsize * 4);

	for (long j = 0; j < eb->Zsize; j++)
		for (long i = 0; i < eb->Xsize; i++)
		{
			long LASTFOUND = 0;

			for (long divv = 0; divv < 4; divv++)
			{
				long divvx, divvy;

				switch (divv)
				{
					case 0:
						divvx = 0;
						divvy = 0;
						break;
					case 1:
						divvx = 1;
						divvy = 1;
						break;
					case 2:
						divvx = 0;
						divvy = 1;
						break;
					case 3:
						divvx = 1;
						divvy = 0;
						break;
				}

				float current_y = 99999999999.f;
				F2L((float)count / total * 100.f, &per);

				if (per != lastper)
				{
					sprintf(text, "Anchor Generation: %d%%", per);
					lastper = per;
					_ShowText(text);
				}

				count += 1.f;
				danaeApp.WinManageMess();

				if (LASTFOUND) break;

				eg = &eb->Backg[i+j*eb->Xsize];
				pos.x = (float)((float)((float)i + 0.5f * (float)divvx) * (float)eb->Xdiv);
				pos.y = 0.f;
				pos.z = (float)((float)((float)j + 0.5f * (float)divvy) * (float)eb->Zdiv);
				ep = GetMinPoly(pos.x, pos.y, pos.z);
				k = 0;
				EERIE_CYLINDER currcyl;
				currcyl.radius = 20 - (4.f * divv);
				currcyl.height = -120.f;
				currcyl.origin.x = pos.x;
				currcyl.origin.y = pos.y;
				currcyl.origin.z = pos.z;

				if (ep)
				{

					EERIEPOLY * epmax;
					epmax = GetMaxPoly(pos.x, pos.y, pos.z);
					float roof = 9999999.f;

					if (ep) roof = ep->min.y - 300;

					if (epmax) roof = epmax->min.y - 300;

					current_y = ep->max.y;

					while (current_y > roof)
					{
						currcyl.origin.y = current_y;
						EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 30.f, currcyl.origin.z);

						if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
							ep2 = NULL;

						if ((ep2) && !(ep2->type & POLY_NOPATH))
						{
							BOOL bval = ANCHOR_AttemptValidCylinderPos(&currcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT | CFLAG_ANCHOR_GENERATION);

							if ((bval)
							        && (currcyl.origin.y - 10.f <= current_y))
							{
								EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 38.f, currcyl.origin.z);

								if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
								{
									current_y -= 10.f;
								}
								else if ((ep2) && (ep2->type & POLY_NOPATH))
								{
									current_y -= 10.f;
								}
								else if (AddAnchor_Original_Method(eb, eg, &currcyl.origin, 0))
								{
									LASTFOUND++;
									current_y = currcyl.origin.y + currcyl.height;
								}
								else current_y -= 10.f;
							}
							else current_y -= 10.f;
						}
						else current_y -= 10.f;

					}
				}
			}
		}

	AnchorData_Create_Phase_II_Original_Method(eb);
	AnchorData_Create_Links_Original_Method(eb);

	/* TO KEEP
		// Parses Anchors to refine anchor creation...
		long ii,ia,ji,ja;
		EERIE_3D p1,p2;
		EERIE_BKG_INFO * eg2;
		count=0;


		total=eb->Zsize*eb->Xsize;
		long usable=0;
		if (0)
		for (j=0;j<eb->Zsize;j++)
		for (long i=0;i<eb->Xsize;i++)
		{
			F2L((float)count/(float)total*100.f,&per);
			if (per!=lastper)
			{
				sprintf(text,"Anchor Generation Pass II: %d%% Suitable %d",per,usable);
				lastper=per;
				_ShowText(text);
			}
			count++;
			eg=&eb->Backg[i+j*eb->Xsize];
			for (long k=0;k<eg->nbianchors;k++)
			{
				ii=i-2;
				ia=i+2;
				ji=j-2;
				ja=j+2;
				FORCERANGE(ii,0,eb->Xsize-1);
				FORCERANGE(ia,0,eb->Xsize-1);
				FORCERANGE(ji,0,eb->Zsize-1);
				FORCERANGE(ja,0,eb->Zsize-1);
				for (long j2=ji;j2<=ja;j2++)
				for (long i2=ii;i2<=ia;i2++)
				{
					eg2=&eb->Backg[i2+j2*eb->Xsize];
					for (long k2=0;k2<eg2->nbianchors;k2++)
					{
						// don't treat currently treated anchor
						if (eg->ianchors[k] == eg2->ianchors[k2]) continue;
						memcpy(&p1,&eb->anchors[eg->ianchors[k]].pos,sizeof(EERIE_3D));
						memcpy(&p2,&eb->anchors[eg2->ianchors[k2]].pos,sizeof(EERIE_3D));
						p1.y+=10.f;
						p2.y+=10.f;
						float dist=TRUEEEDistance3D(&p1,&p2);
						if (dist>120.f) continue;
						if (EEfabs(p1.y-p2.y)>80.f) continue;
						if ((eb->anchors[eg->ianchors[k]].radius>=40)
							&& (eb->anchors[eg2->ianchors[k2]].radius>=40)) 
							continue;
						{
							// found 2 usable anchors
							EERIE_3D pos;
							pos.x=(p1.x+p2.x)*DIV2;
							pos.y=(p1.y+p2.y)*DIV2;
							pos.z=(p1.z+p2.z)*DIV2;
							if (AddAnchor(eb,eg,&pos,MUST_BE_BIG))
								usable++;
						}
					}
				}
			}
		}*/

}
Ejemplo n.º 9
0
void AnchorData_Create_Original_Method(EERIE_BACKGROUND * eb)
{
	char text[256];
	AnchorData_ClearAll(eb);
	EERIE_BKG_INFO * eg;
	EERIEPOLY * ep;
	EERIE_3D pos;
#define DECALLL 20.f
	long k;
	float count = 0;
	long lastper	=	-1;
	long per;
	float total		=	ARX_CLEAN_WARN_CAST_FLOAT(eb->Zsize * eb->Xsize * 9);

	for (long j = 0; j < eb->Zsize; j++)
		for (long i = 0; i < eb->Xsize; i++)
		{
			long LASTFOUND = 0;

			for (long divv = 0; divv < 9; divv++)
			{
				long divvx, divvy;

				switch (divv)
				{
					case 0:
						divvx = 0;
						divvy = 0;
						break;
					case 1:
						divvx = 1;
						divvy = 0;
						break;
					case 2:
						divvx = 2;
						divvy = 0;
						break;
					case 3:
						divvx = 0;
						divvy = 1;
						break;
					case 4:
						divvx = 1;
						divvy = 1;
						break;
					case 5:
						divvx = 2;
						divvy = 1;
						break;
					case 6:
						divvx = 0;
						divvy = 2;
						break;
					case 7:
						divvx = 1;
						divvy = 2;
						break;
					case 8:
						divvx = 2;
						divvy = 2;
						break;

				}

				float current_y = 99999999999.f;
				F2L((float)count / total * 100.f, &per);

				if (per != lastper)
				{
					sprintf(text, "Anchor Generation: %d%%", per);
					lastper = per;
					_ShowText(text);
				}

				count += 1.f;
				danaeApp.WinManageMess();

				if (LASTFOUND) break;

				eg = &eb->Backg[i+j*eb->Xsize];
				pos.x = (float)((float)((float)i + 0.33f * (float)divvx) * (float)eb->Xdiv);
				pos.y = 0.f;
				pos.z = (float)((float)((float)j + 0.33f * (float)divvy) * (float)eb->Zdiv);
				ep = GetMinPoly(pos.x, pos.y, pos.z);
				k = 0;
				EERIE_CYLINDER currcyl;
				currcyl.radius = 20 - (4.f * divv);
				currcyl.height = -120.f;
				currcyl.origin.x = pos.x;
				currcyl.origin.y = pos.y;
				currcyl.origin.z = pos.z;

				if (ep)
				{

					EERIEPOLY * epmax;
					epmax = GetMaxPoly(pos.x, pos.y, pos.z);
					float roof = 9999999.f;

					if (ep) roof = ep->min.y - 300;

					if (epmax) roof = epmax->min.y - 300;

					current_y = ep->max.y;

					while (current_y > roof)
					{
						currcyl.origin.y = current_y;
						EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 30.f, currcyl.origin.z);

						if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
							ep2 = NULL;

						if ((ep2) && !(ep2->type & POLY_NOPATH))
						{
							BOOL bval = ANCHOR_AttemptValidCylinderPos(&currcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT | CFLAG_ANCHOR_GENERATION);

							if ((bval)
							        && (currcyl.origin.y - 10.f <= current_y))
							{
								EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 38.f, currcyl.origin.z);

								if (ep2 && !(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
								{
									current_y -= 10.f;
								}
								else if ((ep2) && (ep2->type & POLY_NOPATH))
								{
									current_y -= 10.f;
								}
								else if (AddAnchor_Original_Method(eb, eg, &currcyl.origin, 0))
								{
									LASTFOUND++;
									current_y = currcyl.origin.y + currcyl.height;
								}
								else current_y -= 10.f;
							}
							else current_y -= 10.f;
						}
						else current_y -= 10.f;
					}
				}
			}
		}

	AnchorData_Create_Phase_II_Original_Method(eb);
	AnchorData_Create_Links_Original_Method(eb);
}
Ejemplo n.º 10
0
void AnchorData_Create_Phase_II_Original_Method(EERIE_BACKGROUND * eb)
{
	char text[256];
	EERIE_BKG_INFO * eg;
	EERIE_3D pos;
	long k;
	float count = 0;


	long lastper	=	-1;
	long per;
	float total		=	ARX_CLEAN_WARN_CAST_FLOAT(eb->Zsize * eb->Xsize);

	for (long j = 0; j < eb->Zsize; j++)
		for (long i = 0; i < eb->Xsize; i++)
		{
			float current_y = 99999999999.f;
			F2L((float)count / total * 100.f, &per);

			if (per != lastper)
			{
				sprintf(text, "Anchor Generation: %d%% (Pass II)", per);
				lastper = per;
				_ShowText(text);
			}

			count += 1.f;
			danaeApp.WinManageMess();

			eg = &eb->Backg[i+j*eb->Xsize];
			pos.x = (float)((float)((float)i) * (float)eb->Xdiv);
			pos.y = 0.f;
			pos.z = (float)((float)((float)j) * (float)eb->Zdiv);
			k = 0;
			EERIE_CYLINDER currcyl;
			currcyl.radius = 30;
			currcyl.height = -150.f;
			currcyl.origin.x = pos.x;
			currcyl.origin.y = pos.y;
			currcyl.origin.z = pos.z;

			if (eg->nbpolyin)
			{
				long ok = 0;

				for (long kkk = 0; kkk < eg->nbpolyin; kkk++)
				{
					EERIEPOLY * ep = eg->polyin[kkk];

					if (ep->type & POLY_PRECISE_PATH)
					{
						ok = 1;
						break;
					}
				}

				if (!ok) continue;

				float roof = GetTileMinY(i, j); 
				current_y = GetTileMaxY(i, j); 

				while (current_y > roof)
				{
					long added = 0;

					for (float pposz = 0.f; pposz < 1.f; pposz += 0.1f)
						for (float pposx = 0.f; pposx < 1.f; pposx += 0.1f)
						{
							currcyl.origin.x = pos.x + pposx * eb->Xdiv;
							currcyl.origin.z = pos.z + pposz * eb->Zdiv;
							currcyl.origin.y = current_y;

							EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 10.f, currcyl.origin.z);

							if (!ep2)
								continue;

							if (!(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
								continue;

							if (ep2->type & POLY_NOPATH)
								continue;

							if (ANCHOR_AttemptValidCylinderPos(&currcyl, NULL, CFLAG_NO_INTERCOL | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT | CFLAG_ANCHOR_GENERATION))
							{
								EERIEPOLY * ep2 = ANCHOR_CheckInPolyPrecis(currcyl.origin.x, currcyl.origin.y - 10.f, currcyl.origin.z);

								if (!ep2)
									continue;

								if (!(ep2->type & POLY_DOUBLESIDED) && (ep2->norm.y > 0.f))
									continue;

								if (ep2->type & POLY_NOPATH)
									continue;

								if (DirectAddAnchor_Original_Method(eb, eg, &currcyl.origin, 0))
								{
									added = 1;
								}
							}
						}


					if (added)
						current_y -= 160.f; 

					current_y -= 50.f; 
				}
			}
		}

}