ADTLodImplementation

From wowdev
Revision as of 02:42, 18 August 2021 by Zee (talk | contribs) (Created page with "My implementation of Adt_lod, may not be 100% but seems alright. Adt_lod is basicly just an implementation of non seamless quad tree terrain. The algorithm itself isn't imp...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

My implementation of Adt_lod, may not be 100% but seems alright.

Adt_lod is basicly just an implementation of non seamless quad tree terrain.

The algorithm itself isn't important because everything is precalculated and saved into the lod file. We just create a big vertex buffer for each chunk, and then based on the camera position we keep updating the index buffer based on the information provided in the ADT_lod file.


The vertex buffer looks something like this : [129 * 129] verts that form suqares, followed by [128 * 128] verts that reside in the middle of each square, which is followed by [x] thickness vertices

The thickness verts only show up in the ADT_Lod meshes and in the WDL meshes, and are used to hide the seams that appear where the different lod chunks meet.

They are just a duplicate of the vertices on the borders of each chunk, moved down a bit (32 units for ADT_lod, and 196 for WDL) WDL ones are moved further down to hide bigger gaps


Here's a presudocode implementation, keep in mind I'm using Y up axis here, you may need to convert it to Z up if you're doing it like blizz

  // Keep track of index
  var index = 0;
  // Iterate through the 129 * 129 square verts
  for (var x = 0; x < 129; x++)
  {
     for (var y = 0; y < 129; y++)
     {
        vertices[index] = vec3(-x * 4.1666625, MLVH[index], -y * 4.1666625);
        index++;
     }
  }
  // Iterate through the 128 * 128 center verts
  for (var x = 0; x < 128; x++)
  {
     for (var y = 0; y < 128; y++)
     {
        vertices[index] = vec3(-x * 4.1666625 + 2.08333125, MLVH[index], (-y - 0.5f) * 4.1666625);
        index++;
     }
  }
  // Iterate through all the skirt indices in MLSI, they indicate the vertices on the edge of each LOD
  for (ver i = 0; i < MLSI.Length; i++)
  {
     // Take the existing seam vertex indicated by the index, and make a copy of it below the original
     vertices[index] = vertices[MLSI[i]] - vec3(0, 32f, 0);
     index++;
  }


Now for the indices, you navigate down the quad tree MLND, as far as you need depending on the distance from camera to your ADT chunk at the current moment My implementation goes through all 4 leaf nodes at once, but you may choose to calculate the distance to each of the 4 leaf nodes and only navigate down to the closer ones. I found that second option to be too much of a hassle.

Once you reach the desired level, you copy the indices from MLVI based on the (index, length) described in the current MLND level.

After that you find the appropriate lod in MLLL based on how deep you went through the tree, and copy the indices from MLVI based on (mapAreaLow_index, mapAreaLow_length) in MLLL. These describe the thickness triangles.

Too much pseudocode to write here, good luck. For questions/discussion poke Zee