Mercurial > mm7
diff Render.cpp @ 1445:6de9c1316852
Слияние
author | Ritor1 |
---|---|
date | Sat, 03 Aug 2013 00:00:31 +0600 |
parents | a8b1bbac95d4 71a2cf416478 |
children | bfe342ae0c1f |
line wrap: on
line diff
--- a/Render.cpp Sat Aug 03 00:00:10 2013 +0600 +++ b/Render.cpp Sat Aug 03 00:00:31 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,30 +292,30 @@ //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]; - uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1];// 1 , 1 + uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; assert(norm_idx < uNumTerrainNormals); auto norm = pTerrainNormals + norm_idx; 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(); @@ -2770,7 +2753,7 @@ //----- (0049F8B5) -------------------------------------------------------- FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) { - Render *v5; // esi@1 + //Render *v5; // esi@1 FILE *result; // eax@1 FILE *v7; // edi@4 int v8; // ecx@5 @@ -2792,7 +2775,6 @@ int v24; // [sp+9Ch] [bp-8h]@2 char *i; // [sp+A0h] [bp-4h]@8 - v5 = this; result = fopen(Filename, "wb"); Filename = (const char *)result; if ( result ) @@ -2853,16 +2835,16 @@ i = (char *)ptr + 2 * v24; do { - *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits) - + LOBYTE(v5->uTargetBBits) - + v5->uTargetRBits + *((char *)ptr + v10) = (signed int)(this->uTargetRMask & *(short *)a5) >> (LOBYTE(this->uTargetGBits) + + LOBYTE(this->uTargetBBits) + + this->uTargetRBits - 8); - a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits) - + LOBYTE(v5->uTargetGBits) + a3[v10] = (signed int)(this->uTargetGMask & *(short *)a5) >> (LOBYTE(this->uTargetBBits) + + LOBYTE(this->uTargetGBits) - 8); v11 = a5; a5 += 2; - i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits)); + i[v10++] = (this->uTargetBMask & *(char *)v11) << (8 - LOBYTE(this->uTargetBBits)); } while ( v10 < a4 ); } @@ -4947,11 +4929,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 +4944,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 +4954,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 +5146,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 )