Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1.     const int arr = 36*3;
  2.  
  3.     // Set the number of vertices in the vertex array.
  4.     m_vertexCount = arr;
  5.  
  6.     // Set the number of indices in the index array.
  7.     m_indexCount = arr;
  8.  
  9.     // Create the vertex array.
  10.     vertices = new VertexType[m_vertexCount];
  11.     if (!vertices)
  12.     {
  13.         return false;
  14.     }
  15.  
  16.  
  17.     // Create the index array.
  18.     indices = new unsigned long[m_indexCount];
  19.     float r = 2.0f;
  20.     float angle = 0;
  21.     if (!indices)
  22.     {
  23.         return false;
  24.     }
  25.     float step = D3DX_PI * 2.0f / 36;
  26.     float S;
  27.     float C;
  28.     int cont = 0;
  29.     S = sinf(angle *D3DX_PI / 180);
  30.     C = cosf(angle * D3DX_PI / 180);
  31.     for (float i = 0; i <D3DX_PI *2.0f; i+= step) {
  32.         float x1 = r * cosf(i) + (-1.0f);
  33.         float y1 = r * sinf(i);
  34.         float x2 = r * cosf(i+step) + (-1.0f);
  35.         float y2 = r * sinf(i+ step);
  36.         vertices[cont].position = D3DXVECTOR3(x1,y1, -1.0f);  // Bottom left.
  37.         vertices[cont].texture = D3DXVECTOR4(0.0f, 1.0f, 1.0f, 1.0f);
  38.  
  39.    
  40.         vertices[cont + 1].position = D3DXVECTOR3(x2,y2, -1.0f);  // Bottom left.
  41.         vertices[cont + 1].texture = D3DXVECTOR4(0.0f, 1.0f, 1.0f, 1.0f);
  42.         cont += 2;
  43.     }
  44.     for (int i = 0; i < arr; i++)
  45.         indices[i] = i;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement