/* ==================== UpdateForCenter Center is in the 0.0 to 1.0 range ==================== */ void idTextureLevel::UpdateForCenter( float center[2] ) { int globalTileCorner[2]; int localTileOffset[2]; if( tilesWide <= TILE_PER_LEVEL && tilesHigh <= TILE_PER_LEVEL ) { globalTileCorner[0] = 0; globalTileCorner[1] = 0; localTileOffset[0] = 0; localTileOffset[1] = 0; // orient the mask so that it doesn't mask anything at all parms[0] = 0.25; parms[1] = 0.25; parms[3] = 0.25; } else { for( int i = 0 ; i < 2 ; i++ ) { float global[2]; // this value will be outside the 0.0 to 1.0 range unless // we are in the corner of the megaTexture global[i] = ( center[i] * parms[3] - 0.5 ) * TILE_PER_LEVEL; globalTileCorner[i] = ( int )( global[i] + 0.5 ); localTileOffset[i] = globalTileCorner[i] & ( TILE_PER_LEVEL - 1 ); // scaling for the mask texture to only allow the proper window // of tiles to show through parms[i] = -globalTileCorner[i] / ( float )TILE_PER_LEVEL; } } image->Bind(); for( int x = 0 ; x < TILE_PER_LEVEL ; x++ ) { for( int y = 0 ; y < TILE_PER_LEVEL ; y++ ) { int globalTile[2]; globalTile[0] = globalTileCorner[0] + ( ( x - localTileOffset[0] ) & ( TILE_PER_LEVEL - 1 ) ); globalTile[1] = globalTileCorner[1] + ( ( y - localTileOffset[1] ) & ( TILE_PER_LEVEL - 1 ) ); UpdateTile( x, y, globalTile[0], globalTile[1] ); } } }
//----------------------------------------------------------------------- // Update our lodStep and lodMask for the current tile, given the page // local coordinates of a vertex. void UpdateWithLocalPage( int localPageX, int localPageZ ) { int tileX = PageToTile( localPageX, invTileSize_, maxNumTiles_ ); int tileZ = PageToTile( localPageZ, invTileSize_, maxNumTiles_ ); UpdateTile( tileX, tileZ ); }
//*************************************************************************************************** // Update //*************************************************************************************************** void eCTerrainTileList::Update( GEUInt a_iViewWorldPosX, GEUInt a_iViewWorldPosY ) { unsigned int iVisibleTileIndex = 0; GEMemSet(m_arrTileTypeCount, 0, sizeof(m_arrTileTypeCount)); while ((iVisibleTileIndex < m_iListCount) && ((m_iListCount + 4) < m_iListCapacity)) { PrefetchArray(iVisibleTileIndex + 16); PrefetchValue(iVisibleTileIndex + 2); GE_ASSERT(!IsSlotFree(iVisibleTileIndex)); UpdateTile(iVisibleTileIndex, a_iViewWorldPosX, a_iViewWorldPosY); iVisibleTileIndex++; } CompactAndSortList(); }
BOOL TilePropWindow::DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch ( msg ) { case WM_ACTIVATE: if ( LOWORD(wParam) != WA_INACTIVE ) chkd.SetCurrDialog(hWnd); break; case WM_INITDIALOG: { HWND hEdit = GetDlgItem(hWnd, IDC_EDIT_TILEVALUE); SendMessage(hEdit, EM_SETLIMITTEXT, 10, 0); UpdateTile(); PostMessage(hWnd, WM_NEXTDLGCTL, (WPARAM)hEdit, true); return true; } break; case WM_PAINT: { RECT rect; GetClientRect(hWnd, &rect); int width = 32, height = 32; PAINTSTRUCT ps; HDC hDC = BeginPaint(hWnd, &ps), MemhDC = CreateCompatibleDC(hDC); HBITMAP Membitmap = CreateCompatibleBitmap(hDC, width, height); SelectObject(MemhDC, Membitmap); TCHAR lpszTile[11]; int TextLength = WORD(SendDlgItemMessage(hWnd, IDC_EDIT_TILEVALUE, EM_LINELENGTH, 0, 0)); *((LPWORD)lpszTile) = TextLength; SendDlgItemMessage(hWnd, IDC_EDIT_TILEVALUE, EM_GETLINE, 0, (LPARAM)lpszTile); lpszTile[TextLength] = '\0'; u16 tile = atoi(lpszTile), tileset = CM->getTileset(); TileSet* tiles = &chkd.scData.tilesets.set[tileset]; HBRUSH brush = CreateSolidBrush(RGB(166, 156, 132)); FillRect(MemhDC, &rect, brush); DeleteObject(brush); BITMAPINFO bmi = GetBMI(32, 32); DrawTile(MemhDC, tiles, 0, 0, tile, bmi, 0, 0, 0); BitBlt(hDC, 55, 50, width, height, MemhDC, 0, 0, SRCCOPY); BITMAPINFO bmiMini = GetBMI(8, 8); for ( int yMiniTile=0; yMiniTile<4; yMiniTile++ ) { for ( int xMiniTile=0; xMiniTile<4; xMiniTile++ ) DrawMiniTileElevation(hDC, tiles, 350+xMiniTile*9, 50+yMiniTile*9, tile, xMiniTile, yMiniTile, bmiMini); } DeleteObject(Membitmap); DeleteDC (MemhDC); DeleteDC (hDC); } break; case WM_DESTROY: EndDialog(hWnd, IDCANCEL); break; default: return false; break; } return 0; }