changeset 2320:847aba0b7f82

draw terrain distance
author Ritor1
date Fri, 21 Mar 2014 01:12:52 +0600
parents 9987f93d7e1f
children 53c9d34024d6
files IndoorCameraD3D.cpp MMT.cpp OSWindow.cpp Render.cpp mm7_data.h
diffstat 5 files changed, 59 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/IndoorCameraD3D.cpp	Thu Mar 20 18:44:27 2014 +0600
+++ b/IndoorCameraD3D.cpp	Fri Mar 21 01:12:52 2014 +0600
@@ -1394,29 +1394,17 @@
 //----- (00436A40) --------------------------------------------------------
 double IndoorCameraD3D::GetPolygonMaxZ(RenderVertexSoft *pVertex, unsigned int uStripType)
 {
-  unsigned int v3; // edx@1
   double result; // st7@1
-  float *v5; // ecx@2
 
-  v3 = uStripType;
   result = 1.1754944e-38;
-  if ( (signed int)uStripType > 0 )
+  for ( uint i = 0; i < uStripType; i++ )
   {
-    v5 = &pVertex->vWorldPosition.z;
-    do
-    {
-      if ( *v5 > result )
-        result = *v5;
-      v5 += 12;
-      --v3;
-    }
-    while ( v3 );
+    if ( pVertex[i].vWorldPosition.z > result )
+      result = pVertex[i].vWorldPosition.z;
   }
   return result;
 }
 
-
-
 // -- new
 // merged from IndoorCamera::Initialize2
 //         and ODMRenderParams::RotationToInts
--- a/MMT.cpp	Thu Mar 20 18:44:27 2014 +0600
+++ b/MMT.cpp	Fri Mar 21 01:12:52 2014 +0600
@@ -189,6 +189,12 @@
     Media::ITrack *track = p->LoadTrack(L"Sounds\\New_Sounds/Stronghold_Theme.mp3");
     track->Play();
   }
+  /*if (!bNoVideo )
+  {
+    Media::Player *p = new Media::Player;//создаётся плеер
+	Media::IMovie *track = p->LoadMovie(L"Anims\\New_Video/3DOLOGO.smk", 640, 480, 0);
+    track->Play();
+  }	 */
 
   pMouse->RemoveHoldingItem();//избавить курсор от вещи
 
--- a/OSWindow.cpp	Thu Mar 20 18:44:27 2014 +0600
+++ b/OSWindow.cpp	Fri Mar 21 01:12:52 2014 +0600
@@ -31,6 +31,7 @@
 bool draw_portals_loops = false;    //видны рамки порталов
 bool new_speed = false;
 bool bSnow = false;
+bool draw_terrain_dist_mist = false;//новая дальность отрисовки тайлов
 
 bool OSWindow::OnMouseLeftClick(int x, int y)
 {
@@ -751,6 +752,12 @@
         AppendMenuW(other_snow, MF_ENABLED | MF_STRING, 40117, L"Snowfall on");
         AppendMenuW(other_snow, MF_ENABLED | MF_STRING, 40118, L"Snowfall off");
       }
+      HMENU other_draw_terrain_dist_mist = CreatePopupMenu();
+      AppendMenuW(other, MF_ENABLED | MF_STRING | MF_POPUP, (UINT_PTR)other_draw_terrain_dist_mist, L"New draw terrain distance");
+      {
+        AppendMenuW(other_draw_terrain_dist_mist, MF_ENABLED | MF_STRING, 40119, L"New draw terrain distance on");
+        AppendMenuW(other_draw_terrain_dist_mist, MF_ENABLED | MF_STRING, 40120, L"New draw terrain distance off");
+      }
 
     }
   }
@@ -887,6 +894,8 @@
     case 40116:  new_speed = false;  break;                          //включить двойную скорость
     case 40117:  bSnow = true;  break;                           //включить снег
     case 40118:  bSnow = false;  break;                          //включить снег
+    case 40119:  draw_terrain_dist_mist = true;  break;                           //новая дальность отрисовки тайлов
+    case 40120:  draw_terrain_dist_mist = false;  break;                          //обычная дальность отрисовки тайлов
 
   }
 
--- a/Render.cpp	Thu Mar 20 18:44:27 2014 +0600
+++ b/Render.cpp	Fri Mar 21 01:12:52 2014 +0600
@@ -359,8 +359,8 @@
         norm = 0;
       else
         norm = &pTerrainNormals[norm_idx];
-      pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &a3a, array_50AC10, 4, 1);//Ritor1: slows
-      pDecalBuilder->_49BE8A(pTilePolygon, norm, &a3a, array_50AC10, 4, 1);
+      //pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &a3a, array_50AC10, 4, 1);//Ritor1: slows
+      //pDecalBuilder->_49BE8A(pTilePolygon, norm, &a3a, array_50AC10, 4, 1);
 //-----------------------------------------------------------------------------------------------
 
       ++pODMRenderParams->uNumPolygons;
@@ -376,7 +376,9 @@
         array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097);
       }
 //---------Draw distance(Дальность отрисовки)-------------------------------
-      pODMRenderParams->shading_dist_mist = 0x5000;
+      int temp =  pODMRenderParams->shading_dist_mist;
+      if ( draw_terrain_dist_mist )
+        pODMRenderParams->shading_dist_mist = 0x5000;
       bool neer_clip = array_73D150[0].vWorldViewPosition.x < 8.0
                     || array_73D150[1].vWorldViewPosition.x < 8.0
                     || array_73D150[2].vWorldViewPosition.x < 8.0
@@ -390,16 +392,15 @@
         if ( neer_clip )
         {
           pTilePolygon->uNumVertices = ODM_NearClip(pTilePolygon->uNumVertices);
-          //ODM_Project(pTilePolygon->uNumVertices);
+          ODM_Project(pTilePolygon->uNumVertices);
         }
         if ( far_clip )
         {
-
           pTilePolygon->uNumVertices = ODM_FarClip(pTilePolygon->uNumVertices);
-          //ODM_Project(pTilePolygon->uNumVertices);
+          ODM_Project(pTilePolygon->uNumVertices);
         }
       }
-      pODMRenderParams->shading_dist_mist = 0x2000;
+      pODMRenderParams->shading_dist_mist = temp;
 
 // check the transparency and texture (tiles) mapping (проверка прозрачности и наложение текстур (тайлов))----------------------
       bool transparent = false;
@@ -8524,16 +8525,38 @@
   bool current_vertices_flag; // edi@1
   bool next_vertices_flag; // [sp+Ch] [bp-24h]@6
   double t; // st6@10
-  //int pNextVertices;
+  bool bFound;
+
+  bFound = false;
 
   if (!num_vertices)
     return 0;
+  for (uint i = 0; i < num_vertices; ++i)// есть ли пограничные вершины
+  {
+    if ( array_50AC10[i].vWorldViewPosition.x > 8.0 )
+    {
+      bFound = true;
+      break;
+    }
+  }
+  if ( !bFound )
+    return 0;
 
   memcpy(&array_50AC10[num_vertices], &array_50AC10[0], sizeof(array_50AC10[0]));
   current_vertices_flag = false;
   next_vertices_flag = false;
   if ( array_50AC10[0].vWorldViewPosition.x <= 8.0 )
     current_vertices_flag = true;
+  //check for near clip plane(проверка по ближней границе)
+  //   
+  // v3.__________________. v0
+  //   |                  |
+  //   |                  |
+  //   |                  |
+  //  ----------------------- 8.0(near_clip - 8.0)
+  //   |                  |
+  //   .__________________.
+  //  v2                     v1
 
   int out_num_vertices = 0;
   for (int i = 0; i < num_vertices; ++i)
@@ -8581,7 +8604,6 @@
   bool next_vertices_flag; // edi@1
   double t; // st6@10
   signed int depth_num_vertices; // [sp+18h] [bp-1Ch]@1
-  //int pNextVertices;
   bool bFound;
   //Доп инфо "Программирование трёхмерных игр для windows" Ламот стр 910
 
@@ -8623,14 +8645,14 @@
       if ( next_vertices_flag )//следующая вершина больше границы видимости(настоящая вершина меньше границы видимости) - v3
       {
         //t = far_clip - v2.x / v3.x - v2.x (формула получения точки пересечения отрезка с плоскостью)
-        t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i + 1].vWorldViewPosition.x - array_50AC10[i].vWorldViewPosition.x);
+        t = (pODMRenderParams->shading_dist_mist - array_50AC10[i].vWorldViewPosition.x) / (array_50AC10[i].vWorldViewPosition.x - array_50AC10[i + 1].vWorldViewPosition.x);
         array_507D30[depth_num_vertices].vWorldViewPosition.x = pODMRenderParams->shading_dist_mist;
         //New_y = v2.y + (v3.y - v2.y)*t
-        array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t;
+        array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t;
         //New_z = v2.z + (v3.z - v2.z)*t
-        array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t;
-        array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t;
-        array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t;
+        array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t;
+        array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t;
+        array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t;
         array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist;
       }
       else//настоящая вершина больше границы видимости(следующая вершина меньше границы видимости) - v0
@@ -8639,11 +8661,11 @@
         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.x = pODMRenderParams->shading_dist_mist;
         //New_y = (v0.y - v1.y)*t + v1.y
-        array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i + 1].vWorldViewPosition.y + (array_50AC10[i].vWorldViewPosition.y - array_50AC10[i + 1].vWorldViewPosition.y) * t;
+        array_507D30[depth_num_vertices].vWorldViewPosition.y = array_50AC10[i].vWorldViewPosition.y + (array_50AC10[i + 1].vWorldViewPosition.y - array_50AC10[i].vWorldViewPosition.y) * t;
         //New_z = (v0.z - v1.z)*t + v1.z
-        array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i + 1].vWorldViewPosition.z + (array_50AC10[i].vWorldViewPosition.z - array_50AC10[i + 1].vWorldViewPosition.z) * t;
-        array_507D30[depth_num_vertices].u = array_50AC10[i + 1].u + (array_50AC10[i].u - array_50AC10[i + 1].u) * t;
-        array_507D30[depth_num_vertices].v = array_50AC10[i + 1].v + (array_50AC10[i].v - array_50AC10[i + 1].v) * t;
+        array_507D30[depth_num_vertices].vWorldViewPosition.z = array_50AC10[i].vWorldViewPosition.z + (array_50AC10[i + 1].vWorldViewPosition.z - array_50AC10[i].vWorldViewPosition.z) * t;
+        array_507D30[depth_num_vertices].u = array_50AC10[i].u + (array_50AC10[i + 1].u - array_50AC10[i].u) * t;
+        array_507D30[depth_num_vertices].v = array_50AC10[i].v + (array_50AC10[i + 1].v - array_50AC10[i].v) * t;
         array_507D30[depth_num_vertices]._rhw = 1.0 / pODMRenderParams->shading_dist_mist;
       }
       ++depth_num_vertices;
@@ -8655,13 +8677,6 @@
     }
     current_vertices_flag = next_vertices_flag;
   }
-  for (uint i = 0; i < depth_num_vertices; ++i)// есть ли пограничные вершины
-  {
-    if ( array_507D30[i].vWorldViewPosition.x > pODMRenderParams->shading_dist_mist )
-    {
-      __debugbreak();
-    }
-  }
   return depth_num_vertices >= 3 ? depth_num_vertices : 0;
 }
 
--- a/mm7_data.h	Thu Mar 20 18:44:27 2014 +0600
+++ b/mm7_data.h	Fri Mar 21 01:12:52 2014 +0600
@@ -785,3 +785,4 @@
 extern bool draw_portals_loops;
 extern bool new_speed;
 extern bool bSnow;
+extern bool draw_terrain_dist_mist;