Mercurial > mm7
diff Render.cpp @ 1427:1987f2cca08f
m
author | Ritor1 |
---|---|
date | Thu, 01 Aug 2013 09:26:05 +0600 |
parents | 5930342f092b |
children | 71a2cf416478 |
line wrap: on
line diff
--- a/Render.cpp Tue Jul 30 15:14:46 2013 +0600 +++ b/Render.cpp Thu Aug 01 09:26:05 2013 +0600 @@ -209,27 +209,10 @@ return result; } - void Render::RenderTerrainD3D() // New function { - char result; // al@3 int v6; // ecx@8 - struct Polygon *pTile; // ebx@8 - struct Polygon *v16; - unsigned int v18; // edi@22 - int v35; // edi@63 - int v37; // eax@73 - int v39; // eax@80 - char v40; // [sp-18h] [bp-70h]@2 - int v41; // [sp-14h] [bp-6Ch]@2 - int v42; // [sp-10h] [bp-68h]@2 - int v43; // [sp-Ch] [bp-64h]@2 - const char *v44; // [sp-8h] [bp-60h]@2 - int v45; // [sp-4h] [bp-5Ch]@2 - int v56; - int v57; // [sp+38h] [bp-20h]@36 - int v64; // [sp+57h] [bp-1h]@2 - int v62; + struct Polygon *pTilePolygon; // ebx@8 //warning: the game uses CW culling by default, ccw is incosistent pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); @@ -271,20 +254,20 @@ { for (unsigned int x = 0; x < 127; ++x) { - pTile = &array_77EC08[pOutdoorCamera->uNumPolygons]; - pTile->flags = 0; - pTile->field_32 = 0; - pTile->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); - pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTile->uTileBitmapID]; - if (pTile->uTileBitmapID == 0xFFFF) + pTilePolygon = &array_77EC08[pOutdoorCamera->uNumPolygons]; + pTilePolygon->flags = 0; + pTilePolygon->field_32 = 0; + pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); + pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; + if (pTilePolygon->uTileBitmapID == 0xFFFF) continue; //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); - pTile->flags = pOutdoor->GetSomeOtherTileInfo(x, z); - pTile->field_32 = 0; - pTile->field_59 = 1; - pTile->sTextureDeltaU = 0; - pTile->sTextureDeltaV = 0; + pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); + pTilePolygon->field_32 = 0; + pTilePolygon->field_59 = 1; + pTilePolygon->sTextureDeltaU = 0; + pTilePolygon->sTextureDeltaV = 0; // x,z x+1,z // .____________. // | | @@ -309,9 +292,9 @@ //v58 = 0; //if (v58 == 4) // if all y == first y; primitive in xz plane //pTile->field_32 |= 0x0001; - pTile->pODMFace = nullptr; - pTile->uNumVertices = 4; - pTile->field_59 = 5; + pTilePolygon->pODMFace = nullptr; + pTilePolygon->uNumVertices = 4; + pTilePolygon->field_59 = 5; //shading (затенение)---------------------------------------------------------------------------- //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; @@ -322,17 +305,17 @@ float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); - pTile->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); + pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); //----------------------------------------------------------------------------------------------- ++pOutdoorCamera->uNumPolygons; ++pOutdoorCamera->field_44; assert(pOutdoorCamera->uNumPolygons < 20000); - pTile->uBModelID = 0; - pTile->uBModelFaceID = 0; - pTile->field_50 = (8 * (0 | (0 << 6))) | 6; - for (unsigned int k = 0; k < pTile->uNumVertices; ++k) + pTilePolygon->uBModelID = 0; + pTilePolygon->uBModelFaceID = 0; + pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; + for (unsigned int k = 0; k < pTilePolygon->uNumVertices; ++k) { memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); @@ -340,27 +323,27 @@ // check the transparency and texture (tiles) mapping (проверка прозрачности и наложение текстур (тайлов))---------------------- bool transparent = false; - if ( !( pTile->flags & 1 ) ) // не поддерживается TextureFrameTable - { - if ( /*pTile->flags & 2 && */pTile->uTileBitmapID == pRenderer->hd_water_tile_id) + if ( !( pTilePolygon->flags & 1 ) ) // не поддерживается TextureFrameTable + { + if ( /*pTile->flags & 2 && */pTilePolygon->uTileBitmapID == pRenderer->hd_water_tile_id) { //transparent = false; v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; } else { - v6 = pTile->uTileBitmapID; - if ( !_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5) ) + v6 = pTilePolygon->uTileBitmapID; + if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5) ) transparent = true; } assert(v6 < 1000); // many random crashes here // for all shore tiles - draw a tile water under them since they're half-empty - if (!_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX - pTile->DrawBorderTiles(); - - pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); + if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX + pTilePolygon->DrawBorderTiles(); + + pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); } //else //здесь уже пограничные тайлы воды //pTile->DrawBorderTiles(); @@ -4947,11 +4930,9 @@ // 4D864C: using guessed type char byte_4D864C; //----- (004A2DA3) -------------------------------------------------------- -void Render::DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *a3, IDirect3DTexture2 *pTexture) +void Render::DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) { int v7; // eax@7 - float v13; // ST3C_4@8 - int i; if ( !this->uNumD3DSceneBegins ) return; @@ -4964,7 +4945,7 @@ this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); } - for ( i = 0; i < uNumVertices; ++i ) + for ( uint i = 0; i < uNumVertices; ++i ) { pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; @@ -4974,10 +4955,7 @@ pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); v7 = 0; if (this->bUsingSpecular) - { - v13 = array_50AC10[i].vWorldViewPosition.x; - v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13); - } + v7 = sub_47C3D7_get_fog_related_stuff(0, 1, array_50AC10[i].vWorldViewPosition.x); pVertices[i].specular = v7; pVertices[i].texcoord.x = array_50AC10[i].u; pVertices[i].texcoord.y = array_50AC10[i].v; @@ -5169,7 +5147,7 @@ if ( v7 == 4 || v7 == 3 ) v70 = v6; stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0); - v62._48607B(&stru_8019C8); + v62.Create_48607B(&stru_8019C8); v62.uTileBitmapID = pFace->uBitmapID; v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0); if ( !v62.pTexture )