Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. double step = Math::PI / (arc/2);
  2.             for (int i = 0; i < (arc/2) + 1; i++)
  3.             {
  4.                 for (int j = 0; j < arc; j++)
  5.                 {
  6.                     double x = center->X + radius * Math::Sin(step * i) * Math::Cos(step * j);
  7.                     double y = center->Y + radius * Math::Sin(step * i) * Math::Sin(step * j);
  8.                     double z = center->Z + radius * Math::Cos(step * i);
  9.                     vertices->SetRow(arc * i + j, gcnew array<double> {x, y, z, 1});
  10.                     double u = (Mod(Math::Atan((y - center->Y)/(x - center->X)), (Math::PI * 2))) / (Math::PI * 2);
  11.                     if (x == center->X) u = 0;
  12.                     double v = (Math::PI - (Math::Acos((z - center->Z) / radius))) / Math::PI;
  13.                     texture->SetRow(arc * i + j, gcnew array<double> {u, v});
  14.                 }
  15.             }
  16.  
  17.             for (int k = 0; k < pointNum - (arc + 1); k++)
  18.             {
  19.                 sides->SetRow(k, gcnew array<double> {k, k + 1, k + arc});
  20.                 sides->SetRow(pointNum - (arc + 1) + k, gcnew array<double> {k + 1, k + arc, k + arc + 1});
  21.             }
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement