/** Draws a Myth/FF7 style viewing window */ static void setViewingWindow() { float pixSizeH, pixSizeV; Vector3i v[4], tv[4], centre; int shortX, longX, yDrop, yDropVar; int dif = getDistanceAdjust(); int dif2 = getLengthAdjust(); PIELIGHT colour; CalcRadarPixelSize(&pixSizeH, &pixSizeV); int x = player.p.x * pixSizeH / TILE_UNITS; int y = player.p.z * pixSizeV / TILE_UNITS; shortX = ((visibleTiles.x / 4) - (dif / 6)) * pixSizeH; longX = ((visibleTiles.x / 2) - (dif / 4)) * pixSizeH; yDropVar = ((visibleTiles.y / 2) - (dif2 / 3)) * pixSizeV; yDrop = ((visibleTiles.y / 2) - dif2 / 3) * pixSizeV; v[0].x = longX; v[0].y = -yDropVar; v[1].x = -longX; v[1].y = -yDropVar; v[2].x = shortX; v[2].y = yDrop; v[3].x = -shortX; v[3].y = yDrop; centre.x = x - scrollMinX * pixSizeH; centre.y = y - scrollMinY * pixSizeV; RotateVector2D(v, tv, ¢re, player.r.y, 4); switch (getCampaignNumber()) { case 1: case 2: // white colour.byte.r = UBYTE_MAX; colour.byte.g = UBYTE_MAX; colour.byte.b = UBYTE_MAX; colour.byte.a = 0x3f; break; case 3: // greenish colour.byte.r = 0x3f; colour.byte.a = 0x3f; colour.byte.g = UBYTE_MAX; colour.byte.b = 0x3f; default: // black colour.rgba = 0; colour.byte.a = 0x3f; break; } /* Send the four points to the draw routine and the clip box params */ pie_SetViewingWindow(tv, colour); }
/** Draws a Myth/FF7 style viewing window */ static void drawViewingWindow(float radarX, float radarY, int x, int y, float pixSizeH, float pixSizeV) { Vector3i v[4], tv[4], centre; int shortX, longX, yDrop, yDropVar; int dif = getDistanceAdjust(); int dif2 = getLengthAdjust(); PIELIGHT colour; shortX = ((visibleTiles.x / 4) - (dif / 6)) * pixSizeH; longX = ((visibleTiles.x / 2) - (dif / 4)) * pixSizeH; yDropVar = ((visibleTiles.y / 2) - (dif2 / 3)) * pixSizeV; yDrop = ((visibleTiles.y / 2) - dif2 / 3) * pixSizeV; v[0].x = longX; v[0].y = -yDropVar; v[1].x = -longX; v[1].y = -yDropVar; v[2].x = shortX; v[2].y = yDrop; v[3].x = -shortX; v[3].y = yDrop; centre.x = radarX + x - scrollMinX*pixSizeH/2; centre.y = radarY + y - scrollMinY*pixSizeV/2; RotateVector2D(v,tv,¢re,player.r.y,4); switch (getCampaignNumber()) { case 1: case 2: // white colour.byte.r = UBYTE_MAX; colour.byte.g = UBYTE_MAX; colour.byte.b = UBYTE_MAX; colour.byte.a = 0x3f; break; case 3: // greenish colour.byte.r = 0x3f; colour.byte.a = 0x3f; colour.byte.g = UBYTE_MAX; colour.byte.b = 0x3f; default: // black colour.rgba = 0; colour.byte.a = 0x3f; break; } /* Send the four points to the draw routine and the clip box params */ pie_DrawViewingWindow(tv, radarX, radarY, radarX + radarWidth, radarY + radarHeight, colour); }
// The inverse of NormalizeToRect // If a Rect is normalized onto one Rect and scaled by another with a different // X:Y ratio, that Rect will be squashed/stretched along its own X,Y axes, // not those of the normal or scale Rects FRect2D ScaleToRect(FRect2D ScaleRect, FRect2D BaseRect) { FRect2D Result; Result.Centre = BaseRect.Centre - FVector2D(0.5,0.5); Result.Centre = Result.Centre * ScaleRect.Size; Result.Centre = RotateVector2D(Result.Centre, ScaleRect.Rotation); Result.Centre += ScaleRect.Centre; Result.Size = BaseRect.Size * ScaleRect.Size; Result.Rotation = BaseRect.Rotation + ScaleRect.Rotation; return Result; }
// Transforms BaseRect into the coordinate system where NormalRect is an AABB // from (0,0) to (1,1). This is defined as: // The origin (0,0) is located at the bottom left corner of NormalRect // The axes X,Y are the positive X,Y according to the rotation of NormalRect // The X,Y unit lengths are equal to the X and Y lengths of NormalRect FRect2D NormalizeToRect(FRect2D NormalRect, FRect2D BaseRect) { FRect2D Result; Result.Centre = BaseRect.Centre - NormalRect.Centre; Result.Centre = RotateVector2D(Result.Centre, -NormalRect.Rotation); Result.Centre /= NormalRect.Size; Result.Centre += FVector2D(0.5,0.5); Result.Size = BaseRect.Size / NormalRect.Size; Result.Rotation = BaseRect.Rotation - NormalRect.Rotation; return Result; }