# HG changeset patch # User Ritor1 # Date 1380886247 -21600 # Node ID 0c4d3c6a9d5ac63d9b2a470655b100ca1e65fdcc # Parent 11f36943e8181436f5b4ec00266045d896a9f593 DrawBuildingsD3D cleared diff -r 11f36943e818 -r 0c4d3c6a9d5a Render.cpp --- a/Render.cpp Thu Oct 03 18:09:21 2013 +0600 +++ b/Render.cpp Fri Oct 04 17:30:47 2013 +0600 @@ -8717,4 +8717,268 @@ assert(false); break; } +} + +//----- (00424EE0) -------------------------------------------------------- +int BuildingVerticesClipping(unsigned int uNumVertices) +{ + signed int previous_vertices_flag; // edi@1 + double t; // st6@10 + bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 + signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 + int pNextVertices; + //Доп инфо "Программирование трёхмерных игр для windows" Ламот стр 910 + + memcpy(&array_50AC10[uNumVertices], array_50AC10, sizeof(array_50AC10[uNumVertices])); + depth_num_vertices = 0; + previous_vertices_flag = 0; + if ( array_50AC10[0].vWorldViewPosition.x <= pODMRenderParams->shading_dist_mist ) + previous_vertices_flag = 1;//предыдущая грань меньше границы видимости + if ( (signed int)uNumVertices <= 0 ) + return 0; + for ( uint i = 1; i <= uNumVertices; ++i ) + { + current_vertices_flag = pODMRenderParams->shading_dist_mist >= array_50AC10[i].vWorldViewPosition.x; + if ( previous_vertices_flag != current_vertices_flag )//одна из граней за границей видимости + { + if ( current_vertices_flag )//текущая грань меньше границы видимости(предыдущая грань за пределами видимости) + { + //t = far_clip - v0.x / v1.x - v0.x (формула получения точки пересечения отрезка с плоскостью) + t = (pODMRenderParams->shading_dist_mist - array_50AC10[i - 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i - 1].vWorldViewPosition.x); + array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i - 1].vWorldViewPosition.y) * t + array_50AC10[i - 1].vWorldViewPosition.y; + array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i - 1].vWorldViewPosition.z) * t + array_50AC10[i - 1].vWorldViewPosition.z; + array_507D30[depth_num_vertices].u = (array_50AC10[i].u - array_50AC10[i - 1].u) * t + array_50AC10[i - 1].u; + array_507D30[depth_num_vertices].v = (array_50AC10[i].v - array_50AC10[i - 1].v) * t + array_50AC10[i - 1].v; + } + else//предыдущая грань меньше границы видимости(текущая грань вышла за пределы видимости) + { + //t = far_clip - v1.x / v0.x - v1.x + t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i - 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); + array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i - 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; + array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i - 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; + array_507D30[depth_num_vertices].u = (array_50AC10[i - 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; + array_507D30[depth_num_vertices].v = (array_50AC10[i - 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; + } + array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; + array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; + ++depth_num_vertices; + } + if ( current_vertices_flag )//оба в границе видимости + { + pNextVertices = depth_num_vertices++; + memcpy(&array_507D30[pNextVertices], &array_50AC10[i], 0x30); + } + previous_vertices_flag = current_vertices_flag; + } + if ( depth_num_vertices < 3 ) + return 0; + return depth_num_vertices; +} + +//----- (0047840D) -------------------------------------------------------- +void Render::DrawBuildingsD3D() +{ + int v9; // ecx@8 + Texture *pFaceTexture; // eax@10 + unsigned int v16; // edi@22 + int v27; // eax@57 + int vertex_id; // eax@58 + unsigned int v34; // eax@80 + int v40; // [sp-4h] [bp-5Ch]@2 + int v49; // [sp+2Ch] [bp-2Ch]@10 + int v50; // [sp+30h] [bp-28h]@34 + int v51; // [sp+34h] [bp-24h]@35 + int v52; // [sp+38h] [bp-20h]@36 + int v53; // [sp+3Ch] [bp-1Ch]@8 + int uNumVertices; // [sp+4Ch] [bp-Ch]@34 + int unused; // [sp+50h] [bp-8h]@3 + + if ( !pRenderer->pRenderD3D ) + { + MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); + } + + unused = 0; + if ( (signed int)pOutdoor->uNumBModels > 0 ) + { + for ( uint model_id = 0; model_id < pOutdoor->uNumBModels; model_id++ ) + { + if ( IsBModelVisible(model_id, &unused) ) + { + pOutdoor->pBModels[model_id].field_40 |= 1; + if ( pOutdoor->pBModels[model_id].uNumFaces > 0 ) + { + for ( int face_id = 0; face_id < pOutdoor->pBModels[model_id].uNumFaces; face_id++ ) + { + if (!pOutdoor->pBModels[model_id].pFaces[face_id].Invisible()) + { + v53 = 0; + array_77EC08[pODMRenderParams->uNumPolygons].flags = 0; + array_77EC08[pODMRenderParams->uNumPolygons].field_32 = 0; + v9 = pOutdoor->pBModels[model_id].pFaces[face_id].uTextureID; + if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_TEXTURE_FRAME) + v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); + pFaceTexture = pBitmaps_LOD->GetTexture(v9); + array_77EC08[pODMRenderParams->uNumPolygons].pTexture = pFaceTexture; + if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_FLUID) + array_77EC08[pODMRenderParams->uNumPolygons].flags |= 2; + if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_DO_NOT_LIGHT ) + HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; + if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & 4 ) + HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 4; + else + { + if ( pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & 0x20 ) + HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 8; + } + if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & 0x0800) + array_77EC08[pODMRenderParams->uNumPolygons].flags |= 0x2000; + else + { + if (pOutdoor->pBModels[model_id].pFaces[face_id].uAttributes & FACE_DONT_CACHE_TEXTURE) + HIBYTE(array_77EC08[pODMRenderParams->uNumPolygons].flags) |= 0x10u; + } + array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaU; + array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV = pOutdoor->pBModels[model_id].pFaces[face_id].sTextureDeltaV; + v16 = GetTickCount() >> 4; + if ( pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z && abs(pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >= 59082 ) + { + if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) + array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; + if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) + array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; + } + else + { + if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 4 ) + array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; + if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 8 ) + array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uHeightMinus1; + } + if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x10 ) + array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU -= v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; + else + { + if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x20 ) + array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU += v16 & array_77EC08[pODMRenderParams->uNumPolygons].pTexture->uWidthMinus1; + } + v50 = 0; + v49 = 0; + uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; + if ( pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices > 0 ) + { + for ( uint vertex_id = 1; vertex_id <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; vertex_id++ ) + { + array_73D150[vertex_id - 1].vWorldPosition.x = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].x; + array_73D150[vertex_id - 1].vWorldPosition.y = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].y; + array_73D150[vertex_id - 1].vWorldPosition.z = pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[vertex_id - 1]].z; + array_73D150[vertex_id - 1].u = (array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaU + (signed __int16)pOutdoor->pBModels[model_id].pFaces[face_id].pTextureUIDs[vertex_id - 1]) * (1.0 / (double)pFaceTexture->uTextureWidth); + array_73D150[vertex_id - 1].v = (array_77EC08[pODMRenderParams->uNumPolygons].sTextureDeltaV + (signed __int16)pOutdoor->pBModels[model_id].pFaces[face_id].pTextureVIDs[vertex_id - 1]) * (1.0 / (double)pFaceTexture->uTextureHeight); + } + for ( uint i = 1; i <= pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; i++ ) + { + if ( pOutdoor->pBModels[model_id].pVertices.pVertices[pOutdoor->pBModels[model_id].pFaces[face_id].pVertexIDs[0]].z == array_73D150[i - 1].vWorldPosition.z ) + ++v53; + pGame->pIndoorCameraD3D->ViewTransform(&array_73D150[i - 1], 1); + if ( array_73D150[i - 1].vWorldViewPosition.x < 8.0 || array_73D150[i - 1].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist ) + { + if ( array_73D150[i - 1].vWorldViewPosition.x >= 8.0 ) + v49 = 1; + else + v50 = 1; + } + else + pGame->pIndoorCameraD3D->Project(&array_73D150[i - 1], 1, 0); + } + } + if ( v53 == pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices ) + LOBYTE(array_77EC08[pODMRenderParams->uNumPolygons].field_32) |= 1; + array_77EC08[pODMRenderParams->uNumPolygons].pODMFace = &pOutdoor->pBModels[model_id].pFaces[face_id]; + array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; + array_77EC08[pODMRenderParams->uNumPolygons].field_59 = 5; + v51 = (unsigned __int64)(-pOutdoor->vSunlight.x * (signed __int64)pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.x) >> 16; + v53 = (unsigned __int64)(-pOutdoor->vSunlight.y * (signed __int64)pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.y) >> 16; + v52 = (unsigned __int64)(-pOutdoor->vSunlight.z * (signed __int64)pOutdoor->pBModels[model_id].pFaces[face_id].pFacePlane.vNormal.z) >> 16; + array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 20 - (20 * (signed int)(v51 + v53 + v52) >> 16); + if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level < 0 ) + array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 0; + if ( array_77EC08[pODMRenderParams->uNumPolygons].dimming_level > 31 ) + array_77EC08[pODMRenderParams->uNumPolygons].dimming_level = 31; + if ( pODMRenderParams->uNumPolygons >= 1999 + 5000) + return; + if ( ODMFace::IsBackfaceCulled(&pOutdoor->pBModels[model_id].pFaces[face_id], array_73D150, &array_77EC08[pODMRenderParams->uNumPolygons]) ) + { + pOutdoor->pBModels[model_id].pFaces[face_id].bVisible = 1; + array_77EC08[pODMRenderParams->uNumPolygons].uBModelFaceID = face_id; + array_77EC08[pODMRenderParams->uNumPolygons].uBModelID = model_id; + v27 = 8 * (face_id | (model_id << 6)); + LOBYTE(v27) = v27 | 6; + array_77EC08[pODMRenderParams->uNumPolygons].field_50 = v27; + for ( int vertex_id = 0; vertex_id < pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices; ++vertex_id) + { + memcpy(&array_50AC10[vertex_id], &array_73D150[vertex_id], sizeof(array_50AC10[vertex_id])); + array_50AC10[vertex_id]._rhw = 1.0 / (array_73D150[vertex_id].vWorldViewPosition.x + 0.0000001); + } + static stru154 static_RenderBuildingsD3D_stru_73C834; + /*static bool __init_flag = false; + if (!__init_flag) + { + __init_flag = true; + static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u; + stru154::stru154(&static_RenderBuildingsD3D_stru_73C834); + atexit(loc_4789D4); + }*/ + + v40 = (int)&pOutdoor->pBModels[model_id].pFaces[face_id]; + pGame->pLightmapBuilder->ApplyLights_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); + pDecalBuilder->ApplyDecals_OutdoorFace(&pOutdoor->pBModels[model_id].pFaces[face_id]); + pGame->pLightmapBuilder->std__vector_000004_size = 0; + int v31 = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + v31 = v50 ? 3 : v49 != 0 ? 5 : 0; + static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(&pOutdoor->pBModels[model_id].pFaces[face_id], &pOutdoor->pBModels[model_id].pVertices); + if ( pDecalBuilder->uNumDecals > 0 ) + { + v40 = -1; + pDecalBuilder->ApplyDecals(31 - array_77EC08[pODMRenderParams->uNumPolygons].dimming_level, 2, &static_RenderBuildingsD3D_stru_73C834, + pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices, array_50AC10, 0, (char)v31, -1); + } + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, array_50AC10, 0, (char)v31); + if ( v50 ) + { + array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = sr_424CD7(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); + uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; + ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); + } + if ( v49 ) + { + array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices = BuildingVerticesClipping(pOutdoor->pBModels[model_id].pFaces[face_id].uNumVertices); + uNumVertices = array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices; + ODM_Project(array_77EC08[pODMRenderParams->uNumPolygons].uNumVertices); + } + if ( uNumVertices ) + { + if ( array_77EC08[pODMRenderParams->uNumPolygons].flags & 2 ) + { + if ( BYTE1(array_77EC08[pODMRenderParams->uNumPolygons].flags) & 0x3C ) + v34 = pRenderer->pHDWaterBitmapIDs[0]; + else + v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + v40 = (int)pBitmaps_LOD->pHardwareTextures[v34]; + } + else + v40 = (int)pBitmaps_LOD->pHardwareTextures[v9]; + pRenderer->DrawPolygon(uNumVertices, &array_77EC08[pODMRenderParams->uNumPolygons], &pOutdoor->pBModels[model_id].pFaces[face_id], (IDirect3DTexture2 *)v40); + } + } + } + } + } + } + } + } + return; } \ No newline at end of file diff -r 11f36943e818 -r 0c4d3c6a9d5a Render.h --- a/Render.h Thu Oct 03 18:09:21 2013 +0600 +++ b/Render.h Fri Oct 04 17:30:47 2013 +0600 @@ -356,7 +356,7 @@ void FillRectFast(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, unsigned int uColor16); int _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7); void _4A6E7E(unsigned int a2, unsigned int a3, struct Texture *a4); - char DrawBuildingsD3D(); + void DrawBuildingsD3D(); //struct BSPModel *DrawBuildingsSW(); //int OnOutdoorRedrawSW(); void DrawSkyD3D(); diff -r 11f36943e818 -r 0c4d3c6a9d5a mm7_3.cpp --- a/mm7_3.cpp Thu Oct 03 18:09:21 2013 +0600 +++ b/mm7_3.cpp Fri Oct 04 17:30:47 2013 +0600 @@ -4282,405 +4282,8 @@ return v16; } -//----- (0047840D) -------------------------------------------------------- -char Render::DrawBuildingsD3D() -{ - //IndoorCameraD3D *v0; // eax@3 - char result; // al@3 - BSPModel *v2; // ebx@4 - int v3; // eax@6 - ODMFace *pFace; // esi@6 - //Vec3_int_ *v5; // ecx@8 - int v6; // eax@8 - struct Polygon *v7; // ebx@8 - //LightmapBuilder *v8; // eax@8 - int v9; // ecx@8 - //char v10; // zf@8 - Texture *pFaceTexture; // eax@10 - signed int v12; // ecx@10 - //unsigned int v13; // eax@14 - //unsigned int v14; // eax@18 - unsigned int v15; // eax@22 - unsigned int v16; // edi@22 - int v17; // eax@24 - int v18; // edi@34 - RenderVertexSoft *v19; // eax@35 - unsigned short *v20; // ecx@35 - unsigned short *v20b; // ecx@35 - unsigned short *v20c; // ecx@35 - Vec3_int_ *v21; // edx@36 - int v22; // edx@36 - RenderVertexSoft *v23; // edi@37 - int v24; // eax@50 - int v25; // ecx@55 - int v26; // eax@57 - int v27; // eax@57 - int v28; // eax@58 - //int v29; // edx@58 - //double v30; // st7@59 - //LightmapBuilder *v31; // edi@63 - signed int v32; // eax@73 - int v33; // eax@78 - unsigned int v34; // eax@80 - std::string v35; // [sp-18h] [bp-70h]@2 - int v36; // [sp-14h] [bp-6Ch]@69 - RenderVertexSoft *v37; // [sp-10h] [bp-68h]@69 - int v38; // [sp-Ch] [bp-64h]@69 - //LightmapBuilder *v39; // [sp-8h] [bp-60h]@2 - int v40; // [sp-4h] [bp-5Ch]@2 - //std::string *v41; // [sp+Ch] [bp-4Ch]@2 - int v41b; - int v42; // [sp+10h] [bp-48h]@6 - LightmapBuilder *pLightmapBuilder; // [sp+14h] [bp-44h]@8 - float v44; // [sp+18h] [bp-40h]@10 - float v45; // [sp+1Ch] [bp-3Ch]@10 - ODMFace *v46; // [sp+20h] [bp-38h]@6 - //IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3 - //unsigned int v48; // [sp+28h] [bp-30h]@8 - int v49; // [sp+2Ch] [bp-2Ch]@10 - int v50; // [sp+30h] [bp-28h]@34 - int v51; // [sp+34h] [bp-24h]@35 - int v52; // [sp+38h] [bp-20h]@36 - int v53; // [sp+3Ch] [bp-1Ch]@8 - Vec3_int_ *v54; // [sp+40h] [bp-18h]@6 - int a1; // [sp+44h] [bp-14h]@3 - BSPModel *v56; // [sp+48h] [bp-10h]@4 - int uNumVertices; // [sp+4Ch] [bp-Ch]@34 - int unused; // [sp+50h] [bp-8h]@3 - int a3; // [sp+57h] [bp-1h]@2 - - if ( !pRenderer->pRenderD3D ) - { - MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); - } - - unused = 0; - a1 = 0; - result = LOBYTE(pOutdoor->pBModels); - v41b = pOutdoor->uNumBModels; - if ( (signed int)pOutdoor->uNumBModels > 0 ) - { - v2 = pOutdoor->pBModels; - v56 = pOutdoor->pBModels; - while ( 1 ) - { - if ( IsBModelVisible(a1, &unused) ) - { - v2->field_40 |= 1u; - v3 = v2->uNumFaces; - pFace = v2->pFaces; - v54 = 0; - v46 = pFace; - v42 = v3; - if ( v3 > 0 ) - break; - } -LABEL_86: - ++a1; - ++v2;// += 47; - result = a1; - v56 = v2; - if ( a1 >= v41b ) - return result; - } - while ( 1 ) - { - if (pFace->Invisible()) - goto LABEL_85; - //v5 = (int)*(v2 - 1); - v6 = pFace->pVertexIDs[0]; - v53 = 0; - v7 = &array_77EC08[pODMRenderParams->uNumPolygons]; - v7->flags = 0; - v7->field_32 = 0; - pLightmapBuilder = (LightmapBuilder *)v2->pVertices.pVertices[v6].z; - v9 = pFace->uTextureID; - if (pFace->uAttributes & FACE_TEXTURE_FRAME) - { - v9 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed); - } - pFaceTexture = pBitmaps_LOD->GetTexture(v9); - v7->pTexture = pFaceTexture; - v12 = pFaceTexture->uTextureWidth; - v49 = v12; - v49 = pFaceTexture->uTextureHeight; - v45 = 1.0 / (double)v12; - v44 = 1.0 / (double)v49; - if (pFace->uAttributes & FACE_FLUID) - *(int *)&v7->flags |= 2u; - if (pFace->uAttributes & FACE_DO_NOT_LIGHT ) - HIBYTE(v7->flags) |= 4u; - if ( pFace->uAttributes & 4 ) - { - HIBYTE(v7->flags) |= 4u; - } - else - { - if ( pFace->uAttributes & 0x20 ) - HIBYTE(v7->flags) |= 8u; - } - if (pFace->uAttributes & 0x0800) - { - *(int *)&v7->flags |= 0x2000u; - } - else - { - if (pFace->uAttributes & FACE_DONT_CACHE_TEXTURE) - HIBYTE(v7->flags) |= 0x10u; - } - v15 = GetTickCount(); - v7->sTextureDeltaU = pFace->sTextureDeltaU; - v7->sTextureDeltaV = pFace->sTextureDeltaV; - v16 = v15 >> 4; - if ( pFace->pFacePlane.vNormal.z && (v40 = pFace->pFacePlane.vNormal.z, abs(v40) >= 59082) ) - { - v17 = *(int *)&v7->flags; - if ( BYTE1(v17) & 4 ) - goto LABEL_29; - if ( BYTE1(v17) & 8 ) - { -LABEL_26: - v7->sTextureDeltaV -= v16 & v7->pTexture->uHeightMinus1; - goto LABEL_30; - } - } - else - { - v17 = *(int *)&v7->flags; - if ( BYTE1(v17) & 4 ) - goto LABEL_26; - if ( BYTE1(v17) & 8 ) - { -LABEL_29: - v7->sTextureDeltaV += v16 & v7->pTexture->uHeightMinus1; - goto LABEL_30; - } - } -LABEL_30: - if ( BYTE1(v17) & 0x10 ) - { - v7->sTextureDeltaU -= v16 & v7->pTexture->uWidthMinus1; - } - else - { - if ( BYTE1(v17) & 0x20 ) - v7->sTextureDeltaU += v16 & v7->pTexture->uWidthMinus1; - } - v18 = pFace->uNumVertices; - v50 = 0; - v49 = 0; - uNumVertices = v18; - if ( v18 > 0 ) - { - //v19 = (char *)&array_73D150[0].vWorldPosition.z; - //v20 = (char *)pFace->pTextureUIDs; - v19 = array_73D150; - v20 = pFace->pTextureUIDs; - v20b = pFace->pVertexIDs; - v20c = pFace->pTextureVIDs; - v51 = v18; - do - { -/* v21 = &(*(v56 - 1))[*((short *)v20 - 20)]; - *((float *)v19 - 2) = (double)v21->x; - *((float *)v19 - 1) = (double)v21->y; - *(float *)v19 = (double)v21->z; - v19 += 48; - v52 = v7->sTextureDeltaU + *(short *)v20; - *((float *)v19 - 5) = (double)v52 * v45; - v22 = v7->sTextureDeltaV + *((short *)v20 + 20); - v20 += 2; - v10 = v51-- == 1; - v52 = v22; - *((float *)v19 - 4) = (double)v22 * v44;*/ - - //v21 = (BSPVertexBuffer *)(*((_DWORD *)v56 - 1) + 12 * *(v20 - 20)); - v21 = &v56->pVertices.pVertices[*v20b]; - //*((float *)v19 - 2) = (double)v21->x; - //*((float *)v19 - 1) = (double)v21->y; - v19->vWorldPosition.x = (double)v21->x; - v19->vWorldPosition.y = (double)v21->y; - v19->vWorldPosition.z = (double)v21->z; - ++v19; - v52 = v7->sTextureDeltaU + (signed __int16)*v20; - //*((float *)v19 - 5) = (double)v52 * v45; - (v19-1)->u = (double)v52 * v45; - v22 = v7->sTextureDeltaV + (signed __int16)*v20c; - ++v20; - ++v20b; - ++v20c; - v52 = v22; - //*((float *)v19 - 4) = (double)v22 * v44; - (v19-1)->v = (double)v22 * v44; - } - while ( !(v51-- == 1) ); - //v23 = (char *)&array_73D150[0].vWorldViewPosition; - v23 = array_73D150; - v51 = uNumVertices; - *(float *)&pLightmapBuilder = (double)(signed int)pLightmapBuilder; - do - { - //if ( *(float *)&pLightmapBuilder == *((float *)v23 - 1) ) - if ( *(float *)&pLightmapBuilder == v23->vWorldPosition.z ) - ++v53; - //v47->ViewTransform((RenderVertexSoft *)(v23 - 12), 1u); - pGame->pIndoorCameraD3D->ViewTransform(v23, 1u); - if ( v23->vWorldViewPosition.x < 8.0 || (double)pODMRenderParams->shading_dist_mist < v23->vWorldViewPosition.x ) - { - if ( v23->vWorldViewPosition.x >= 8.0 ) - v49 = 1; - else - v50 = 1; - } - else - { - pGame->pIndoorCameraD3D->Project(v23, 1u, 0); - } - ++v23;// += 48; - --v51; - } - while ( v51 ); - v18 = uNumVertices; - } - if ( v53 == v18 ) - LOBYTE(v7->field_32) |= 1u; - v24 = pOutdoor->vSunlight.x; - v7->pODMFace = pFace; - v7->uNumVertices = v18; - v7->field_59 = 5; - pLightmapBuilder = (LightmapBuilder *)-v24; - v51 = pFace->pFacePlane.vNormal.x; - v51 = (unsigned __int64)(-v24 * (signed __int64)v51) >> 16; - v53 = pFace->pFacePlane.vNormal.y; - pLightmapBuilder = (LightmapBuilder *)-pOutdoor->vSunlight.y; - v53 = (unsigned __int64)(-pOutdoor->vSunlight.y * (signed __int64)v53) >> 16; - v52 = pFace->pFacePlane.vNormal.z; - v52 = (unsigned __int64)(-pOutdoor->vSunlight.z * (signed __int64)v52) >> 16; - pLightmapBuilder = (LightmapBuilder *)(v51 + v53 + v52); - v51 = 20 * (int)pLightmapBuilder; - result = 20 - (20 * (signed int)pLightmapBuilder >> 16); - v7->dimming_level = result; - if ( result < 0 ) - v7->dimming_level = 0; - if ( v7->dimming_level > 31 ) - v7->dimming_level = 31; - if ( pODMRenderParams->uNumPolygons >= 1999 + 5000) - return result; - ++pODMRenderParams->uNumPolygons; - ++pODMRenderParams->field_44; - if ( ODMFace::IsBackfaceCulled(pFace, array_73D150, v7) ) - { - LOBYTE(v25) = (char)v54; - v26 = a1; - pFace->bVisible = 1; - v7->uBModelFaceID = v25; - LOWORD(v25) = (unsigned __int8)v25; - v7->uBModelID = v26; - v27 = 8 * (v25 | (v26 << 6)); - LOBYTE(v27) = v27 | 6; - v7->field_50 = v27; - - for (v28 = 0; v28 < v18; ++v28) - { - memcpy(&array_50AC10[v28], &array_73D150[v28], sizeof(array_50AC10[v28])); - array_50AC10[v28]._rhw = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001); - - pFace = v46; - } - - static stru154 static_RenderBuildingsD3D_stru_73C834; - /*static bool __init_flag = false; - if (!__init_flag) - { - __init_flag = true; - - static_RenderBuildingsD3D_byte_73C84C_init_flag |= 1u; - stru154::stru154(&static_RenderBuildingsD3D_stru_73C834); - atexit(loc_4789D4); - }*/ - - v40 = (int)pFace; - pGame->pLightmapBuilder->ApplyLights_OutdoorFace(pFace); - pDecalBuilder->ApplyDecals_OutdoorFace(pFace); - pGame->pLightmapBuilder->std__vector_000004_size = 0; - - int v31 = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - v31 = v50 ? 3 : v49 != 0 ? 5 : 0; - static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(pFace, &v56->pVertices); - if ( pDecalBuilder->uNumDecals > 0 ) - { - v40 = -1; - v38 = 0; - v37 = array_50AC10; - v36 = uNumVertices; - pDecalBuilder->ApplyDecals(31 - v7->dimming_level, - 2, - &static_RenderBuildingsD3D_stru_73C834, - uNumVertices, - array_50AC10, - 0, - (char)v31, - -1); - } - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - pGame->pLightmapBuilder->ApplyLights( - &stru_F8AD28, - &static_RenderBuildingsD3D_stru_73C834, - uNumVertices, - array_50AC10, - 0, - (char)v31); - if ( v50 ) - { - v32 = sr_424CD7(uNumVertices); - goto LABEL_76; - } - if ( v49 ) - { - v32 = BuildingVerticesClipping(uNumVertices); -LABEL_76: - v7->uNumVertices = v32; - uNumVertices = v32; - ODM_Project(v32); - } - if ( uNumVertices ) - { - v33 = *(int *)&v7->flags; - if ( v33 & 2 ) - { - if ( BYTE1(v33) & 0x3C ) - v34 = pRenderer->pHDWaterBitmapIDs[0]; - else - v34 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - v40 = (int)pBitmaps_LOD->pHardwareTextures[v34]; - } - else - { - v40 = (int)pBitmaps_LOD->pHardwareTextures[v9]; - } - pRenderer->DrawPolygon(uNumVertices, v7, pFace, (IDirect3DTexture2 *)v40); - } - goto LABEL_85; - } - --pODMRenderParams->uNumPolygons; - --pODMRenderParams->field_44; -LABEL_85: - v54 = (Vec3_int_ *)((char *)v54 + 1); - v2 = v56; - ++pFace; - v46 = pFace; - if ( (signed int)v54 >= (signed int)v42 ) - goto LABEL_86; - } - } - return result; -} // 73C84C: using guessed type char static_RenderBuildingsD3D_byte_73C84C_init_flag; - //----- (00479089) -------------------------------------------------------- bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable) { @@ -5297,10 +4900,13 @@ int v35; // [sp+148h] [bp-1Ch]@4 int screen_center_x; // [sp+14Ch] [bp-18h]@2 int v37; // [sp+154h] [bp-10h]@8 - int v38; // [sp+158h] [bp-Ch]@1 + int pViewportBR_Y; // [sp+158h] [bp-Ch]@1 int v39; // [sp+15Ch] [bp-8h]@4 //int v40; // [sp+160h] [bp-4h]@7 - + +//Хотя сами двухмерные изображения основаны на системе координат XY, накладываются текстуры на объект, основанный на +//осях координат U (горизонталь) и V (вертикаль), обхватывающих поверхность объекта. + extern bool new_sky; if (new_sky) { @@ -5310,7 +4916,7 @@ v30 = ((double)(pODMRenderParams->int_fov_rad * pGame->pIndoorCameraD3D->vPartyPos.z) / ((double)pODMRenderParams->int_fov_rad + 8192.0) + pViewport->uScreenCenterY);//184 изменяется при подъёме на высоту - v38 = pViewport->uScreenCenterY - pODMRenderParams->int_fov_rad / + pViewportBR_Y = pViewport->uScreenCenterY - pODMRenderParams->int_fov_rad / (pODMRenderParams->shading_dist_mist * cos(pGame->pIndoorCameraD3D->sRotationX * 0.003066406352445483) + 0.0000001000000011686097) * (pODMRenderParams->shading_dist_mist * -sin(pGame->pIndoorCameraD3D->sRotationX * 0.003066406352445483) - pGame->pIndoorCameraD3D->vPartyPos.z);//61 / 184 / 310 изменяется при наклоне камеры @@ -5335,7 +4941,7 @@ pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//60928 pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; - //sky position(положение неба)---------------------------------------------- + //sky wiew position(положение неба)------------------------------------------ // X // 0._____________________________.3 // |8,8 468,8 | @@ -5343,7 +4949,7 @@ // | | // Y| | // | | - // |8,? 468,? | + // |8,351 468,351 | // 1._____________________________.2 // @@ -5351,10 +4957,10 @@ array_50AC10[0].vWorldViewProjY = pViewport->uViewportTL_Y;//8 array_50AC10[1].vWorldViewProjX = pViewport->uViewportTL_X;//8 - array_50AC10[1].vWorldViewProjY = v38;//61 / 184 / 310 + array_50AC10[1].vWorldViewProjY = pViewportBR_Y;//61 / 184 / 310 array_50AC10[2].vWorldViewProjX = pViewport->uViewportBR_X;//468 - array_50AC10[2].vWorldViewProjY = v38;//61 / 184 / 310 + array_50AC10[2].vWorldViewProjY = pViewportBR_Y;//61 / 184 / 310 array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X;//468 array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y;//8 @@ -5386,9 +4992,9 @@ v33 = 65536 / (signed int)(screen_center_x / tan(0.6457717418670654) + 0.5);//360 : (расстояние от экрана до камеры в пикселях) = 214 //-------------------------------------------------------------------------- - for (uint i = 0; i < pSkyPolygon.uNumVertices; ++i) - { - v29 = floorf(array_50AC10[i].vWorldViewProjY + 0.5f);//8 + for ( uint vertex_id = 0; vertex_id < pSkyPolygon.uNumVertices; ++vertex_id ) + { + v29 = floorf(array_50AC10[vertex_id].vWorldViewProjY + 0.5f);//8 v39 = (unsigned __int64)(pSkyPolygon.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;//0 v8 = v39 + pSkyPolygon.ptr_38->field_C;//0 @@ -5404,11 +5010,11 @@ v39 = 0; } //v11 = (signed __int64)array_50AC10[i].vWorldViewProjX; - v38 = v10; + pViewportBR_Y = v10; //v12 = array_50AC10[i].vWorldViewProjY - 1.0; - v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX); + v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[vertex_id].vWorldViewProjX); v34 = -pSkyPolygon.field_24; - v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0; + v32 = (signed __int64)array_50AC10[vertex_id].vWorldViewProjY - 1.0; v14 = v33 * (v30 - v32); while ( 1 ) @@ -5422,7 +5028,7 @@ v14 += v33; v10 = pSkyPolygon.v_18.x + v16; v39 = pSkyPolygon.v_18.x + v16; - v38 = pSkyPolygon.v_18.x + v16; + pViewportBR_Y = pSkyPolygon.v_18.x + v16; break; } v37 = abs(v34 >> 14);//2048 @@ -5438,38 +5044,38 @@ v14 += v33; v10 = pSkyPolygon.v_18.x + v16; v39 = pSkyPolygon.v_18.x + v16; - v38 = pSkyPolygon.v_18.x + v16; + pViewportBR_Y = pSkyPolygon.v_18.x + v16; break; } - pShading = fixpoint_div(v34, v38); + pShading = fixpoint_div(v34, pViewportBR_Y); if ( pShading < 0 ) pShading = pODMRenderParams->shading_dist_mist; v37 += ((unsigned __int64)(pSkyPolygon.ptr_38->field_10 * v13) >> 16); screen_center_x += ((unsigned __int64)(pSkyPolygon.ptr_38->field_1C * v13) >> 16); - v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_mul(v37, pShading) / 8; + v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_mul(v37, pShading) / 8;// Медленно вращаем небесный купол screen_center_x = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_mul(screen_center_x, pShading) / 8; - //array_50AC10[i].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; - //array_50AC10[i].vWorldPosition.x = v36 / (pSky.pTexture->uTextureHeight * 65536.0); - //array_50AC10[i].vWorldPosition.y = 1.0 / (pODMRenderParams->shading_dist_mist >> 16); - //array_50AC10[i].vWorldPosition.z = v35 / (pSky.pTexture->uTextureWidth * 65536.0); - //array_50AC10[i]._rhw = 1.0f / (pShading >> 16); - //array_50AC10[i].u = (double)v35 / (65536.0 * pSkyPolygon.pTexture->uTextureWidth); - //array_50AC10[i].v = (double)screen_center_x / (65536.0 * pSkyPolygon.pTexture->uTextureHeight); + //array_50AC10[vertex_id].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; + //array_50AC10[vertex_id].vWorldPosition.x = v36 / (pSky.pTexture->uTextureHeight * 65536.0); + //array_50AC10[vertex_id].vWorldPosition.y = 1.0 / (pODMRenderParams->shading_dist_mist >> 16); + //array_50AC10[vertex_id].vWorldPosition.z = v35 / (pSky.pTexture->uTextureWidth * 65536.0); + //array_50AC10[vertex_id]._rhw = 1.0f / (pShading >> 16); + //array_50AC10[vertex_id].u = (double)v35 / (65536.0 * pSkyPolygon.pTexture->uTextureWidth); + //array_50AC10[vertex_id].v = (double)screen_center_x / (65536.0 * pSkyPolygon.pTexture->uTextureHeight); //----------------------------------------------------------------------------------------- - array_50AC10[i]._rhw = 1.0f; + array_50AC10[vertex_id]._rhw = 1.0f; } //if ( i == _this.uNumVertices - 1 ) //{ pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[pSkyPolygon.uTileBitmapID]); - array_50AC10[0].vWorldViewProjY = v38; + array_50AC10[0].vWorldViewProjY = pViewportBR_Y; array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; - array_50AC10[3].vWorldViewProjY = v38; + array_50AC10[3].vWorldViewProjY = pViewportBR_Y; pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[pSkyPolygon.uTileBitmapID]); //} diff -r 11f36943e818 -r 0c4d3c6a9d5a mm7_6.cpp --- a/mm7_6.cpp Thu Oct 03 18:09:21 2013 +0600 +++ b/mm7_6.cpp Fri Oct 04 17:30:47 2013 +0600 @@ -42,62 +42,6 @@ -//----- (00424EE0) -------------------------------------------------------- -int BuildingVerticesClipping(unsigned int uNumVertices) -{ - signed int previous_vertices_flag; // edi@1 - double t; // st6@10 - bool current_vertices_flag; // [sp+Ch] [bp-28h]@6 - signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1 - int pNextVertices; - //Доп инфо "Программирование трёхмерных игр для windows" Ламот стр 910 - - memcpy(&array_50AC10[uNumVertices], array_50AC10, sizeof(array_50AC10[uNumVertices])); - depth_num_vertices = 0; - previous_vertices_flag = 0; - if ( array_50AC10[0].vWorldViewPosition.x <= pODMRenderParams->shading_dist_mist ) - previous_vertices_flag = 1;//предыдущая грань меньше границы видимости - if ( (signed int)uNumVertices <= 0 ) - return 0; - for ( uint i = 1; i <= uNumVertices; ++i ) - { - current_vertices_flag = pODMRenderParams->shading_dist_mist >= array_50AC10[i].vWorldViewPosition.x; - if ( previous_vertices_flag != current_vertices_flag )//одна из граней за границей видимости - { - if ( current_vertices_flag )//текущая грань меньше границы видимости(предыдущая грань за пределами видимости) - { - //t = far_clip - v0.x / v1.x - v0.x (формула получения точки пересечения отрезка с плоскостью) - t = (pODMRenderParams->shading_dist_mist - array_50AC10[i - 1].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i - 1].vWorldViewPosition.x); - array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i - 1].vWorldViewPosition.y) * t + array_50AC10[i - 1].vWorldViewPosition.y; - array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i - 1].vWorldViewPosition.z) * t + array_50AC10[i - 1].vWorldViewPosition.z; - array_507D30[depth_num_vertices].u = (array_50AC10[i].u - array_50AC10[i - 1].u) * t + array_50AC10[i - 1].u; - array_507D30[depth_num_vertices].v = (array_50AC10[i].v - array_50AC10[i - 1].v) * t + array_50AC10[i - 1].v; - } - else//предыдущая грань меньше границы видимости(текущая грань вышла за пределы видимости) - { - //t = far_clip - v1.x / v0.x - v1.x - t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i - 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x); - array_507D30[depth_num_vertices].vWorldViewPosition.y = (array_50AC10[i - 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t + array_50AC10[i].vWorldViewPosition.y; - array_507D30[depth_num_vertices].vWorldViewPosition.z = (array_50AC10[i - 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t + array_50AC10[i].vWorldViewPosition.z; - array_507D30[depth_num_vertices].u = (array_50AC10[i - 1].u - array_50AC10[i].u) * t + array_50AC10[i].u; - array_507D30[depth_num_vertices].v = (array_50AC10[i - 1].v - array_50AC10[i].v) * t + array_50AC10[i].v; - } - array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist; - array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist; - ++depth_num_vertices; - } - if ( current_vertices_flag )//оба в границе видимости - { - pNextVertices = depth_num_vertices++; - memcpy(&array_507D30[pNextVertices], &array_50AC10[i], 0x30); - } - previous_vertices_flag = current_vertices_flag; - } - if ( depth_num_vertices < 3 ) - return 0; - return depth_num_vertices; -} - //----- (00426A5A) -------------------------------------------------------- void stru319::LootActor(Actor *pActor) {