SHARE
TWEET

Untitled

a guest Dec 20th, 2014 3 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     const int maxTessellationLevel     = 64;
  2.     const int trianglesPerHeightSample = 10;
  3.  
  4.     const int xDivisions = trianglesPerHeightSample * TILE_WIDTH  / CHUNKS / maxTessellationLevel;
  5.     const int zDivisions = trianglesPerHeightSample * TILE_HEIGHT / CHUNKS / maxTessellationLevel;
  6.  
  7.     int patchCount = xDivisions * zDivisions;
  8.  
  9.     QVector<float> positionData(2 * patchCount); // 2 floats per vertex
  10.  
  11.     const float dx = 1.0f / MathHelper::toFloat(xDivisions);
  12.     const float dz = 1.0f / MathHelper::toFloat(zDivisions);
  13.  
  14.     for(int j = 0; j < 2 * zDivisions; j += 2)
  15.     {
  16.         float z = MathHelper::toFloat(j) * dz * 0.5;
  17.  
  18.         for(int i = 0; i < 2 * xDivisions; i += 2)
  19.         {
  20.             float x         = MathHelper::toFloat(i) * dx * 0.5;
  21.             const int index = xDivisions * j + i;
  22.  
  23.             positionData[index]     = x;
  24.             positionData[index + 1] = z;
  25.         }
  26.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top